diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-204-fragment.html')
-rw-r--r-- | testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-204-fragment.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-204-fragment.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-204-fragment.html new file mode 100644 index 0000000000..bb47cd3820 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/window-open-204-fragment.html @@ -0,0 +1,63 @@ +<!DOCTYPE html> +<meta charset="UTF-8"> +<title>Fragment navigation on initial empty document created through window.open(url-with-204-response)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/helpers.js"></script> +<body></body> +<script> +/* + When a new window is opened through window.open() it will contain the initial + empty document. If the URL parameter is set to the URL that doesn't load a + new document (e.g. it results in a HTTP 204 response), it will stay on the + initial empty document. If fragment navigations happen, it will still stay on + the initial empty document. + These tests verify the behavior of navigations that happen on the initial + empty document in that situation. They should all be converted to do a + replacement. +*/ +"use strict"; +const url1 = "about:blank#foo"; +const url2 = "resources/code-injector.html?2&pipe=sub(none)&code=" + + encodeURIComponent(postMessageToOpenerOnLoad); + +promise_test(async t => { + // Open a new window with a URL that doesn't load a new document, so it will stay in the initial empty document. + const openedWindow = windowOpen204(t); + + // Do a fragment navigation within the initial empty document through setting location.href. + // This should do a replacement. + openedWindow.location.href = url1; + await new Promise(resolve => t.step_timeout(resolve, 100)); + assert_equals(openedWindow.location.hash, "#foo"); + assert_equals(openedWindow.history.length, 1, + "history.length should not increase after fragment navigation on initial empty document"); + + // Navigate away from the initial empty document through setting location.href. + // This should do a replacement. + openedWindow.location.href = url2; + await waitForMessage(t, "loaded"); + assert_equals(openedWindow.history.length, 1, + "history.length should not increase after normal navigation away from initial empty document"); +}, "location.href"); + +promise_test(async t => { + // Open a new window with a URL that doesn't load a new document, so it will stay in the initial empty document. + const openedWindow = windowOpen204(t); + + // Do a fragment navigation within the initial empty document through location.assign(). + // This should do a replacement. + openedWindow.location.assign(url1); + await new Promise(resolve => t.step_timeout(resolve, 100)); + assert_equals(openedWindow.location.hash, "#foo"); + assert_equals(openedWindow.history.length, 1, + "history.length should not increase after fragment navigation on initial empty document"); + + // Navigate away from the initial empty document through location.assign(). + // This should do a replacement. + openedWindow.location.assign(url2); + await waitForMessage(t, "loaded"); + assert_equals(openedWindow.history.length, 1, + "history.length should not increase after normal navigation away from initial empty document"); +}, "location.assign"); +</script> |