diff -u b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php --- b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php @@ -99,11 +99,23 @@ // the viewport. $web_assert->assertNotVisibleInViewport('css', $ckeditor_id, 'topLeft', 'CKEditor-enabled body field is visible.'); + $before_url = $session->getCurrentUrl(); + // Trigger a hash change with as target the hidden textarea. $session->executeScript("location.hash = '#edit-body-0-value';"); // Check that the CKEditor-enabled body field is visible in the viewport. $web_assert->assertVisibleInViewport('css', $ckeditor_id, 'topLeft', 'CKEditor-enabled body field is not visible.'); + + // Use JavaScript to go back in the history instead of + // \Behat\Mink\Session::back() because that function doesn't work after a + // hash change. + $session->executeScript("history.back();"); + + $after_url = $session->getCurrentUrl(); + + // Check that going back in the history worked. + self::assertEquals($before_url, $after_url, 'History back works.'); } } diff -u b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php --- b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php +++ b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php @@ -77,6 +77,8 @@ */ public function testFragmentLink() { $session = $this->getSession(); + $web_assert = $this->assertSession(); + $ckeditor_id = '#cke_edit-body-0-value'; $this->drupalGet('node/add/page'); @@ -91,27 +93,9 @@ // visible. PhantomJS runs with a resolution of 1024x768px. $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '800px';"); - // Javascript to test if top of the CKEditor-enabled body field is visible - // in the viewport. The NodeElement::isVisible() method doesn't take the - // viewport into account. - $visibility_check_javascript = <<= 0 && - r.top < (w.innerHeight || e.clientHeight) - ); - }()); -JS; - // Check that the CKEditor-enabled body field is currently not visible in // the viewport. - $this->assertFalse($session->evaluateScript($visibility_check_javascript), 'CKEditor-enabled body field is not visible.'); + $web_assert->assertNotVisibleInViewport('css', $ckeditor_id, 'topLeft', 'CKEditor-enabled body field is not visible.'); // Check if we can find the error fragment link within the errors summary // message. @@ -121,7 +105,7 @@ $errors_link->click(); // Check that the CKEditor-enabled body field is visible in the viewport. - $this->assertTrue($session->evaluateScript($visibility_check_javascript), 'CKEditor-enabled body field is visible.'); + $web_assert->assertVisibleInViewport('css', $ckeditor_id, 'topLeft', 'CKEditor-enabled body field is visible.'); } }