Bug 1760181 [wpt PR 33182] - App history API to navigation API rename (2/n), a=testonly
[gecko.git] / testing / web-platform / tests / navigation-api / navigate-event / cross-window / click-samedocument-crossorigin-sameorigindomain.sub.html
blobb7d284088081e846cadb65558bc7ed665bf6ce61
1 <!doctype html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <body>
6 <script>
7 document.domain = "{{host}}";
8 async_test(t => {
9 const url = new URL("resources/document-domain-setter.sub.html", location.href);
10 url.hostname = "{{domains[www1]}}";
11 const iframe = document.createElement("iframe");
12 iframe.name = "windowname";
13 iframe.src = url;
14 document.body.append(iframe);
16 url.hash = "#foo";
17 const link = document.createElement("a");
18 link.href = url;
19 link.target = iframe.name;
20 document.body.append(link);
22 navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window");
23 window.onload = t.step_func(() => {
24 iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
25 assert_equals(e.navigationType, "push", "navigationType");
26 assert_true(e.cancelable, "cancelable");
27 assert_true(e.canTransition, "canTransition");
28 assert_false(e.userInitiated, "userInitiated");
29 assert_true(e.hashChange, "hashChange");
30 assert_equals(e.formData, null, "formData");
31 assert_equals(e.destination.url, link.href, "destination.url");
32 assert_true(e.destination.sameDocument, "destination.sameDocument");
33 assert_equals(e.destination.key, null, "destination.key");
34 assert_equals(e.destination.id, null, "destination.id");
35 assert_equals(e.destination.index, -1, "destination.index");
36 });
38 link.click();
39 });
40 }, "clicking on an <a> element that navigates same-document targeting a same-origin-domain (but cross-origin) window");
41 </script>