You are here

protected function CKEditorTestTrait::waitForEditor in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/ckeditor/tests/src/Traits/CKEditorTestTrait.php \Drupal\Tests\ckeditor\Traits\CKEditorTestTrait::waitForEditor()
  2. 9 core/modules/ckeditor/tests/src/Traits/CKEditorTestTrait.php \Drupal\Tests\ckeditor\Traits\CKEditorTestTrait::waitForEditor()

Waits for CKEditor to initialize.

Parameters

string $instance_id: (optional) The CKEditor instance ID. Defaults to 'edit-body-0-value'.

int $timeout: (optional) Timeout in milliseconds, defaults to 10000.

File

core/modules/ckeditor/tests/src/Traits/CKEditorTestTrait.php, line 20

Class

CKEditorTestTrait
Provides methods to test CKEditor.

Namespace

Drupal\Tests\ckeditor\Traits

Code

protected function waitForEditor($instance_id = 'edit-body-0-value', $timeout = 10000) {
  $condition = <<<JS
      (function() {
        return (
          typeof CKEDITOR !== 'undefined'
          && typeof CKEDITOR.instances["{<span class="php-variable">$instance_id</span>}"] !== 'undefined'
          && CKEDITOR.instances["{<span class="php-variable">$instance_id</span>}"].instanceReady
        );
      }())
JS;
  $this
    ->assertJsCondition($condition, $timeout);
}