diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/history')
11 files changed, 264 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer-1.html b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer-1.html new file mode 100644 index 0000000000..d083a2a1d3 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer-1.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html> + <head> + <title> + Ensure referrer header persists after + history.pushState/replaceState/fragment navigation and reload + </title> + </head> + <body> + <noscript><p>Enable JavaScript and reload</p></noscript> + <div id="log"></div> + <script type="text/javascript"> + location.href = "history_reload_referrer-2.html?pipe=sub"; + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer-2.html b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer-2.html new file mode 100644 index 0000000000..d85517a15f --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer-2.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<html> + <head> + <title> + Ensure referrer header persists after + history.pushState/replaceState/fragment navigation and reload + </title> + </head> + <body> + <a id="fragment" href="#fragment">fragment</a> + <noscript><p>Enable JavaScript and reload</p></noscript> + <div id="log"></div> + <script type="text/javascript"> + const step = localStorage.getItem("history_reload_referrer_step") || "1"; + localStorage.setItem("history_reload_referrer_step", parseInt(step) + 1); + + var httpReferer = unescape("{{headers[referer]}}"); + var expectedReferrer = location.href.replace( + /\/[^\/]*$/, + "\/history_reload_referrer-1.html" + ); + + parent.test(function () { + parent.assert_equals(httpReferer, expectedReferrer); + }, `Step ${step}: Checking HTTP referrer (is "${httpReferer}")`); + parent.test(function () { + parent.assert_equals(document.referrer, expectedReferrer); + }, `Step ${step}: Checking document.referrer (is "${httpReferer}")`); + + switch (step) { + case "1": + history.pushState("", "", location); + location.reload(); + break; + + case "2": + history.replaceState("", "", location); + location.reload(); + break; + + case "3": + document.getElementById("fragment").click(); + location.reload(); + break; + + case "4": + localStorage.removeItem("history_reload_referrer_step"); + parent.done(); + break; + + default: + throw new Error(`Unexpected step "${step}"`); + } + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer.html b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer.html new file mode 100644 index 0000000000..d11ee89702 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_reload_referrer.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<html> + <head> + <title> + Ensure referrer header persists after + history.pushState/replaceState/fragment navigation and reload + </title> + <script type="text/javascript" src="/resources/testharness.js"></script> + <script + type="text/javascript" + src="/resources/testharnessreport.js" + ></script> + </head> + <body> + <noscript><p>Enable JavaScript and reload</p></noscript> + <div id="log"></div> + <script type="text/javascript"> + setup({ explicit_done: true }); + var iframe = document.createElement("iframe"); + window.onload = function () { + iframe.setAttribute("src", "history_reload_referrer-1.html"); + document.body.appendChild(iframe); + }; + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-replace-from-iframe.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-replace-from-iframe.html new file mode 100644 index 0000000000..a0cd9f25ef --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-replace-from-iframe.html @@ -0,0 +1,31 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Referer with location.replace and location.assign</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <iframe src="/resources/blank.html" hidden></iframe> + <script> + async_test(function(t) { + function on_message(e) { + const referrer = e.data; + assert_equals(referrer, window.location.href); + t.done(); + } + window.addEventListener('message', t.step_func(on_message), false); + document.querySelector("iframe").contentWindow.location.replace("resources/iframe-contents.sub.html?replace"); + }, "Browser sends Referer header in iframe request when location.replace is called from an iframe"); + async_test(function(t) { + function on_message(e) { + const referrer = e.data; + assert_equals(referrer, window.location.href); + t.done(); + } + window.addEventListener('message', t.step_func(on_message), false); + document.querySelector("iframe").contentWindow.location.assign("resources/iframe-contents.sub.html?assign"); + }, "Browser sends Referer header in iframe request when location.assign is called from an iframe"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-replace-from-top-to-nested-iframe.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-replace-from-top-to-nested-iframe.html new file mode 100644 index 0000000000..eb6e4960dc --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-replace-from-top-to-nested-iframe.html @@ -0,0 +1,36 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Referer with location.replace and location.assign with nested iframes</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <iframe src="resources/iframe-with-iframe.html" hidden></iframe> + <script> + const iframe = document.querySelector("iframe"); + async_test(function(t) { + function on_message(e) { + const referrer = e.data; + assert_equals(referrer, iframe.contentWindow.location.href); + t.done(); + } + window.addEventListener('message', t.step_func(on_message), false); + window.addEventListener('load', function () { + iframe.contentDocument.querySelector("iframe").contentWindow.location.replace("/resources/blank.html"); + }, false); + }, "Browser sends Referer header in nested iframe request when location.replace is called on an iframe"); + async_test(function(t) { + function on_message(e) { + const referrer = e.data; + assert_equals(referrer, iframe.contentWindow.location.href); + t.done(); + } + window.addEventListener('message', t.step_func(on_message), false); + window.addEventListener('load', function () { + iframe.contentDocument.querySelector("iframe").contentWindow.location.replace("/resources/blank.html"); + }, false); + }, "Browser sends Referer header in nested iframe request when location.assign is called on an iframe"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-with-nested-iframe.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-with-nested-iframe.html new file mode 100644 index 0000000000..e043623c08 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/assign-with-nested-iframe.html @@ -0,0 +1,21 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Referer with location.assign and nested frames</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <iframe src="resources/replace-or-assign-call-on-iframe.html?assign" hidden></iframe> + <script> + async_test(function(t) { + function on_message(e) { + const nestedIframeReferrer = e.data; + assert_equals(nestedIframeReferrer, document.querySelector("iframe").contentWindow.location.href); + t.done(); + } + window.addEventListener('message', t.step_func(on_message), false); + }, "Browser sends Referer header when location.assign is called in iframe document on another nested iframe element"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/replace-with-nested-iframe.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/replace-with-nested-iframe.html new file mode 100644 index 0000000000..e6620bd29c --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/replace-with-nested-iframe.html @@ -0,0 +1,21 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Referer with location.replace and nested frames</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <iframe src="resources/replace-or-assign-call-on-iframe.html?replace" hidden></iframe> + <script> + async_test(function(t) { + function on_message(e) { + const nestedIframeReferrer = e.data; + assert_equals(nestedIframeReferrer, document.querySelector("iframe").contentWindow.location.href); + t.done(); + } + window.addEventListener('message', t.step_func(on_message), false); + }, "Browser sends Referer header when location.replace is called in iframe document on another nested iframe element"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-contents.sub.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-contents.sub.html new file mode 100644 index 0000000000..8ac0a264db --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-contents.sub.html @@ -0,0 +1,14 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Resource file for test of Referer with location.replace</title> + </head> + <body> + <div></div> + <script> + const referer = "{{header_or_default(referer, missing)}}" + window.parent.postMessage(referer); + document.querySelector("div").textContent = `Referer header: ${referer}`; + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-postmessage-to-parent-parent.sub.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-postmessage-to-parent-parent.sub.html new file mode 100644 index 0000000000..25c4af19a3 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-postmessage-to-parent-parent.sub.html @@ -0,0 +1,14 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Resource file for test of Referer with location.replace</title> + </head> + <body> + <div></div> + <script> + const referer = "{{header_or_default(referer, missing)}}" + window.parent.parent.postMessage(referer); + document.querySelector("div").textContent = `Referer header: ${referer}`; + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-with-iframe.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-with-iframe.html new file mode 100644 index 0000000000..675f293ffa --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/iframe-with-iframe.html @@ -0,0 +1,9 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Resource file for test of Referer with location.replace and location.assign</title> + </head> + <body> + <iframe src="iframe-postmessage-to-parent-parent.sub.html"></iframe> + </body> +</html> diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/replace-or-assign-call-on-iframe.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/replace-or-assign-call-on-iframe.html new file mode 100644 index 0000000000..bdad8334a5 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/resources/replace-or-assign-call-on-iframe.html @@ -0,0 +1,20 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Referer with location.replace and location.assign</title> + </head> + <body> + <iframe src="/resources/blank.html" hidden></iframe> + <script> + window.addEventListener('message', function (e) { + const referrer = e.data; + window.parent.postMessage(referrer); + }); + if (window.location.search === "?replace") { + document.querySelector("iframe").contentWindow.location.replace("iframe-contents.sub.html?replace"); + } else if (window.location.search === "?assign") { + document.querySelector("iframe").contentWindow.location.assign("iframe-contents.sub.html?assign"); + } + </script> + </body> +</html> |