function CKEditor5TestBase::triggerKeyUp

Same name and namespace in other branches
  1. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5TestBase::triggerKeyUp()
  2. 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5TestBase::triggerKeyUp()

Trigger a keyup event on the selected element.

Parameters

string $selector: The css selector for the element.

string $key: The keyCode.

15 calls to CKEditor5TestBase::triggerKeyUp()
AdminUiTest::testLanguageConfigForm in core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php
Tests the language config form.
AdminUiTest::testMessagesDoNotAccumulate in core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php
Ensure CKEditor 5 admin UI's real-time validation errors do not accumulate.
AdminUiTest::testPluginSettingsFormSection in core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php
Tests the plugin settings form section.
CKEditor5AllowedTagsTest::testAllowedTags in core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
Test filter_html allowed tags.
CKEditor5AllowedTagsTest::testFullHtml in core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
Tests full HTML text format.

... See full list

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php, line 95

Class

CKEditor5TestBase
Base class for testing CKEditor 5.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function triggerKeyUp(string $selector, string $key) {
    $script = <<<JS
(function (selector, key) {
  const btn = document.querySelector(selector);
    btn.dispatchEvent(new KeyboardEvent('keydown', { key }));
    btn.dispatchEvent(new KeyboardEvent('keyup', { key }));
})('{<span class="php-variable">$selector</span>}', '{<span class="php-variable">$key</span>}')

JS;
    $options = [
        'script' => $script,
        'args' => [],
    ];
    $this->getSession()
        ->getDriver()
        ->getWebDriverSession()
        ->execute($options);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.