You are here

protected function CKEditorTestTrait::assignNameToCkeditorIframe 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::assignNameToCkeditorIframe()
  2. 9 core/modules/ckeditor/tests/src/Traits/CKEditorTestTrait.php \Drupal\Tests\ckeditor\Traits\CKEditorTestTrait::assignNameToCkeditorIframe()

Assigns a name to the CKEditor iframe.

Parameters

string $id: (optional) The id to assign the iframe element. Defaults to 'ckeditor'.

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

See also

\Behat\Mink\Session::switchToIFrame()

File

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

Class

CKEditorTestTrait
Provides methods to test CKEditor.

Namespace

Drupal\Tests\ckeditor\Traits

Code

protected function assignNameToCkeditorIframe($id = 'ckeditor', $instance_id = 'edit-body-0-value') {
  $javascript = <<<JS
(function(){
  CKEDITOR.instances['{<span class="php-variable">$instance_id</span>}'].element.getParent().find('.cke_wysiwyg_frame').\$[0].id = '{<span class="php-variable">$id</span>}';
})()
JS;
  $this
    ->getSession()
    ->evaluateScript($javascript);
}