diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/history/the-location-interface')
8 files changed, 166 insertions, 0 deletions
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> |