summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-api/navigate-event/cross-window
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/navigation-api/navigate-event/cross-window
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/navigation-api/navigate-event/cross-window')
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin-sameorigindomain.sub.html41
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin.html30
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-sameorigin.html29
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub.html41
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin.html39
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin.html27
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin-sameorigindomain.sub.html34
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin.html23
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-sameorigin.html26
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub.html34
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin.html32
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin.html26
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin-sameorigindomain.sub.html35
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin.html24
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-sameorigin.html26
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub.html35
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin.html33
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin.html26
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/cross-origin-iframe-helper.html28
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/document-domain-setter.sub.html3
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin-sameorigindomain.sub.html41
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin.html30
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-sameorigin.html27
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub.html41
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin.html39
-rw-r--r--testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin.html27
26 files changed, 797 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..004e1a75e3
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.name = "windowname";
+ iframe.src = url;
+ document.body.append(iframe);
+
+ url.search = "?foo";
+ const link = document.createElement("a");
+ link.href = url;
+ link.target = iframe.name;
+ document.body.append(link);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, link.href, "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ link.click();
+ });
+}, "clicking on an <a> element that navigates cross-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin.html
new file mode 100644
index 0000000000..2f40238912
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-crossorigin.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const url = new URL("resources/cross-origin-iframe-helper.html", location.href);
+ url.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe");
+ iframe.src = url;
+ iframe.name = "windowname";
+ document.body.append(iframe);
+
+ url.search = "?postMessage-top-when-done";
+ const link = document.createElement("a");
+ link.href = url;
+ link.target = iframe.name;
+ document.body.append(link);
+
+ window.onmessage = t.step_func_done(e => {
+ // If we hit onnavigate in the target window, we'll get a different message, and fail.
+ assert_equals(e.data, "DONE");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => link.click());
+}, "clicking on an <a> element that navigates cross-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-sameorigin.html
new file mode 100644
index 0000000000..683875d006
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-crossdocument-sameorigin.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<a id="link" href="/common/blank.html?foo" target="windowname">Click me</a>
+<iframe id="i" name="windowname" src="/common/blank.html"></iframe>
+
+<script>
+async_test(t => {
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, link.href, "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ link.click();
+ });
+}, "clicking on an <a> element that navigates cross-document targeting a same-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..60d1653a3a
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.name = "windowname";
+ iframe.src = url;
+ document.body.append(iframe);
+
+ url.hash = "#foo";
+ const link = document.createElement("a");
+ link.href = url;
+ link.target = iframe.name;
+ document.body.append(link);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, link.href, "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ link.click();
+ });
+}, "clicking on an <a> element that navigates same-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin.html
new file mode 100644
index 0000000000..ee01e7f1f2
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin.html
@@ -0,0 +1,39 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const url = new URL("resources/cross-origin-iframe-helper.html", location.href);
+ url.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe")
+ iframe.src = url;
+ iframe.name = "windowname";
+ document.body.append(iframe);
+
+ url.hash = "#foo";
+ const link = document.createElement("a");
+ link.href = url;
+ link.target = iframe.name;
+ document.body.append(link);
+
+ window.onmessage = t.step_func_done(e => {
+ assert_equals(e.data.navigationType, "push", "navigationType");
+ assert_true(e.data.cancelable, "cancelable");
+ assert_true(e.data.canIntercept, "canIntercept");
+ assert_false(e.data.userInitiated, "userInitiated");
+ assert_true(e.data.hashChange, "hashChange");
+ assert_equals(e.data.formData, null, "formData");
+ assert_equals(e.data.destination.url, link.href, "destination.url");
+ assert_true(e.data.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.data.destination.key, "", "destination.key");
+ assert_equals(e.data.destination.id, "", "destination.id");
+ assert_equals(e.data.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => link.click());
+}, "clicking on an <a> element that navigates same-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin.html
new file mode 100644
index 0000000000..eaa7b52345
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<a id="link" href="/common/blank.html#foo" target="windowname">Click me</a>
+<iframe id="i" name="windowname" src="/common/blank.html"></iframe>
+
+<script>
+async_test(t => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, link.href, "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => link.click());
+}, "clicking on an <a> element that navigates same-document targeting a same-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..cee7d95b9e
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.src = url;
+ document.body.append(iframe);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, iframe.src + "?foo", "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ iframe.contentWindow.location.href = url + "?foo";
+ });
+}, "using location.href to navigate cross-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin.html
new file mode 100644
index 0000000000..79df86fdc9
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-crossorigin.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const iframeURL = new URL("resources/cross-origin-iframe-helper.html", location.href);
+ iframeURL.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe");
+ iframe.src = iframeURL;
+ document.body.append(iframe);
+
+ window.onmessage = t.step_func_done(e => {
+ // If we hit onnavigate in the target window, we'll get a different message, and fail.
+ assert_equals(e.data, "DONE");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => iframe.contentWindow.location.href = iframeURL + "?postMessage-top-when-done");
+}, "using location.href to navigate cross-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-sameorigin.html
new file mode 100644
index 0000000000..d0dad46b72
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-crossdocument-sameorigin.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id="i" src="/common/blank.html"></iframe>
+
+<script>
+async_test(t => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, i.src + "?foo", "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => i.contentWindow.location.href = "/common/blank.html?foo");
+}, "using location.href to navigate cross-document targeting a same-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..156d1cb3cf
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.src = url;
+ document.body.append(iframe);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, iframe.src + "#foo", "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ iframe.contentWindow.location.href = url + "#foo";
+ });
+}, "using location.href to navigate same-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin.html
new file mode 100644
index 0000000000..6d73262dea
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const iframeURL = new URL("resources/cross-origin-iframe-helper.html", location.href);
+ iframeURL.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe")
+ iframe.src = iframeURL;
+ document.body.append(iframe);
+
+ window.onmessage = t.step_func_done(e => {
+ assert_equals(e.data.navigationType, "push", "navigationType");
+ assert_true(e.data.cancelable, "cancelable");
+ assert_true(e.data.canIntercept, "canIntercept");
+ assert_false(e.data.userInitiated, "userInitiated");
+ assert_true(e.data.hashChange, "hashChange");
+ assert_equals(e.data.formData, null, "formData");
+ assert_equals(e.data.destination.url, iframe.src + "#foo", "destination.url");
+ assert_true(e.data.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.data.destination.key, "", "destination.key");
+ assert_equals(e.data.destination.id, "", "destination.id");
+ assert_equals(e.data.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => iframe.contentWindow.location.href = iframeURL + "#foo");
+}, "using location.href to navigate same-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin.html
new file mode 100644
index 0000000000..6516a60239
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id="i" src="/common/blank.html"></iframe>
+
+<script>
+async_test(t => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, i.src + "#foo", "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => i.contentWindow.location.href = "/common/blank.html#foo");
+}, "using location.href to navigate same-document targeting a same-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..1c411d9866
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.name = "windowname";
+ iframe.src = url;
+ document.body.append(iframe);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, url + "?foo", "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ window.open(url + "?foo", iframe.name);
+ });
+}, "using window.open() to navigate cross-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin.html
new file mode 100644
index 0000000000..73ede89cbf
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-crossorigin.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const iframeURL = new URL("resources/cross-origin-iframe-helper.html", location.href);
+ iframeURL.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe");
+ iframe.src = iframeURL;
+ iframe.name = "windowname";
+ document.body.append(iframe);
+
+ window.onmessage = t.step_func_done(e => {
+ // If we hit onnavigate in the target window, we'll get a different message, and fail.
+ assert_equals(e.data, "DONE");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => window.open(iframeURL + "?postMessage-top-when-done", "windowname"));
+}, "using window.open() to navigate cross-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-sameorigin.html
new file mode 100644
index 0000000000..c91689341e
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-crossdocument-sameorigin.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id="i" name="windowname" src="/common/blank.html"></iframe>
+
+<script>
+async_test(t => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, i.src + "?foo", "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => window.open("/common/blank.html?foo", "windowname"));
+}, "using window.open() to navigate cross-document targeting a same-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..74a6cae246
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.name = "windowname";
+ iframe.src = url;
+ document.body.append(iframe);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, url + "#foo", "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ window.open(url + "#foo", iframe.name);
+ });
+}, "using window.open() to navigate same-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin.html
new file mode 100644
index 0000000000..9b31744ba3
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const iframeURL = new URL("resources/cross-origin-iframe-helper.html", location.href);
+ iframeURL.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe")
+ iframe.src = iframeURL;
+ iframe.name = "windowname";
+ document.body.append(iframe);
+
+ window.onmessage = t.step_func_done(e => {
+ assert_equals(e.data.navigationType, "push", "navigationType");
+ assert_true(e.data.cancelable, "cancelable");
+ assert_true(e.data.canIntercept, "canIntercept");
+ assert_false(e.data.userInitiated, "userInitiated");
+ assert_true(e.data.hashChange, "hashChange");
+ assert_equals(e.data.formData, null, "formData");
+ assert_equals(e.data.destination.url, iframe.src + "#foo", "destination.url");
+ assert_true(e.data.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.data.destination.key, "", "destination.key");
+ assert_equals(e.data.destination.id, "", "destination.id");
+ assert_equals(e.data.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => window.open(iframeURL + "#foo", "windowname"));
+}, "using window.open() to navigate same-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin.html
new file mode 100644
index 0000000000..c357072e09
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id="i" name="windowname" src="/common/blank.html"></iframe>
+
+<script>
+async_test(t => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, i.src + "#foo", "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => window.open("/common/blank.html#foo", "windowname"));
+}, "using window.open() to navigate same-document targeting a same-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/cross-origin-iframe-helper.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/cross-origin-iframe-helper.html
new file mode 100644
index 0000000000..3393a2ecaa
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/cross-origin-iframe-helper.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script>
+navigation.onnavigate = e => {
+ const message = {
+ navigationType: e.navigationType,
+ cancelable: e.cancelable,
+ canIntercept: e.canIntercept,
+ userInitiated: e.userInitiated,
+ hashChange: e.hashChange,
+ formData: e.formData,
+ destination: {
+ url: e.destination.url,
+ sameDocument: e.destination.sameDocument,
+ key: e.destination.key,
+ id: e.destination.id,
+ index: e.destination.index
+ }
+ };
+ e.preventDefault();
+ top.postMessage(message, "*");
+};
+
+window.onload = () => {
+ if (location.href.includes("postMessage-top-when-done")) {
+ top.postMessage("DONE", "*");
+ }
+};
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/document-domain-setter.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/document-domain-setter.sub.html
new file mode 100644
index 0000000000..abe32ad8fb
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/resources/document-domain-setter.sub.html
@@ -0,0 +1,3 @@
+<script>
+document.domain = "{{host}}";
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..ffdaac7ccd
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html?start", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.name = "windowname";
+ iframe.src = url;
+ document.body.append(iframe);
+
+ url.search = ""; // setting to "?" actually erases it anyway
+ const form = document.createElement("form");
+ form.action = url + "?";
+ form.target = iframe.name;
+ document.body.append(form);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, form.action, "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ form.submit();
+ });
+}, "submitting a <form> element that navigates cross-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin.html
new file mode 100644
index 0000000000..007f58b1fb
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const url = new URL("resources/cross-origin-iframe-helper.html", location.href);
+ url.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe")
+ iframe.src = url;
+ iframe.name = "windowname";
+ document.body.append(iframe);
+
+ const form = document.createElement("form");
+ form.action = url;
+ form.target = iframe.name;
+ form.innerHTML = `<input type="hidden" name="postMessage-top-when-done" value="yes">`;
+ document.body.append(form);
+
+ window.onmessage = t.step_func_done(e => {
+ // If we hit onnavigate in the target window, we'll get a different message, and fail.
+ assert_equals(e.data, "DONE");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => form.submit());
+}, "submitting a <form> element that navigates cross-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-sameorigin.html
new file mode 100644
index 0000000000..b54a5a440b
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-crossdocument-sameorigin.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<form id="form" action="/common/blank.html?" target="windowname"></form>
+<iframe id="i" name="windowname" src="/common/blank.html?start"></iframe>
+
+<script>
+async_test(t => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_false(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, form.action, "destination.url");
+ assert_false(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => form.submit());
+}, "submitting a <form> element that navigates cross-document targeting a same-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub.html
new file mode 100644
index 0000000000..e9ab17243e
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+
+<script>
+document.domain = "{{host}}";
+async_test(t => {
+ const url = new URL("resources/document-domain-setter.sub.html?", location.href);
+ url.hostname = "{{domains[www1]}}";
+ const iframe = document.createElement("iframe");
+ iframe.name = "windowname";
+ iframe.src = url;
+ document.body.append(iframe);
+
+ url.hash = "#foo";
+ const form = document.createElement("form");
+ form.action = url;
+ form.target = iframe.name;
+ document.body.append(form);
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => {
+ iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, form.action, "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ form.submit();
+ });
+}, "submitting a <form> element that navigates cross-document targeting a same-origin-domain (but cross-origin) window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin.html
new file mode 100644
index 0000000000..69b12f2795
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin.html
@@ -0,0 +1,39 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+
+<script>
+async_test(t => {
+ const url = new URL("resources/cross-origin-iframe-helper.html?", location.href);
+ url.hostname = get_host_info().REMOTE_HOST;
+ const iframe = document.createElement("iframe")
+ iframe.src = url;
+ iframe.name = "windowname";
+ document.body.append(iframe);
+
+ url.hash = "#foo";
+ const form = document.createElement("form");
+ form.action = url;
+ form.target = iframe.name;
+ document.body.append(form);
+
+ window.onmessage = t.step_func_done(e => {
+ assert_equals(e.data.navigationType, "push", "navigationType");
+ assert_true(e.data.cancelable, "cancelable");
+ assert_true(e.data.canIntercept, "canIntercept");
+ assert_false(e.data.userInitiated, "userInitiated");
+ assert_true(e.data.hashChange, "hashChange");
+ assert_equals(e.data.formData, null, "formData");
+ assert_equals(e.data.destination.url, form.action, "destination.url");
+ assert_true(e.data.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.data.destination.key, "", "destination.key");
+ assert_equals(e.data.destination.id, "", "destination.id");
+ assert_equals(e.data.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => form.submit());
+}, "submitting a <form> element that navigates same-document targeting a cross-origin window");
+</script>
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin.html b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin.html
new file mode 100644
index 0000000000..8a0e1f1fb6
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<form id="form" action="/common/blank.html?#foo" target="windowname"></form>
+<iframe id="i" name="windowname" src="/common/blank.html?"></iframe>
+
+<script>
+async_test(t => {
+ i.contentWindow.navigation.onnavigate = t.step_func_done(e => {
+ assert_equals(e.navigationType, "push", "navigationType");
+ assert_true(e.cancelable, "cancelable");
+ assert_true(e.canIntercept, "canIntercept");
+ assert_false(e.userInitiated, "userInitiated");
+ assert_true(e.hashChange, "hashChange");
+ assert_equals(e.formData, null, "formData");
+ assert_equals(e.destination.url, form.action, "destination.url");
+ assert_true(e.destination.sameDocument, "destination.sameDocument");
+ assert_equals(e.destination.key, "", "destination.key");
+ assert_equals(e.destination.id, "", "destination.id");
+ assert_equals(e.destination.index, -1, "destination.index");
+ });
+
+ navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
+ window.onload = t.step_func(() => form.submit());
+}, "submitting a <form> element that navigates same-document targeting a same-origin window");
+</script>