Loading core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ * BigPipe regression tests. * * @group big_pipe * @group #slow */ class BigPipeRegressionTest extends WebDriverTestBase { Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ * Tests for CKEditor 5. * * @group ckeditor5 * @group #slow * @internal */ class CKEditor5Test extends CKEditor5TestBase { Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestBase.php +170 −165 Original line number Diff line number Diff line Loading @@ -160,10 +160,8 @@ public function testAttributeRetentionDuringUpcasting(): void { /** * Tests that arbitrary attributes are allowed via GHS. * * @dataProvider providerLinkability */ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): void { public function testImageArbitraryHtml(): void { $editor = Editor::load('test_format'); $settings = $editor->getSettings(); Loading @@ -171,13 +169,16 @@ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = ['<img data-foo>']; $editor->setSettings($settings); $editor->save(); $format = FilterFormat::load('test_format'); $original_config = $format->filters('filter_html') ->getConfiguration(); // Disable filter_html. if ($unrestricted) { FilterFormat::load('test_format') ->setFilterConfig('filter_html', ['status' => FALSE]) foreach ($this->providerLinkability() as $data) { [$image_type, $unrestricted] = $data; $format_config = $unrestricted ? ['status' => FALSE] : $original_config; $format->setFilterConfig('filter_html', $format_config) ->save(); } // Make the test content have either a block image or an inline image. $img_tag = '<img data-foo="bar" alt="drupalimage test image" data-entity-type="file" ' . $this->imageAttributesAsString() . ' />'; Loading @@ -198,6 +199,7 @@ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): $xpath = new \DOMXPath($this->getEditorDataAsDom()); $this->assertNotEmpty($xpath->query('//img[@data-foo="bar"]')); } } /** * Tests linkability of the image CKEditor widget. Loading @@ -207,31 +209,33 @@ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): * These are CKEditor 5 concepts. * * @see https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/editing-engine.html#conversion * * @dataProvider providerLinkability */ public function testLinkability(string $image_type, bool $unrestricted): void { public function testLinkability(): void { $format = FilterFormat::load('test_format'); $original_config = $format->filters('filter_html') ->getConfiguration(); $original_body_value = $this->host->body->value; foreach ($this->providerLinkability() as $data) { [$image_type, $unrestricted] = $data; assert($image_type === 'inline' || $image_type === 'block'); // Disable filter_html. if ($unrestricted) { FilterFormat::load('test_format') ->setFilterConfig('filter_html', ['status' => FALSE]) $format_config = $unrestricted ? ['status' => FALSE] : $original_config; $format->setFilterConfig('filter_html', $format_config) ->save(); } // Make the test content have either a block image or an inline image. $img_tag = '<img alt="drupalimage test image" data-entity-type="file" ' . $this->imageAttributesAsString() . ' />'; $this->host->body->value .= $image_type === 'block' $this->host->body->value = $original_body_value . ($image_type === 'block' ? $img_tag : "<p>$img_tag</p>"; : "<p>$img_tag</p>"); $this->host->save(); // Adjust the expectations accordingly. $expected_widget_class = $image_type === 'block' ? 'image' : 'image-inline'; $this->drupalGet($this->host->toUrl('edit-form')); $page = $this->getSession()->getPage(); // Adjust the expectations accordingly. $expected_widget_class = $image_type === 'block' ? 'image' : 'image-inline'; $this->drupalGet($this->host->toUrl('edit-form')); $this->waitForEditor(); $assert_session = $this->assertSession(); Loading Loading @@ -353,6 +357,7 @@ public function testLinkability(string $image_type, bool $unrestricted): void { $this->assertCount(1, $xpath->query('//img[@alt="drupalimage test image"]')); $this->assertCount(0, $xpath->query('//a')); } } /** * Tests that alt text is required for images. Loading Loading @@ -457,7 +462,7 @@ public static function providerAltTextRequired(): array { ]; } public static function providerLinkability(): array { protected function providerLinkability(): array { return [ 'BLOCK image, restricted' => ['block', FALSE], 'BLOCK image, unrestricted' => ['block', TRUE], Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php +18 −6 Original line number Diff line number Diff line Loading @@ -27,10 +27,22 @@ */ class MediaTest extends MediaTestBase { /** * Tests the drupal-media tag. */ public function testDrupalMedia(): void { $this->testConversion(); $this->testOnlyDrupalMediaTagProcessed(); $this->testEditableCaption(); $this->testAlignment(); $this->testAlt(); $this->testMediaSplitList(); } /** * Tests that `<drupal-media>` is converted into a block element. */ public function testConversion(): void { protected function testConversion(): void { // Wrap the `<drupal-media>` markup in a `<p>`. $original_value = $this->host->body->value; $this->host->body->value = '<p>foo' . $original_value . '</p>'; Loading @@ -50,7 +62,7 @@ public function testConversion(): void { * * @see \Drupal\Tests\media\Kernel\MediaEmbedFilterTest::testOnlyDrupalMediaTagProcessed() */ public function testOnlyDrupalMediaTagProcessed(): void { protected function testOnlyDrupalMediaTagProcessed(): void { $original_value = $this->host->body->value; $this->host->body->value = str_replace('drupal-media', 'p', $original_value); $this->host->save(); Loading @@ -75,7 +87,7 @@ public function testOnlyDrupalMediaTagProcessed(): void { /** * Tests adding media to a list does not split the list. */ public function testMediaSplitList(): void { protected function testMediaSplitList(): void { $assert_session = $this->assertSession(); $editor = Editor::load('test_format'); Loading Loading @@ -193,7 +205,7 @@ function (ConstraintViolation $v) { /** * Tests caption editing in the CKEditor widget. */ public function testEditableCaption(): void { protected function testEditableCaption(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); // Test that setting caption to blank string doesn't break 'Edit media' Loading Loading @@ -362,7 +374,7 @@ public function testAltDisabled(): void { /** * Tests the CKEditor 5 media plugin can override image media's alt attribute. */ public function testAlt(): void { protected function testAlt(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->drupalGet($this->host->toUrl('edit-form')); Loading Loading @@ -572,7 +584,7 @@ public function testTranslationAlt(): void { * the media style toolbar allows altering the alignment and that the changes * are reflected on the widget and downcast drupal-media tag. */ public function testAlignment(): void { protected function testAlignment(): void { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalGet($this->host->toUrl('edit-form')); Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php +32 −18 Original line number Diff line number Diff line Loading @@ -68,28 +68,31 @@ public function testSourceEditingSettingsForm(): void { /** * Tests allowing extra attributes on already supported tags using GHS. * * @dataProvider providerAllowingExtraAttributes */ public function testAllowingExtraAttributes(string $original_markup, string $expected_markup, ?string $allowed_elements_string = NULL): void { $this->host->body->value = $original_markup; $this->host->save(); if ($allowed_elements_string) { public function testAllowingExtraAttributes(): void { $original_text_editor = Editor::load('test_format'); $original_text_format = FilterFormat::load('test_format'); $allowed_elements = HTMLRestrictions::fromTextFormat($original_text_format); $filter_html_config = $original_text_format->filters('filter_html') ->getConfiguration(); foreach ($this->providerAllowingExtraAttributes() as $data) { $text_editor = clone $original_text_editor; $text_format = clone $original_text_format; [$original_markup, $expected_markup, $allowed_elements_string] = $data; // Allow creating additional HTML using SourceEditing. $text_editor = Editor::load('test_format'); $settings = $text_editor->getSettings(); if ($allowed_elements_string) { $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'][] = $allowed_elements_string; } $text_editor->setSettings($settings); $new_config = $filter_html_config; if ($allowed_elements_string) { // Keep the allowed HTML tags in sync. $text_format = FilterFormat::load('test_format'); $allowed_elements = HTMLRestrictions::fromTextFormat($text_format); $updated_allowed_tags = $allowed_elements->merge(HTMLRestrictions::fromString($allowed_elements_string)); $filter_html_config = $text_format->filters('filter_html') ->getConfiguration(); $filter_html_config['settings']['allowed_html'] = $updated_allowed_tags->toFilterHtmlAllowedTagsString(); $text_format->setFilterConfig('filter_html', $filter_html_config); $new_config['settings']['allowed_html'] = $updated_allowed_tags->toFilterHtmlAllowedTagsString(); } $text_format->setFilterConfig('filter_html', $new_config); // Verify the text format and editor are still a valid pair. $this->assertSame([], array_map( Loading @@ -105,8 +108,16 @@ function (ConstraintViolation $v) { // If valid, save both. $text_format->save(); $text_editor->save(); $this->doTestAllowingExtraAttributes($original_markup, $expected_markup, $allowed_elements_string); } } /** * Tests extra attributes with a specific data set. */ protected function doTestAllowingExtraAttributes(string $original_markup, string $expected_markup, string $allowed_elements_string): void { $this->host->body->value = $original_markup; $this->host->save(); $this->drupalGet($this->host->toUrl('edit-form')); $this->waitForEditor(); $this->assertSame($expected_markup, $this->getEditorDataAsHtmlString()); Loading @@ -118,12 +129,13 @@ function (ConstraintViolation $v) { * @return array * The test cases. */ public static function providerAllowingExtraAttributes(): array { protected function providerAllowingExtraAttributes(): array { $general_test_case_markup = '<div class="llama" data-llama="🦙"><p data-llama="🦙">The <a href="https://example.com/pirate" class="button" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" class="use-ajax" data-grammar="adjective">irate</a>.</p></div>'; return [ 'no extra attributes allowed' => [ $general_test_case_markup, '<div class="llama"><p>The <a href="https://example.com/pirate">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>', '', ], // Common case: any attribute that is not `style` or `class`. Loading Loading @@ -224,6 +236,7 @@ public static function providerAllowingExtraAttributes(): array { 'no numberedList-related additions to the Source Editing configuration' => [ '<ol type="A"><li>foo</li><li>bar</li></ol>', '<ol><li>foo</li><li>bar</li></ol>', '', ], '<ol type>' => [ '<ol type="A"><li>foo</li><li>bar</li></ol>', Loading @@ -238,6 +251,7 @@ public static function providerAllowingExtraAttributes(): array { 'no bulletedList-related additions to the Source Editing configuration' => [ '<ul type="circle"><li>foo</li><li>bar</li></ul>', '<ul><li>foo</li><li>bar</li></ul>', '', ], '<ul type>' => [ '<ul type="circle"><li>foo</li><li>bar</li></ul>', Loading Loading
core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ * BigPipe regression tests. * * @group big_pipe * @group #slow */ class BigPipeRegressionTest extends WebDriverTestBase { Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ * Tests for CKEditor 5. * * @group ckeditor5 * @group #slow * @internal */ class CKEditor5Test extends CKEditor5TestBase { Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestBase.php +170 −165 Original line number Diff line number Diff line Loading @@ -160,10 +160,8 @@ public function testAttributeRetentionDuringUpcasting(): void { /** * Tests that arbitrary attributes are allowed via GHS. * * @dataProvider providerLinkability */ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): void { public function testImageArbitraryHtml(): void { $editor = Editor::load('test_format'); $settings = $editor->getSettings(); Loading @@ -171,13 +169,16 @@ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = ['<img data-foo>']; $editor->setSettings($settings); $editor->save(); $format = FilterFormat::load('test_format'); $original_config = $format->filters('filter_html') ->getConfiguration(); // Disable filter_html. if ($unrestricted) { FilterFormat::load('test_format') ->setFilterConfig('filter_html', ['status' => FALSE]) foreach ($this->providerLinkability() as $data) { [$image_type, $unrestricted] = $data; $format_config = $unrestricted ? ['status' => FALSE] : $original_config; $format->setFilterConfig('filter_html', $format_config) ->save(); } // Make the test content have either a block image or an inline image. $img_tag = '<img data-foo="bar" alt="drupalimage test image" data-entity-type="file" ' . $this->imageAttributesAsString() . ' />'; Loading @@ -198,6 +199,7 @@ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): $xpath = new \DOMXPath($this->getEditorDataAsDom()); $this->assertNotEmpty($xpath->query('//img[@data-foo="bar"]')); } } /** * Tests linkability of the image CKEditor widget. Loading @@ -207,31 +209,33 @@ public function testImageArbitraryHtml(string $image_type, bool $unrestricted): * These are CKEditor 5 concepts. * * @see https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/editing-engine.html#conversion * * @dataProvider providerLinkability */ public function testLinkability(string $image_type, bool $unrestricted): void { public function testLinkability(): void { $format = FilterFormat::load('test_format'); $original_config = $format->filters('filter_html') ->getConfiguration(); $original_body_value = $this->host->body->value; foreach ($this->providerLinkability() as $data) { [$image_type, $unrestricted] = $data; assert($image_type === 'inline' || $image_type === 'block'); // Disable filter_html. if ($unrestricted) { FilterFormat::load('test_format') ->setFilterConfig('filter_html', ['status' => FALSE]) $format_config = $unrestricted ? ['status' => FALSE] : $original_config; $format->setFilterConfig('filter_html', $format_config) ->save(); } // Make the test content have either a block image or an inline image. $img_tag = '<img alt="drupalimage test image" data-entity-type="file" ' . $this->imageAttributesAsString() . ' />'; $this->host->body->value .= $image_type === 'block' $this->host->body->value = $original_body_value . ($image_type === 'block' ? $img_tag : "<p>$img_tag</p>"; : "<p>$img_tag</p>"); $this->host->save(); // Adjust the expectations accordingly. $expected_widget_class = $image_type === 'block' ? 'image' : 'image-inline'; $this->drupalGet($this->host->toUrl('edit-form')); $page = $this->getSession()->getPage(); // Adjust the expectations accordingly. $expected_widget_class = $image_type === 'block' ? 'image' : 'image-inline'; $this->drupalGet($this->host->toUrl('edit-form')); $this->waitForEditor(); $assert_session = $this->assertSession(); Loading Loading @@ -353,6 +357,7 @@ public function testLinkability(string $image_type, bool $unrestricted): void { $this->assertCount(1, $xpath->query('//img[@alt="drupalimage test image"]')); $this->assertCount(0, $xpath->query('//a')); } } /** * Tests that alt text is required for images. Loading Loading @@ -457,7 +462,7 @@ public static function providerAltTextRequired(): array { ]; } public static function providerLinkability(): array { protected function providerLinkability(): array { return [ 'BLOCK image, restricted' => ['block', FALSE], 'BLOCK image, unrestricted' => ['block', TRUE], Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php +18 −6 Original line number Diff line number Diff line Loading @@ -27,10 +27,22 @@ */ class MediaTest extends MediaTestBase { /** * Tests the drupal-media tag. */ public function testDrupalMedia(): void { $this->testConversion(); $this->testOnlyDrupalMediaTagProcessed(); $this->testEditableCaption(); $this->testAlignment(); $this->testAlt(); $this->testMediaSplitList(); } /** * Tests that `<drupal-media>` is converted into a block element. */ public function testConversion(): void { protected function testConversion(): void { // Wrap the `<drupal-media>` markup in a `<p>`. $original_value = $this->host->body->value; $this->host->body->value = '<p>foo' . $original_value . '</p>'; Loading @@ -50,7 +62,7 @@ public function testConversion(): void { * * @see \Drupal\Tests\media\Kernel\MediaEmbedFilterTest::testOnlyDrupalMediaTagProcessed() */ public function testOnlyDrupalMediaTagProcessed(): void { protected function testOnlyDrupalMediaTagProcessed(): void { $original_value = $this->host->body->value; $this->host->body->value = str_replace('drupal-media', 'p', $original_value); $this->host->save(); Loading @@ -75,7 +87,7 @@ public function testOnlyDrupalMediaTagProcessed(): void { /** * Tests adding media to a list does not split the list. */ public function testMediaSplitList(): void { protected function testMediaSplitList(): void { $assert_session = $this->assertSession(); $editor = Editor::load('test_format'); Loading Loading @@ -193,7 +205,7 @@ function (ConstraintViolation $v) { /** * Tests caption editing in the CKEditor widget. */ public function testEditableCaption(): void { protected function testEditableCaption(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); // Test that setting caption to blank string doesn't break 'Edit media' Loading Loading @@ -362,7 +374,7 @@ public function testAltDisabled(): void { /** * Tests the CKEditor 5 media plugin can override image media's alt attribute. */ public function testAlt(): void { protected function testAlt(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->drupalGet($this->host->toUrl('edit-form')); Loading Loading @@ -572,7 +584,7 @@ public function testTranslationAlt(): void { * the media style toolbar allows altering the alignment and that the changes * are reflected on the widget and downcast drupal-media tag. */ public function testAlignment(): void { protected function testAlignment(): void { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalGet($this->host->toUrl('edit-form')); Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php +32 −18 Original line number Diff line number Diff line Loading @@ -68,28 +68,31 @@ public function testSourceEditingSettingsForm(): void { /** * Tests allowing extra attributes on already supported tags using GHS. * * @dataProvider providerAllowingExtraAttributes */ public function testAllowingExtraAttributes(string $original_markup, string $expected_markup, ?string $allowed_elements_string = NULL): void { $this->host->body->value = $original_markup; $this->host->save(); if ($allowed_elements_string) { public function testAllowingExtraAttributes(): void { $original_text_editor = Editor::load('test_format'); $original_text_format = FilterFormat::load('test_format'); $allowed_elements = HTMLRestrictions::fromTextFormat($original_text_format); $filter_html_config = $original_text_format->filters('filter_html') ->getConfiguration(); foreach ($this->providerAllowingExtraAttributes() as $data) { $text_editor = clone $original_text_editor; $text_format = clone $original_text_format; [$original_markup, $expected_markup, $allowed_elements_string] = $data; // Allow creating additional HTML using SourceEditing. $text_editor = Editor::load('test_format'); $settings = $text_editor->getSettings(); if ($allowed_elements_string) { $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'][] = $allowed_elements_string; } $text_editor->setSettings($settings); $new_config = $filter_html_config; if ($allowed_elements_string) { // Keep the allowed HTML tags in sync. $text_format = FilterFormat::load('test_format'); $allowed_elements = HTMLRestrictions::fromTextFormat($text_format); $updated_allowed_tags = $allowed_elements->merge(HTMLRestrictions::fromString($allowed_elements_string)); $filter_html_config = $text_format->filters('filter_html') ->getConfiguration(); $filter_html_config['settings']['allowed_html'] = $updated_allowed_tags->toFilterHtmlAllowedTagsString(); $text_format->setFilterConfig('filter_html', $filter_html_config); $new_config['settings']['allowed_html'] = $updated_allowed_tags->toFilterHtmlAllowedTagsString(); } $text_format->setFilterConfig('filter_html', $new_config); // Verify the text format and editor are still a valid pair. $this->assertSame([], array_map( Loading @@ -105,8 +108,16 @@ function (ConstraintViolation $v) { // If valid, save both. $text_format->save(); $text_editor->save(); $this->doTestAllowingExtraAttributes($original_markup, $expected_markup, $allowed_elements_string); } } /** * Tests extra attributes with a specific data set. */ protected function doTestAllowingExtraAttributes(string $original_markup, string $expected_markup, string $allowed_elements_string): void { $this->host->body->value = $original_markup; $this->host->save(); $this->drupalGet($this->host->toUrl('edit-form')); $this->waitForEditor(); $this->assertSame($expected_markup, $this->getEditorDataAsHtmlString()); Loading @@ -118,12 +129,13 @@ function (ConstraintViolation $v) { * @return array * The test cases. */ public static function providerAllowingExtraAttributes(): array { protected function providerAllowingExtraAttributes(): array { $general_test_case_markup = '<div class="llama" data-llama="🦙"><p data-llama="🦙">The <a href="https://example.com/pirate" class="button" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" class="use-ajax" data-grammar="adjective">irate</a>.</p></div>'; return [ 'no extra attributes allowed' => [ $general_test_case_markup, '<div class="llama"><p>The <a href="https://example.com/pirate">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>', '', ], // Common case: any attribute that is not `style` or `class`. Loading Loading @@ -224,6 +236,7 @@ public static function providerAllowingExtraAttributes(): array { 'no numberedList-related additions to the Source Editing configuration' => [ '<ol type="A"><li>foo</li><li>bar</li></ol>', '<ol><li>foo</li><li>bar</li></ol>', '', ], '<ol type>' => [ '<ol type="A"><li>foo</li><li>bar</li></ol>', Loading @@ -238,6 +251,7 @@ public static function providerAllowingExtraAttributes(): array { 'no bulletedList-related additions to the Source Editing configuration' => [ '<ul type="circle"><li>foo</li><li>bar</li></ul>', '<ul><li>foo</li><li>bar</li></ul>', '', ], '<ul type>' => [ '<ul type="circle"><li>foo</li><li>bar</li></ul>', Loading