function CKEditorTestTrait::waitForEditor

Same name in other branches
  1. 8.9.x 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.

14 calls to CKEditorTestTrait::waitForEditor()
CKEditorIntegrationTest::testDrupalImageCaptionDialog in core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
Tests if the Drupal Image Caption plugin appears and works as expected.
MediaLibraryTest::testAllowedMediaTypes in core/modules/ckeditor/tests/src/FunctionalJavascript/MediaLibraryTest.php
Tests the allowed media types setting on the MediaEmbed filter.
MediaLibraryTest::testButton in core/modules/ckeditor/tests/src/FunctionalJavascript/MediaLibraryTest.php
Tests using DrupalMediaLibrary button to embed media into CKEditor.
MediaTest::testAlignment in core/modules/ckeditor/tests/src/FunctionalJavascript/MediaTest.php
Tests alignment integration.
MediaTest::testAlt in core/modules/ckeditor/tests/src/FunctionalJavascript/MediaTest.php
Tests the EditorMediaDialog can set the alt attribute.

... See full list

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);
}

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