diff --git a/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php index 071b4121c8..5bd2990e40 100644 --- a/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php +++ b/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php @@ -243,14 +243,13 @@ public function testPreviewUsesDefaultThemeAndIsClientCacheable() { $this->assertNotEmpty($assert_session->waitForElementVisible('css', 'img[src*="image-test.png"]')); $element = $assert_session->elementExists('css', '[data-media-embed-test-active-theme]'); $this->assertSame('stable', $element->getAttribute('data-media-embed-test-active-theme')); - // Assert that the first preview request transferred >500 B over the wire. // Then toggle source mode on and off. This causes the CKEditor widget to be // destroyed and then reconstructed. Assert that during this reconstruction, // a second request is sent. This second request should have transferred 0 // bytes: the browser should have cached the response, thus resulting in a // much better user experience. - $this->assertGreaterThan(500, $this->getLastPreviewRequestTransferSize()); + $this->assertGreaterThan(500, $this->getInitialPreviewRequestTransferSize()); $this->pressEditorButton('source'); $this->assertNotEmpty($assert_session->waitForElement('css', 'textarea.cke_source')); $this->pressEditorButton('source'); @@ -1352,6 +1351,26 @@ protected function closeDialog() { $this->assertTrue($result); } + /** + * Gets the transfer size of the initial preview request. + * + * @return int + * The size of the bytes transferred. + */ + protected function getInitialPreviewRequestTransferSize() { + $this->getSession()->switchToIFrame(); + $javascript = <<getSession()->evaluateScript($javascript); + } + /** * Gets the transfer size of the last preview request. *