diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/windows/resources')
19 files changed, 239 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/windows/resources/browsing-context-window.html b/testing/web-platform/tests/html/browsers/windows/resources/browsing-context-window.html new file mode 100644 index 0000000000..c1594f637e --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/browsing-context-window.html @@ -0,0 +1,7 @@ +<script> +if (window.parent) { + window.parent.postMessage({ + "thisWindowEquivalency": (window === this) + }, "*"); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/document-domain-setter.html b/testing/web-platform/tests/html/browsers/windows/resources/document-domain-setter.html new file mode 100644 index 0000000000..3b14255571 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/document-domain-setter.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Helper page that sets document.domain</title> +<script> +"use strict"; +document.domain = document.domain; +</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/echo-window-name.html b/testing/web-platform/tests/html/browsers/windows/resources/echo-window-name.html new file mode 100644 index 0000000000..a437fecb2c --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/echo-window-name.html @@ -0,0 +1 @@ +<script>document.write(name)</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-cross-origin.html b/testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-cross-origin.html new file mode 100644 index 0000000000..a1a66ed842 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-cross-origin.html @@ -0,0 +1,2 @@ +<!doctype html> +<iframe scrolling=no frameborder=0 srcdoc='PASS'></iframe> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-printing-pass.html b/testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-printing-pass.html new file mode 100644 index 0000000000..c2dca9185f --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-printing-pass.html @@ -0,0 +1,9 @@ +<!doctype html> +<style> +body { + margin: calc(0.5px * 2 / 3); +} +</style> +<body> +PASS +</body> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/message-parent.html b/testing/web-platform/tests/html/browsers/windows/resources/message-parent.html new file mode 100644 index 0000000000..ba60618ad4 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/message-parent.html @@ -0,0 +1,5 @@ +<script> + window.parent.postMessage({ + "name": window.name, + }, "*"); +</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/nested-post-to-opener.html b/testing/web-platform/tests/html/browsers/windows/resources/nested-post-to-opener.html new file mode 100644 index 0000000000..e92b69d7e7 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/nested-post-to-opener.html @@ -0,0 +1,12 @@ +<body> +<script> + var i = document.createElement("iframe"); + i.name = "nested1"; + document.body.appendChild(i); + + window.opener.postMessage({ + "name": window.name, + "isTop": window.top === window + }, "*"); +</script> +</body> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/noreferrer-window-name.html b/testing/web-platform/tests/html/browsers/windows/resources/noreferrer-window-name.html new file mode 100644 index 0000000000..8c106ca886 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/noreferrer-window-name.html @@ -0,0 +1,8 @@ +<script> + addEventListener("storage", function(e) { + if(e.newValue === "close") { + close() + } + }) + localStorage.setItem("window" + location.hash.slice(1), "tralala") +</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-embed.sub.html b/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-embed.sub.html new file mode 100644 index 0000000000..db0c003141 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-embed.sub.html @@ -0,0 +1,2 @@ +<meta charset=utf-8> +<iframe src=//{{domains[élève]}}:{{location[port]}}/html/browsers/windows/resources/opener-cross-origin.html></iframe> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-end.txt b/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-end.txt new file mode 100644 index 0000000000..8b74fbab8a --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-end.txt @@ -0,0 +1 @@ +THE END diff --git a/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin.html b/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin.html new file mode 100644 index 0000000000..7c536b9213 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin.html @@ -0,0 +1,4 @@ +<script> + parent.opener.location.href = "./opener-cross-origin-end.txt" + parent.window.close() +</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/post-to-opener.html b/testing/web-platform/tests/html/browsers/windows/resources/post-to-opener.html new file mode 100644 index 0000000000..453fec97a7 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/post-to-opener.html @@ -0,0 +1,8 @@ +<script> + if (window.opener) { + window.opener.postMessage({ + "name": window.name, + "isTop": window.top === window + }, "*"); + } +</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/restore-window-name-back.sub.html b/testing/web-platform/tests/html/browsers/windows/resources/restore-window-name-back.sub.html new file mode 100644 index 0000000000..ea2c3a92b4 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/restore-window-name-back.sub.html @@ -0,0 +1,7 @@ +<!doctype html> +<script> + onload = () => { + window.name = "clear"; + history.back(); + }; +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/browsers/windows/resources/restore-window-name.sub.html b/testing/web-platform/tests/html/browsers/windows/resources/restore-window-name.sub.html new file mode 100644 index 0000000000..a1e573a7c0 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/restore-window-name.sub.html @@ -0,0 +1,43 @@ +<!doctype html> +<html> +<head> +<title>popup helper for restore window.name test</title> +<script> + +const search = window.location.search.replace("?", ""); +const name = search.split("=")[1]; + +if (!search.startsWith("name=")) { + throw new Error("Unsupported test!"); +} + +function startTest() { + if (window.name === "start") { + window.name = name; + const url = new URL(window.location); + url.host = "{{hosts[alt][]}}:{{ports[https][0]}}"; + url.pathname = url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1); + url.pathname += "restore-window-name-back.sub.html"; + window.location = url.href; + } +} + +function verifyResult() { + const result = document.getElementById("result"); + if (window.name === "start") { + result.textContent = "Please first click the above 'start test' link."; + return; + } + + result.textContent = window.name === name ? "PASS" : "FAIL"; +} + +</script> +</head> +<body> + <p>Please first click the 'start test' link. And then, click the 'Verify Result' button to verify the result. You should get a PASS after clicking the button</p> + <a id="navigate" href="javascript:void(0)" onclick="startTest()">start test</a><br> + <button onclick="verifyResult()">Verify Result</button> + Result: <a id="result"></a> +</body> +</html> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/target-cross-origin.sub.html b/testing/web-platform/tests/html/browsers/windows/resources/target-cross-origin.sub.html new file mode 100644 index 0000000000..8472f96b90 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/target-cross-origin.sub.html @@ -0,0 +1,3 @@ +<meta charset=utf-8> +<p>Follow this link to open a new browsing context in a separate origin. +<a target=second href="{{location[scheme]}}://{{domains[www2]}}:{{location[port]}}/html/browsers/windows/resources/target-cross-origin.sub.html">link</a>. diff --git a/testing/web-platform/tests/html/browsers/windows/resources/window-close-button.html b/testing/web-platform/tests/html/browsers/windows/resources/window-close-button.html new file mode 100644 index 0000000000..38ec2aef5c --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/window-close-button.html @@ -0,0 +1 @@ +<p>Clicking this button should close this browsing context: <button onclick=window.close()>button</button> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/window-name-stash.py b/testing/web-platform/tests/html/browsers/windows/resources/window-name-stash.py new file mode 100644 index 0000000000..411a4587bc --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/window-name-stash.py @@ -0,0 +1,13 @@ +def main(request, response): + key = request.GET.first(b"id") + if request.method == "POST": + value = request.GET.first(b"value") + request.server.stash.take(key) + request.server.stash.put(key, value) + return b"OK" + else: + value = request.server.stash.take(key) + if value is not None: + return value + else: + return b"NONE" diff --git a/testing/web-platform/tests/html/browsers/windows/resources/window-name.sub.html b/testing/web-platform/tests/html/browsers/windows/resources/window-name.sub.html new file mode 100644 index 0000000000..55fb8ebbbc --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/window-name.sub.html @@ -0,0 +1,102 @@ +<!doctype html> +<title>popup helper</title> +<script> + +const search = window.location.search.replace("?", ""); +const steps = search.split("|"); + +async function proceedTest() { + while (steps.length) { + const step = steps.shift(); + + if (step.startsWith("report=")) { + const id = step.split("=")[1]; + const stashURL = new URL("window-name-stash.py", location); + stashURL.searchParams.set('id', id); + stashURL.searchParams.set('value', window.name); + + await fetch(stashURL, { method: "POST" }); + continue; + } + + if (step === "close") { + window.close(); + break; + } + + if (step === "cross") { + const url = new URL(window.location); + url.host = "{{hosts[alt][]}}:{{ports[https][0]}}"; + url.search = "?" + steps.join("|"); + window.location = url.href; + break; + } + + if (step === "same") { + const url = new URL(window.location); + url.host = "{{host}}:{{ports[https][0]}}"; + url.search = "?" + steps.join("|"); + window.location = url.href; + break; + } + + if (step === "sub") { + const url = new URL(window.location); + url.host = "{{hosts[][www]}}:{{ports[https][0]}}"; + url.search = "?" + steps.join("|"); + window.location = url.href; + break; + } + + if (step === "closeOpener") { + if (window.opener) { + window.opener.close(); + } + continue; + } + + if (step.startsWith("navOpener=")) { + if (!window.opener) { + continue; + } + + let url = step.split("=")[1]; + window.opener.location.href = url; + + continue; + } + + if (step === "open") { + const url = new URL(window.location); + url.host = "{{host}}:{{ports[https][0]}}"; + url.search = "?" + steps.join("|"); + window.open(url); + break; + } + + if (step.startsWith("reportOpener=")) { + const id = step.split("=")[1]; + const stashURL = new URL("window-name-stash.py", location); + stashURL.searchParams.set('id', id); + stashURL.searchParams.set('value', window.opener.name); + + await fetch(stashURL, { method: "POST" }); + continue; + } + + if (step.startsWith("set=")) { + window.name = step.split("=")[1]; + continue; + } + + if (step.startsWith("setDomain=")) { + document.domain = step.split("=")[1]; + continue; + } + + throw new Error("Unsupported step!"); + } +} + +proceedTest(); +</script> diff --git a/testing/web-platform/tests/html/browsers/windows/resources/window-opener.html b/testing/web-platform/tests/html/browsers/windows/resources/window-opener.html new file mode 100644 index 0000000000..c734eb3056 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/windows/resources/window-opener.html @@ -0,0 +1,4 @@ +<script> + localStorage.setItem("opener", window.opener) + window.close() +</script> |