function AjaxCssTest::testCkeditorAjaxAddCss

Same name and namespace in other branches
  1. 8.9.x core/modules/ckeditor/tests/src/FunctionalJavascript/AjaxCssTest.php \Drupal\Tests\ckeditor\FunctionalJavascript\AjaxCssTest::testCkeditorAjaxAddCss()

Tests adding style sheets dynamically to CKEditor.

File

core/modules/ckeditor/tests/src/FunctionalJavascript/AjaxCssTest.php, line 49

Class

AjaxCssTest
Tests delivery of CSS to CKEditor via AJAX.

Namespace

Drupal\Tests\ckeditor\FunctionalJavascript

Code

public function testCkeditorAjaxAddCss() {
    $this->drupalGet('/ckeditor_test/ajax_css');
    $session = $this->getSession();
    $page = $session->getPage();
    $this->waitOnCkeditorInstance('edit-iframe-value');
    $this->waitOnCkeditorInstance('edit-inline');
    $style_color = 'rgb(255, 0, 0)';
    // Add the inline CSS and assert that the style is applied to the main body,
    // but not the iframe.
    $page->pressButton('Add CSS to inline CKEditor instance');
    $result = $page->waitFor(10, function () use ($style_color) {
        return $this->getEditorStyle('edit-inline', 'color') == $style_color && $this->getEditorStyle('edit-iframe-value', 'color') != $style_color;
    });
    $this->assertTrue($result);
    $session->reload();
    $this->waitOnCkeditorInstance('edit-iframe-value');
    $this->waitOnCkeditorInstance('edit-inline');
    // Add the iframe CSS and assert that the style is applied to the iframe,
    // but not the main body.
    $page->pressButton('Add CSS to iframe CKEditor instance');
    $result = $page->waitFor(10, function () use ($style_color) {
        return $this->getEditorStyle('edit-inline', 'color') != $style_color && $this->getEditorStyle('edit-iframe-value', 'color') == $style_color;
    });
    $this->assertTrue($result);
}

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