summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/windows
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/windows')
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-closed.html31
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-multiple.html35
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noopener.html25
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noreferrer.html29
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.html33
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.window.js38
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener.html55
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html30
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/message-window-opener.html14
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/multiple-opener.html32
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/no-opener.html16
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/open-closer.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/opener-setter.html23
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-001.html35
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-002.html21
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-003.html20
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-001.html15
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-002.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-003.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-004.html40
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-001.html15
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-002.html46
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-001.html34
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-002.html33
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-003.html39
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-001.html23
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-002.html16
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-existing-001.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-001-iframe-1.html5
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-iframe.html4
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-window.html12
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-iframe.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-window.html4
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-1.html14
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-2.html9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-001-iframe.html9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-002-iframe.html11
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-002-window.html16
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-1.html15
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-2.html10
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-default-002-iframe.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-existing-001-iframe.html7
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_parent.html9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_top.html9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/post-to-opener.html12
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/post-to-top.html10
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-has-opener.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-is-top.html10
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context-window.html37
-rw-r--r--testing/web-platform/tests/html/browsers/windows/browsing-context.html48
-rw-r--r--testing/web-platform/tests/html/browsers/windows/clear-window-name.https.html122
-rw-r--r--testing/web-platform/tests/html/browsers/windows/document-domain-nested-navigate.window.js16
-rw-r--r--testing/web-platform/tests/html/browsers/windows/document-domain-nested-set.window.js10
-rw-r--r--testing/web-platform/tests/html/browsers/windows/document-domain-nested.window.js9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/document-domain-removed-iframe.html72
-rw-r--r--testing/web-platform/tests/html/browsers/windows/embedded-opener-a-form.html30
-rw-r--r--testing/web-platform/tests/html/browsers/windows/embedded-opener-remove-frame.html66
-rw-r--r--testing/web-platform/tests/html/browsers/windows/embedded-opener.html32
-rw-r--r--testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-print.sub.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-scaled-print.sub.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/iframe-nested-print-ref.html9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/iframe-nested-print.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/iframe-nested-scaled-print-ref.html15
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement-siblings.sub.html42
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html66
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/name-attribute.window.js58
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-nested-frame.html7
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessed.html16
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessor.html33
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-window-post.html14
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-opener.html7
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-parent.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent-null.html66
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent.html44
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top-null.html66
-rw-r--r--testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top.html65
-rw-r--r--testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-close-manual.sub.html3
-rw-r--r--testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-manual.html10
-rw-r--r--testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-window-name-manual.sub.html3
-rw-r--r--testing/web-platform/tests/html/browsers/windows/noreferrer-null-opener.html25
-rw-r--r--testing/web-platform/tests/html/browsers/windows/noreferrer-window-name.html86
-rw-r--r--testing/web-platform/tests/html/browsers/windows/opener-cross-origin-manual.sub.html10
-rw-r--r--testing/web-platform/tests/html/browsers/windows/opener-string.window.js14
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-cross-partition.sub.html26
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-same-partition.html26
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-cross-origin.sub.html27
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-same-origin.sub.html27
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-cross-partition-window.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-same-partition-window.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-iframe.https.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-window.sub.https.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-iframe.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-window.sub.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-iframe.sub.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-window.https.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-iframe.sub.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-window.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-a.sub.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-b.https.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-window.sub.https.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-a.sub.https.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-b.https.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-window.sub.https.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-a.sub.html17
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-b.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-window.sub.html6
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-cross-origin.sub.html29
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-same-origin.sub.html29
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html30
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html30
-rw-r--r--testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html30
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/browsing-context-window.html7
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/document-domain-setter.html7
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/echo-window-name.html1
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-cross-origin.html2
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/iframe-nested-printing-pass.html9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/message-parent.html5
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/nested-post-to-opener.html12
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/noreferrer-window-name.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-embed.sub.html2
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin-end.txt1
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/opener-cross-origin.html4
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/post-to-opener.html8
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/restore-window-name-back.sub.html7
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/restore-window-name.sub.html43
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/target-cross-origin.sub.html3
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/window-close-button.html1
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/window-name-stash.py13
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/window-name.sub.html102
-rw-r--r--testing/web-platform/tests/html/browsers/windows/resources/window-opener.html4
-rw-r--r--testing/web-platform/tests/html/browsers/windows/restore-window-name-manual.https.html20
-rw-r--r--testing/web-platform/tests/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html39
-rw-r--r--testing/web-platform/tests/html/browsers/windows/targeting-multiple-cross-origin-manual.sub.html9
-rw-r--r--testing/web-platform/tests/html/browsers/windows/targeting-with-embedded-null-in-target.html34
134 files changed, 2881 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-closed.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-closed.html
new file mode 100644
index 0000000000..106c3f97cb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-closed.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<meta charset="utf-8">
+<html>
+ <head>
+ <title>Auxiliary Browsing Contexts: window.opener when Opener Removed/Closed</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/PrefixedLocalStorage.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var prefixedLocalStorage;
+ setup (() => prefixedLocalStorage = new PrefixedLocalStorageTest());
+ async_test(t => {
+ t.add_cleanup (() => prefixedLocalStorage.cleanup());
+ var a = document.createElement('a');
+ a.href = prefixedLocalStorage.url('resources/open-closer.html');
+ a.target = '_blank';
+ prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
+ // The window for this auxiliary browsing context's opener
+ // has been closed and discarded, so the aux browsing context
+ // should now report `null` for `window.opener`
+ assert_equals(e.newValue, 'true');
+ }));
+ document.body.append(a);
+ a.click();
+ }, 'An auxiliary browsing context should report `null` for `window.opener` when that browsing context is discarded');
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-multiple.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-multiple.html
new file mode 100644
index 0000000000..e71d4dc868
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-multiple.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Auxiliary Browsing Contexts: window.opener, multiple</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/PrefixedLocalStorage.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var prefixedLocalStorage;
+ setup (() => prefixedLocalStorage = new PrefixedLocalStorageTest());
+ async_test(t => {
+ t.add_cleanup (() => prefixedLocalStorage.cleanup());
+ var a = document.createElement('a');
+ a.href = prefixedLocalStorage.url('resources/multiple-opener.html');
+ a.target = 'multipleOpener';
+ window.name = 'topOpener';
+ document.body.appendChild(a);
+ window.addEventListener('message', t.step_func_done(e => {
+ var aux1 = e.data.aux1; // First opened context
+ var aux2 = e.data.aux2; // Context opened by first-opened context
+ assert_equals(aux1.name, 'multipleOpener');
+ assert_equals(aux1.openerName, window.name);
+ assert_equals(aux1.isTop, true);
+ assert_equals(aux2.name, 'multipleOpenee');
+ assert_equals(aux2.openerName, aux1.name);
+ assert_equals(aux2.isTop, true);
+ }));
+ a.click();
+ }, 'An auxiliary browsing context should be able to open another auxiliary browsing context');
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noopener.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noopener.html
new file mode 100644
index 0000000000..086a96442d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noopener.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Auxiliary Browsing Contexts: window.opener noopener</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/PrefixedLocalStorage.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var prefixedLocalStorage;
+ setup(() => prefixedLocalStorage = new PrefixedLocalStorageTest());
+ async_test(t => {
+ t.add_cleanup(() => prefixedLocalStorage.cleanup());
+ prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
+ assert_equals(e.newValue, 'true');
+ }));
+ window.open(prefixedLocalStorage.url('resources/no-opener.html'),
+ 'iShouldNotHaveAnOpener',
+ 'noopener');
+ }, 'Auxiliary browsing context created via `window.open` setting `noopener` should report `window.opener` `null`');
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noreferrer.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noreferrer.html
new file mode 100644
index 0000000000..b8226bd2b9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-noreferrer.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Auxiliary Browsing Contexts: window.opener noreferrer</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/PrefixedLocalStorage.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var prefixedLocalStorage;
+ setup(() => prefixedLocalStorage = new PrefixedLocalStorageTest());
+ async_test(t => {
+ t.add_cleanup(() => prefixedLocalStorage.cleanup());
+ var a = document.createElement('a');
+ a.href = prefixedLocalStorage.url('resources/no-opener.html');
+ a.target = '_blank';
+ a.rel = 'noreferrer';
+ window.name = 'topWindow';
+ document.body.appendChild(a);
+ prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
+ assert_equals(e.newValue, 'true');
+ }));
+ a.click();
+ }, 'Auxiliary browsing context created with `rel="noreferrer"` should report `window.opener` `null`');
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.html
new file mode 100644
index 0000000000..ac6e47b846
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Auxiliary Browsing Contexts: window.opener setter</title>
+ <meta name=timeout content=long>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/PrefixedLocalStorage.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var prefixedLocalStorage;
+ setup(() => prefixedLocalStorage = new PrefixedLocalStorageTest());
+ async_test(t => {
+ t.add_cleanup(() => prefixedLocalStorage.cleanup());
+ prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
+ assert_equals(e.newValue, 'true');
+ }));
+ window.open(prefixedLocalStorage.url('resources/opener-setter.html'),
+ 'iShouldSetOpenerToNull');
+ }, 'Auxiliary browsing context created via `window.open` and setting `window.opener` to `null` should report `window.opener` `null`');
+ async_test(t => {
+ t.add_cleanup(() => prefixedLocalStorage.cleanup());
+ prefixedLocalStorage.onSet('openerIsTest', t.step_func_done(e => {
+ assert_equals(e.newValue, 'true');
+ }));
+ window.open(prefixedLocalStorage.url('resources/opener-setter.html'),
+ 'iShouldSetOpenerToTest');
+ }, 'Auxiliary browsing context created via `window.open` and setting `window.opener` to `test` should report `test`');
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.window.js b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.window.js
new file mode 100644
index 0000000000..6d540ce97c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-setter.window.js
@@ -0,0 +1,38 @@
+[
+ undefined,
+ 42,
+ function() { return "hi" },
+ "hi",
+ {},
+ [],
+ Symbol()
+].forEach(val => {
+ test(t => {
+ const frame = document.body.appendChild(document.createElement("iframe")),
+ win = frame.contentWindow;
+ t.add_cleanup(() => frame.remove());
+
+ assert_own_property(win, "opener");
+ assert_equals(win.opener, null);
+ const beforeDesc = Object.getOwnPropertyDescriptor(win, "opener"),
+ openerGet = beforeDesc.get,
+ openerSet = beforeDesc.set;
+ assert_own_property(beforeDesc, "get");
+ assert_own_property(beforeDesc, "set");
+ assert_true(beforeDesc.enumerable);
+ assert_true(beforeDesc.configurable);
+
+ win.opener = val;
+ assert_equals(win.opener, val);
+ assert_equals(openerGet(), null);
+
+ const desc = Object.getOwnPropertyDescriptor(win, "opener");
+ assert_equals(desc.value, val);
+ assert_true(desc.writable);
+ assert_true(desc.enumerable);
+ assert_true(desc.configurable);
+
+ openerSet("x");
+ assert_equals(win.opener, "x");
+ }, "Setting window.opener to " + String(val)); // String() needed for symbols
+});
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener.html
new file mode 100644
index 0000000000..c43d3bd3bf
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener.html
@@ -0,0 +1,55 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Auxiliary Browsing Contexts: window.opener</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/PrefixedLocalStorage.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var prefixedLocalStorage;
+ setup (() => {
+ window.name = 'topWindow';
+ prefixedLocalStorage = new PrefixedLocalStorageTest();
+ });
+
+ function cleanup () {
+ prefixedLocalStorage.setItem('closeAll', 'true');
+ prefixedLocalStorage.clear();
+ }
+
+ function testOpener (t, target) {
+ t.add_cleanup(cleanup);
+ window.addEventListener('message', t.step_func(e => {
+ if (e.data.name === target) {
+ // The opener IDL attribute...must return the WindowProxy object of the
+ // browsing context from which the current browsing context was created
+ assert_equals(e.data.openerName, 'topWindow');
+ // Auxiliary browsing contexts are always top-level browsing contexts
+ assert_equals(e.data.isTop, true);
+ t.done();
+ }
+ }));
+ }
+
+ async_test(t => {
+ var target = 'windowOpenerA';
+ var a = document.createElement('a');
+ a.href = prefixedLocalStorage.url('resources/message-window-opener.html');
+ a.target = target;
+ document.body.appendChild(a);
+ testOpener(t, target);
+ a.click();
+ }, 'Newly-created auxiliary browsing context should report `window.opener`');
+
+ async_test(t => {
+ var target = 'windowOpenerB';
+ testOpener(t, target);
+ window.open(prefixedLocalStorage.url('resources/message-window-opener.html'),
+ target);
+ }, 'Browsing context created with `window.open` should report `window.opener`');
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html
new file mode 100644
index 0000000000..f41773ed2c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<meta charset="utf-8">
+<html>
+<body onload="closeOpener()">
+<p>This window should close its opener.</p>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedLocalStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+var prefixedLocalStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+function closeOpener () {
+ if (window.opener) {
+ window.opener.close();
+
+ // Give the browsing context a chance to dispose of itself
+ function waitForContextDiscard () {
+ if (window.opener === null) {
+ return prefixedLocalStorage.setItem('openerIsNull', 'true');
+ }
+ return setTimeout(waitForContextDiscard, 0);
+ }
+ waitForContextDiscard();
+ }
+}
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/message-window-opener.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/message-window-opener.html
new file mode 100644
index 0000000000..8105650b61
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/message-window-opener.html
@@ -0,0 +1,14 @@
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedLocalStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+
+if (window.opener) {
+ window.opener.postMessage ({
+ name : window.name,
+ openerName: window.opener.name,
+ isTop : window.top === window
+ }, '*');
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/multiple-opener.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/multiple-opener.html
new file mode 100644
index 0000000000..2e63b9f4c6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/multiple-opener.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<body onload="openNested()">
+<script>
+var prefixedLocalStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+function openNested () {
+ // Listen for message from opened context and pass through to this
+ // context's opener
+ window.addEventListener('message', (e) => {
+ if (window.opener) {
+ window.opener.postMessage({
+ aux2: e.data, // From multipleOpenee
+ aux1: { // This context
+ name : window.name,
+ openerName : window.opener.name,
+ isTop : window.top === window
+ }
+ }, '*');
+ }
+ });
+ var a = document.createElement('a');
+ a.target = 'multipleOpenee';
+ a.href = prefixedLocalStorage.url('message-window-opener.html');
+ document.body.appendChild(a);
+ a.click();
+}
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/no-opener.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/no-opener.html
new file mode 100644
index 0000000000..afd72f948d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/no-opener.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset="utf-8">
+<html>
+<p>This window should have no opener.</p>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedLocalStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+function checkOpener () {
+ return prefixedLocalStorage.setItem('openerIsNull', window.opener === null);
+}
+</script>
+<body onload="checkOpener()">
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/open-closer.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/open-closer.html
new file mode 100644
index 0000000000..7575c7c95f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/open-closer.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset="utf-8">
+<html>
+<body onload="openAuxiliary()">
+<a rel="opener" target="_blank">Open auxiliary context that will close this window (its opener)</a>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+function openAuxiliary () {
+ var prefixedLocalStorage = new PrefixedLocalStorageResource();
+ var a = document.body.querySelector('a');
+ a.href = prefixedLocalStorage.url('close-opener.html');
+ document.body.append(a);
+ a.click();
+}
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/opener-setter.html b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/opener-setter.html
new file mode 100644
index 0000000000..4112dae0ce
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/opener-setter.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<meta charset="utf-8">
+<html>
+<p>This window should set the window.opener attribute</p>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedLocalStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+function checkOpener () {
+ if (window.name == 'iShouldSetOpenerToNull') {
+ window.opener = null;
+ return prefixedLocalStorage.setItem('openerIsNull', window.opener === null);
+ }
+ if (window.name == 'iShouldSetOpenerToTest') {
+ window.opener = 'test';
+ return prefixedLocalStorage.setItem('openerIsTest', window.opener === "test");
+ }
+}
+</script>
+<body onload="checkOpener()">
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-001.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-001.html
new file mode 100644
index 0000000000..a1416f2eb8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-001.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Browsing context - `_blank` name keyword</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(t => {
+ var window1 = window.open('about:blank', '_blank');
+ var window2 = window.open('about:blank', '_blank');
+ var window3 = window.open('about:blank', '_blank');
+ t.add_cleanup(() => {
+ window1.close();
+ window2.close();
+ window3.close();
+ });
+ assert_not_equals(window1, window2);
+ assert_not_equals(window2, window3);
+ assert_not_equals(window1, window3);
+}, 'window.open into `_blank` should create a new browsing context each time');
+
+test(t => {
+ var window1 = window.open('about:blank', '_bLAnk');
+ var window2 = window.open('about:blank', '_bLAnk');
+ var window3 = window.open('about:blank', '_bLAnk');
+ t.add_cleanup(() => {
+ window1.close();
+ window2.close();
+ window3.close();
+ });
+ assert_not_equals(window1, window2);
+ assert_not_equals(window2, window3);
+ assert_not_equals(window1, window3);
+}, '`_blank` should be ASCII case-insensitive');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-002.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-002.html
new file mode 100644
index 0000000000..aba9d52ba0
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-002.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>Link with target=_blank, rel=noreferrer</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<div id="log"></div>
+<a href="resources/report-has-opener.html" rel="noreferrer" target="_blank">Link</a>
+<script>
+var prefixedStorage;
+setup (() => prefixedStorage = new PrefixedLocalStorageTest());
+
+async_test(t => {
+ t.add_cleanup(() => prefixedStorage.cleanup());
+ var a = document.getElementsByTagName('a')[0];
+ a.href = prefixedStorage.url(a.href);
+ prefixedStorage.onSet('hasOpener', t.step_func_done(e => {
+ assert_equals(e.newValue, 'false');
+ }));
+ a.click();
+}, 'Context for opened noreferrer link targeted to "_blank" should not have opener reference');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-003.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-003.html
new file mode 100644
index 0000000000..5571344c85
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-003.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>Link with target=_blank, no rel</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<div id="log"></div>
+<a href="resources/report-has-opener.html" target="_blank">Link</a>
+<script>
+var prefixedStorage;
+setup(() => prefixedStorage = new PrefixedLocalStorageTest());
+async_test(t => {
+ t.add_cleanup(() => prefixedStorage.cleanup());
+ prefixedStorage.onSet('hasOpener', t.step_func_done(e => {
+ assert_equals(e.newValue, 'false');
+ }));
+ var a = document.getElementsByTagName('a')[0];
+ a.href = prefixedStorage.url(a.href);
+ a.click();
+}, 'Context created by link targeting "_blank" should not have opener reference');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-001.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-001.html
new file mode 100644
index 0000000000..35cbc101c7
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-001.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - '_parent'</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ window.addEventListener('message', t.step_func_done(e => {
+ assert_equals(e.data.name, 'parentWin');
+ }));
+}, 'The parent browsing context must be chosen if the given name is `_parent`');
+</script>
+<iframe id="embedded" src="resources/choose-_parent-001-iframe-1.html" name="parentWin" style="display:none"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-002.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-002.html
new file mode 100644
index 0000000000..7b7d561030
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-002.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - '_parent' (nested contexts)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ var topWindow;
+ t.add_cleanup(() => topWindow.close());
+ window.addEventListener('message', t.step_func_done(e => {
+ assert_equals(e.data.name, 'iframeParent');
+ assert_false(e.data.isTop, 'window.parent is not top');
+ }));
+ topWindow = window.open('resources/choose-_parent-002-window.html', '_blank');
+}, 'choosing _parent context: multiple nested contexts');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-003.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-003.html
new file mode 100644
index 0000000000..20dc9b0d2a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-003.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - '_parent' (via window.open)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ var topWindow;
+ t.add_cleanup(() => topWindow.close());
+ window.addEventListener('message', t.step_func_done(e => {
+ assert_equals(e.data.name, 'parentTopReplace');
+ assert_equals(e.data.isTop, true);
+ }));
+ topWindow = window.open('resources/choose-_parent-003-window.html', 'parentTopReplace');
+}, '_parent should reuse window.parent context');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-004.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-004.html
new file mode 100644
index 0000000000..c79378018a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_parent-004.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - '_parent' (case-sensitivity)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<body>
+<div id="log"></div>
+
+<script>
+var prefixedStorage;
+var iframe;
+setup(() => prefixedStorage = new PrefixedLocalStorageTest());
+
+async_test(t => {
+ t.add_cleanup(() => prefixedStorage.cleanup());
+ var testFunc = (function (t) {
+ var completed = 0;
+ var testCount = 2;
+ return function (actual, expected) {
+ assert_equals(actual, expected);
+ if (++completed >= testCount) {
+ t.done();
+ }
+ }
+ }(t));
+
+ prefixedStorage.onSet('isTop', t.step_func(e => {
+ testFunc(e.newValue, 'false');
+ }));
+ prefixedStorage.onSet('name', t.step_func(e => {
+ testFunc(e.newValue, 'parentWin');
+ }));
+ iframe = document.createElement('iframe');
+ iframe.src = prefixedStorage.url('resources/choose-_parent-004-iframe-1.html');
+ iframe.name = 'parentWin';
+ document.body.appendChild(iframe);
+}, 'choosing _parent context should be case-insensitive');
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-001.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-001.html
new file mode 100644
index 0000000000..ed7666846d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-001.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - the given name is '_self'</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="resources/choose-_self-001-iframe.html" style="display:none"></iframe>
+<script>
+async_test(t => {
+ window.addEventListener('message', t.step_func_done(e => {
+ assert_equals(e.data.name, 'myownself');
+ }), false);
+}, 'The current browsing context must be chosen if the given name is "_self"');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-002.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-002.html
new file mode 100644
index 0000000000..2e798f5493
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_self-002.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - '_self' (case-sensitivity)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<body>
+<div id="log"></div>
+
+<script>
+var prefixedStorage;
+setup(() => prefixedStorage = new PrefixedLocalStorageTest());
+
+async_test(t => {
+ var iframe;
+
+ var testFunc = (function (t) {
+ var completed = 0;
+ var testCount = 2;
+ return function (actual, expected) {
+ assert_equals(actual, expected);
+ if (++completed >= testCount) {
+ t.done();
+ }
+ }
+ }(t));
+
+ t.add_cleanup(() => prefixedStorage.cleanup());
+
+ prefixedStorage.onSet('isTop', t.step_func(e => {
+ testFunc(e.newValue, 'false');
+ }));
+ prefixedStorage.onSet('name', t.step_func(e => {
+ testFunc(e.newValue, 'testWin');
+ }));
+
+ iframe = document.createElement('iframe');
+ iframe.name = 'testWin';
+ iframe.src = prefixedStorage.url('resources/choose-_self-002-iframe.html');
+ document.body.appendChild(iframe);
+
+}, 'choosing _self context should be case-insensitive');
+
+</script>
+
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-001.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-001.html
new file mode 100644
index 0000000000..de4c6ad115
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-001.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<title>HTML Test: Browsing context name - _top (current is top)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<div id="log"></div>
+<script>
+var prefixedStorage;
+setup (() => prefixedStorage = new PrefixedLocalStorageTest());
+
+async_test(t => {
+ t.add_cleanup(() => prefixedStorage.cleanup());
+
+ var testFunc = (function (t) {
+ var completed = 0;
+ var testCount = 2;
+ return function (actual, expected) {
+ assert_equals(actual, expected);
+ if (++completed >= testCount) {
+ t.done();
+ }
+ }
+ }(t));
+
+ prefixedStorage.onSet('isTop', t.step_func(e => {
+ testFunc(e.newValue, 'true');
+ }));
+ prefixedStorage.onSet('name', t.step_func(e => {
+ testFunc(e.newValue, 'topWin1');
+ }));
+
+ window.open(prefixedStorage.url('resources/open-in-_top.html'), '_blank');
+}, 'Should choose current browsing context for "_top" if current is top');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-002.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-002.html
new file mode 100644
index 0000000000..f29da80c6e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-002.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<title>HTML Test: Browsing context name - _top</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<div id="log"></div>
+<script>
+var prefixedStorage;
+setup (() => prefixedStorage = new PrefixedLocalStorageTest());
+
+async_test(t => {
+ t.add_cleanup(() => prefixedStorage.cleanup());
+
+ var testFunc = (function (t) {
+ var completed = 0;
+ var testCount = 2;
+ return function (actual, expected) {
+ assert_equals(actual, expected);
+ if (++completed >= testCount) {
+ t.done();
+ }
+ }
+ }(t));
+
+ prefixedStorage.onSet('isTop', t.step_func(e => {
+ testFunc(e.newValue, 'true');
+ }));
+ prefixedStorage.onSet('name', t.step_func(e => {
+ testFunc(e.newValue, 'topWin2');
+ }));
+ window.open(prefixedStorage.url('resources/choose-_top-002-window.html'), '_blank');
+}, 'Should choose top browsing context for "_top" if current is not top');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-003.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-003.html
new file mode 100644
index 0000000000..e068f8cc1f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_top-003.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - '_top' (case-sensitivity)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<body>
+<div id="log"></div>
+
+<script>
+var prefixedStorage;
+setup(() => prefixedStorage = new PrefixedLocalStorageTest());
+
+async_test(t => {
+ var testFunc = (function (t) {
+ var completed = 0;
+ var testCount = 2;
+ return function (actual, expected) {
+ assert_equals(actual, expected);
+ if (++completed >= testCount) {
+ t.done();
+ }
+ }
+ }(t));
+
+ t.add_cleanup(() => prefixedStorage.cleanup());
+
+ prefixedStorage.onSet('isTop', t.step_func(e => {
+ testFunc(e.newValue, 'true');
+ }));
+ prefixedStorage.onSet('name', t.step_func(e => {
+ testFunc(e.newValue, 'topWin');
+ }));
+
+ window.open(prefixedStorage.url('resources/choose-_top-003-iframe-1.html'), '_blank');
+}, 'choosing _top context should be case-insensitive');
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-001.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-001.html
new file mode 100644
index 0000000000..c21159e0a6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-001.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Browsing context - Default name</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="/common/blank.html" style="display:none"></iframe>
+<object id="obj" type="text/html" data="about:blank"></object>
+<embed id="embedded" type="image/svg+xml" src="/images/green.svg" width="0" height="0" />
+<script>
+test(t => {
+ assert_equals(window.frames[0].name, "");
+ assert_equals(document.getElementById("embedded").name, "");
+ assert_equals(window["obj"].name, "");
+}, "A embedded browsing context has empty-string default name");
+
+test(t => {
+ var win = window.open("about:blank", "_blank");
+ assert_equals(win.name, "");
+ win.close();
+}, "A browsing context which is opened by window.open() method with '_blank' parameter has empty-string default name");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-002.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-002.html
new file mode 100644
index 0000000000..748ee68973
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-default-002.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Browsing context names - empty string</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ window.addEventListener('message', t.step_func_done(e => {
+ assert_equals(e.data.isTop, false);
+ assert_equals(e.data.name, 'hellothere', 'Empty-string browsing context should choose current context');
+ }), false);
+}, 'The current browsing context must be chosen if the given name is empty string');
+</script>
+<iframe name="hellothere" src="resources/choose-default-002-iframe.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-existing-001.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-existing-001.html
new file mode 100644
index 0000000000..fdf74b8a79
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-existing-001.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Choose browsing context - the given name is same as an existing browsing context's name</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="resources/choose-existing-001-iframe.html" style="display:none"></iframe>
+<iframe name="iExist" style="display:none"></iframe>
+<script>
+async_test(t => {
+ window.addEventListener('message', t.step_func_done(e => {
+ assert_equals(e.data.name, 'iExist');
+ }), false);
+
+}, 'An existing browsing context must be chosen if the given name is the same as its name');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-001-iframe-1.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-001-iframe-1.html
new file mode 100644
index 0000000000..04dd74f1a5
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-001-iframe-1.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<iframe src="open-in-_parent.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-iframe.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-iframe.html
new file mode 100644
index 0000000000..52da8986b0
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-iframe.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent: nested context</title>
+<iframe name="iframeChild" src="open-in-_parent.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-window.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-window.html
new file mode 100644
index 0000000000..558193742f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-002-window.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent: top-level context</title>
+<iframe name="iframeParent" src="choose-_parent-002-iframe.html"></iframe>
+<script>
+// Relay a message from child context to opener context
+window.addEventListener('message', e => {
+ if (window.opener) {
+ window.opener.postMessage(e.data, '*');
+ }
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-iframe.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-iframe.html
new file mode 100644
index 0000000000..1412dc2e79
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-iframe.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent</title>
+<script>
+window.open("post-to-opener.html", "_parent");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-window.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-window.html
new file mode 100644
index 0000000000..bd1802aed6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-window.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent: top-level context (gets replaced)</title>
+<iframe name="iframeOpener" src="choose-_parent-003-iframe.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-1.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-1.html
new file mode 100644
index 0000000000..7a8cbecb27
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-1.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent</title>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<body>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+var iframe = document.createElement('iframe');
+iframe.src = prefixedStorage.url('choose-_parent-004-iframe-2.html');
+document.body.appendChild(iframe);
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-2.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-2.html
new file mode 100644
index 0000000000..33ead5a538
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-004-iframe-2.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent (case-insensitive)</title>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource();
+window.open(prefixedStorage.url('report-is-top.html'), '_pARent');
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-001-iframe.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-001-iframe.html
new file mode 100644
index 0000000000..0ad79d6e16
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-001-iframe.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - self</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script>
+window.name = 'myownself';
+var win = window.open('post-to-top.html', '_self');
+win.close();
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-002-iframe.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-002-iframe.html
new file mode 100644
index 0000000000..9d88305e09
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_self-002-iframe.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - self (case-insensitive)</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+var win = window.open(prefixedStorage.url('report-is-top.html'), '_sElF');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-002-window.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-002-window.html
new file mode 100644
index 0000000000..d71384b72f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-002-window.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/common/PrefixedLocalStorage.js"></script>
+<title>HTML Test: browsing context name - _top</title>
+<body>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup:true
+});
+window.name = 'topWin2';
+var iframe = document.createElement('iframe');
+iframe.src = prefixedStorage.url('open-in-_top.html');
+// Append iframe that will open another document into `_top` (this context)
+document.body.appendChild(iframe);
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-1.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-1.html
new file mode 100644
index 0000000000..aecc2fd88a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - top (case-insensitive)</title>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<body>
+</body>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+window.name = 'topWin';
+var iframe = document.createElement('iframe');
+iframe.src = prefixedStorage.url('choose-_top-003-iframe-2.html');
+document.body.appendChild(iframe);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-2.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-2.html
new file mode 100644
index 0000000000..a1a7e1dda7
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_top-003-iframe-2.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - top (case-insensitive)</title>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+window.open(prefixedStorage.url("report-is-top.html"), "_ToP");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-default-002-iframe.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-default-002-iframe.html
new file mode 100644
index 0000000000..567e4ea310
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-default-002-iframe.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - Empty string</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<body onload="followLink()">
+</body>
+<script>
+function followLink() {
+ var a = document.createElement('a');
+ a.href = 'post-to-top.html';
+ a.target = ''; // Target is empty string
+ document.body.appendChild(a);
+ a.click();
+}
+</script>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-existing-001-iframe.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-existing-001-iframe.html
new file mode 100644
index 0000000000..cb0b554854
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-existing-001-iframe.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>This is a test page</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script>
+window.open("post-to-top.html", "iExist");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_parent.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_parent.html
new file mode 100644
index 0000000000..81d0735c60
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_parent.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: browsing context name - parent</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script>
+
+window.open("post-to-top.html", "_parent");
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_top.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_top.html
new file mode 100644
index 0000000000..929d52d15e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_top.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/common/PrefixedLocalStorage.js"></script>
+<title>HTML Test: browsing context name - _top</title>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource();
+window.name = 'topWin1';
+window.open(prefixedStorage.url('report-is-top.html'), '_top');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/post-to-opener.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/post-to-opener.html
new file mode 100644
index 0000000000..3e9b7aaccb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/post-to-opener.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: post window's name to top browsing context</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<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/browsing-context-names/resources/post-to-top.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/post-to-top.html
new file mode 100644
index 0000000000..aebb57b019
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/post-to-top.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: post window's name to top browsing context</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script>
+top.postMessage({
+ name: window.name,
+ isTop: (window.top === window)
+}, "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-has-opener.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-has-opener.html
new file mode 100644
index 0000000000..37d8cedc6d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-has-opener.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+prefixedStorage.setItem('hasOpener', window.opener !== null);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-is-top.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-is-top.html
new file mode 100644
index 0000000000..8711235982
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/report-is-top.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<meta charset="utf-8">
+<script src="/common/PrefixedLocalStorage.js"></script>
+<script>
+var prefixedStorage = new PrefixedLocalStorageResource({
+ close_on_cleanup: true
+});
+prefixedStorage.setItem('isTop', window === window.top);
+prefixedStorage.setItem('name', window.name);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context-window.html b/testing/web-platform/tests/html/browsers/windows/browsing-context-window.html
new file mode 100644
index 0000000000..f4f3c715ac
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context-window.html
@@ -0,0 +1,37 @@
+<!doctype html>
+<html>
+ <head>
+ <title>HTML Test: Newly-Created browsing context Window and `this`</title>
+ <link rel="author" title="Intel" href="http://www.intel.com/" />
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/get-host-info.sub.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+
+ /**
+ * Test for creating a new browsing context, [Browsing Contexts](#windows).
+ * This test is separate from the rest of the browsing-content-creation tests
+ * because the `iframe` has a src and thus its document won't be `about:blank`.
+ */
+ var doc, iframe;
+
+ setup(function () {
+ iframe = document.createElement("iframe");
+ iframe.src = get_host_info().HTTP_REMOTE_ORIGIN + "/html/browsers/windows/resources/browsing-context-window.html";
+ document.body.appendChild(iframe);
+ doc = iframe.contentDocument;
+ });
+
+ async_test(function (t) {
+ window.onmessage = t.step_func(function (e) {
+ assert_equals(e.data.thisWindowEquivalency, true, "The global `this` for the created browsing context should be a reference to Window through WindowProxy");
+ t.done();
+ });
+ });
+
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/browsing-context.html b/testing/web-platform/tests/html/browsers/windows/browsing-context.html
new file mode 100644
index 0000000000..59367b0428
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/browsing-context.html
@@ -0,0 +1,48 @@
+<!doctype html>
+<html>
+ <head>
+ <title>HTML Test: Browsing context is first created</title>
+ <link rel="author" title="Intel" href="http://www.intel.com/" />
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var doc, iframe;
+
+ setup(function () {
+ // Create new browsing context via iframe
+ iframe = document.createElement("iframe");
+ document.body.appendChild(iframe);
+ doc = iframe.contentDocument;
+ });
+
+ test(function () {
+ assert_equals(doc.compatMode, "BackCompat", "The compatMode of a document without a document type declaration should be 'BackCompat'."); // Quirksmode
+ assert_equals(doc.contentType, "text/html", "The document should be an HTML document.");
+ assert_equals(doc.readyState, "complete", "The readyState attribute should be 'complete'.");
+ // Document metadata...
+ assert_equals(doc.documentURI, "about:blank", "The document's address should be 'about:blank'.");
+ assert_equals(doc.URL, "about:blank", "The document's address should be 'about:blank'.");
+ assert_equals(doc.doctype, null, "The docType of a document without a document type declaration should be null.");
+ assert_equals(doc.characterSet, "UTF-8", "The document's encoding should be 'UTF-8'.");
+ }, "Check that browsing context has new, ready HTML document");
+
+ test(function () {
+ assert_equals(doc.childNodes.length, 1, "The document must have only one child.");
+ assert_equals(doc.documentElement.tagName, "HTML");
+ assert_equals(doc.documentElement.childNodes.length, 2, "The HTML element should have 2 children.");
+ assert_equals(doc.documentElement.childNodes[0].tagName, "HEAD", "The first child of HTML element should be a HEAD element.");
+ assert_false(doc.documentElement.childNodes[0].hasChildNodes(), "The HEAD element should not have children.");
+ assert_equals(doc.documentElement.childNodes[1].tagName, "BODY", "The second child of HTML element should be a BODY element.");
+ assert_false(doc.documentElement.childNodes[1].hasChildNodes(), "The BODY element should not have children.");
+ }, "Check that new document nodes extant, empty");
+
+ test(function () {
+ assert_equals(doc.referrer, document.URL, "The document's referrer should be its creator document's URL.");
+ assert_equals(iframe.contentWindow.parent.document, document);
+ }, "Check the document properties corresponding to the creator browsing context");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/clear-window-name.https.html b/testing/web-platform/tests/html/browsers/windows/clear-window-name.https.html
new file mode 100644
index 0000000000..698de8a1ca
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/clear-window-name.https.html
@@ -0,0 +1,122 @@
+<!doctype html>
+<html>
+<head>
+ <title>Clear window.name when cross-origin</title>
+ <meta name="timeout" content="long">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/utils.js"></script>
+</head>
+<body>
+ <script>
+
+function anchorClick(n) {
+ const hyperlink = document.body.appendChild(document.createElement("a"))
+ hyperlink.rel = "noopener";
+ hyperlink.target = "_blank";
+ hyperlink.href = n;
+ hyperlink.click();
+}
+
+async function pollResultAndCheck(t, id, expected) {
+ const stashURL = new URL("resources/window-name-stash.py", location);
+ stashURL.searchParams.set('id', id);
+
+ let res = "NONE";
+ while (res == "NONE") {
+ await new Promise(resolve => { t.step_timeout(resolve, 100); });
+
+ const response = await fetch(stashURL);
+ res = await response.text();
+ }
+ if (res !== expected) {
+ assert_unreached('Stash result does not equal expected result.')
+ }
+}
+
+promise_test(async t => {
+ const id = token();
+
+ window.open(`resources/window-name.sub.html?report=${id}|close`, id);
+ await pollResultAndCheck(t, id, id);
+}, "Window.name is not reset when there is an opener around");
+
+promise_test(async t => {
+ const id = token();
+
+ window.open(`resources/window-name.sub.html?cross|same|report=${id}|close`, id);
+ await pollResultAndCheck(t, id, id);
+}, "Window.name is not reset when there is an opener around (cross-origin)");
+
+promise_test(async t => {
+ const id = token();
+
+ window.open(`resources/window-name.sub.html?report=${id}|close`, id, "noopener");
+ await pollResultAndCheck(t, id, id);
+}, "Window.name is not reset at the first navigation away from initial about:blank with noopener");
+
+promise_test(async t => {
+ const id = token();
+
+ window.open(`resources/window-name.sub.html?cross|same|report=${id}|close`, id, "noopener");
+ await pollResultAndCheck(t, id, "");
+}, "Window.name is reset at the first cross-origin navigation with noopener");
+
+promise_test(async t => {
+ const id = token();
+
+ let win = window.open(`resources/window-name.sub.html?report=${id}|close`, id);
+ win.opener = null;
+ await pollResultAndCheck(t, id, id);
+}, "Window.name is not reset at the first navigation away from initial about:blank with window.opener set to null");
+
+promise_test(async t => {
+ const id = token();
+
+ let win = window.open(`resources/window-name.sub.html?same|report=${id}|close`, id);
+ win.opener = null;
+ await pollResultAndCheck(t, id, id);
+}, "Window.name is not reset at the same-origin navigation with window.opener set to null");
+
+promise_test(async t => {
+ const id = token();
+
+ let win = window.open(`resources/window-name.sub.html?cross|same|report=${id}|close`, id);
+ win.opener = null;
+ await pollResultAndCheck(t, id, "");
+}, "Window.name is reset at the first first cross-origin navigation with window.opener set to null");
+
+promise_test(async t => {
+ const id = token();
+
+ anchorClick(`resources/window-name.sub.html?set=${id}|report=${id}|close`);
+ await pollResultAndCheck(t, id, id);
+}, "Window.name is set by the window");
+
+promise_test(async t => {
+ const id = token();
+
+ anchorClick(`resources/window-name.sub.html?set=${id}|cross|same|report=${id}|close`);
+ await pollResultAndCheck(t, id, "");
+}, "Window.name is reset at the first cross-origin navigation");
+
+promise_test(async t => {
+ const id = token();
+
+ window.open(`resources/window-name.sub.html?open|navOpener=about:blank|reportOpener=${id}|closeOpener|close`, id, "noopener");
+ await pollResultAndCheck(t, id, id);
+}, "window.name is not reset after navigating to an about:blank page from a non-about:blank page");
+
+
+promise_test(async t => {
+ const id = token();
+ const domain = window.location.host;
+
+ anchorClick(`resources/window-name.sub.html?sub|set=${id}|setDomain=${domain}|sub|report=${id}|close`);
+ await pollResultAndCheck(t, id, id);
+}, "Window.name is not reset if the document.domain is set to the parent domain");
+
+
+ </script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/document-domain-nested-navigate.window.js b/testing/web-platform/tests/html/browsers/windows/document-domain-nested-navigate.window.js
new file mode 100644
index 0000000000..f51eed5ca9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/document-domain-nested-navigate.window.js
@@ -0,0 +1,16 @@
+async_test(t => {
+ // Setting document.domain makes this document cross-origin with that of the frame. However,
+ // about:blank will end up reusing the origin of this document, at which point the frame's
+ // document is no longer cross-origin.
+ const frame = document.body.appendChild(document.createElement('iframe'));
+ document.domain = document.domain;
+ frame.src = "/common/blank.html";
+ frame.onload = t.step_func(() => {
+ assert_throws_dom("SecurityError", () => window[0].document);
+ frame.src = "about:blank";
+ frame.onload = t.step_func_done(() => {
+ // Ensure we can access the child browsing context after navigation to non-initial about:blank
+ assert_equals(window[0].document, frame.contentDocument);
+ });
+ });
+}, "Navigated frame to about:blank and document.domain");
diff --git a/testing/web-platform/tests/html/browsers/windows/document-domain-nested-set.window.js b/testing/web-platform/tests/html/browsers/windows/document-domain-nested-set.window.js
new file mode 100644
index 0000000000..13c0d50ba0
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/document-domain-nested-set.window.js
@@ -0,0 +1,10 @@
+test(() => {
+ // As the initial:about frame document reuses the origin of this document, setting document.domain
+ // from the frame, resulting in a origin mutation, has no effect on these documents being able to
+ // reach each other, as they share the same "physical" origin.
+ document.body.appendChild(document.createElement('iframe'));
+ const script = document.createElement("script");
+ script.text = "document.domain = document.domain";
+ window[0].document.body.appendChild(script);
+ assert_equals(window[0].document.body.localName, "body");
+}, "Initial about:blank frame and document.domain in the frame");
diff --git a/testing/web-platform/tests/html/browsers/windows/document-domain-nested.window.js b/testing/web-platform/tests/html/browsers/windows/document-domain-nested.window.js
new file mode 100644
index 0000000000..2e39d05f03
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/document-domain-nested.window.js
@@ -0,0 +1,9 @@
+test(() => {
+ // As the initial:about frame document reuses the origin of this document, setting document.domain
+ // from this document, resulting in a origin mutation, has no effect on these documents being able
+ // to reach each other, as they share the same "physical" origin.
+ document.body.appendChild(document.createElement('iframe'));
+ document.domain = document.domain;
+ // Ensure we can still access the child browsing context
+ assert_equals(window[0].document.body.localName, "body");
+}, "Initial about:blank frame and document.domain");
diff --git a/testing/web-platform/tests/html/browsers/windows/document-domain-removed-iframe.html b/testing/web-platform/tests/html/browsers/windows/document-domain-removed-iframe.html
new file mode 100644
index 0000000000..7403ebfaad
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/document-domain-removed-iframe.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>document.domain and removed iframe interaction</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<!-- This is a test for https://crbug.com/1095145 where window
+ properties become undefined for document.domain-using removed
+ iframes -->
+
+<div id="log"></div>
+
+<script>
+"use strict";
+
+promise_test(t => {
+ return new Promise(resolve => {
+ const iframe = document.createElement("iframe");
+ iframe.onload = t.step_func(() => {
+ const { contentWindow } = iframe;
+ assert_equals(contentWindow.status, "");
+ resolve();
+ });
+ iframe.src = "/common/blank.html";
+ document.body.append(iframe);
+ });
+}, "No removal, no document.domain");
+
+promise_test(t => {
+ return new Promise(resolve => {
+ const iframe = document.createElement("iframe");
+ iframe.onload = t.step_func(() => {
+ const { contentWindow } = iframe;
+ iframe.remove();
+ assert_equals(contentWindow.status, "");
+ resolve();
+ });
+ iframe.src = "/common/blank.html";
+ document.body.append(iframe);
+ });
+}, "Removal, no document.domain");
+
+promise_test(t => {
+ return new Promise(resolve => {
+ const iframe = document.createElement("iframe");
+ iframe.onload = t.step_func(() => {
+ document.domain = document.domain;
+ const { contentWindow } = iframe;
+ assert_equals(contentWindow.status, "");
+ resolve();
+ });
+ iframe.src = "resources/document-domain-setter.html";
+ document.body.append(iframe);
+ });
+}, "No removal, document.domain");
+
+promise_test(t => {
+ return new Promise(resolve => {
+ const iframe = document.createElement("iframe");
+ iframe.onload = t.step_func(() => {
+ document.domain = document.domain; // technically we already did this above
+ const { contentWindow } = iframe;
+ iframe.remove();
+ assert_equals(contentWindow.status, "");
+ resolve();
+ });
+ iframe.src = "resources/document-domain-setter.html";
+ document.body.append(iframe);
+ });
+}, "Removal, document.domain");
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/embedded-opener-a-form.html b/testing/web-platform/tests/html/browsers/windows/embedded-opener-a-form.html
new file mode 100644
index 0000000000..e1ec760b92
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/embedded-opener-a-form.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<title>opener and embedded documents; using a and form</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<iframe name=matchesastring></iframe>
+<a href=/common/blank.html target=matchesastring>&lt;a></a>
+<form action=/common/blank.html target=matchesastring><input type=submit value="<form>"></form>
+<script>
+async_test(t => {
+ const frame = document.querySelector("iframe");
+ let counter = 0;
+ frame.onload = t.step_func(() => {
+ // Firefox and Chrome/Safari load differently
+ if (frame.contentWindow.location.href === "about:blank") {
+ return;
+ }
+
+ // Test bits
+ assert_equals(frame.contentWindow.opener, null);
+ if (counter === 0) {
+ document.querySelector("input").click();
+ } else {
+ t.done();
+ }
+ counter++;
+ });
+ document.querySelector("a").click();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/embedded-opener-remove-frame.html b/testing/web-platform/tests/html/browsers/windows/embedded-opener-remove-frame.html
new file mode 100644
index 0000000000..a66f52e5f6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/embedded-opener-remove-frame.html
@@ -0,0 +1,66 @@
+<!doctype html>
+<title>opener and discarded browsing contexts</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<iframe name=matchesastring></iframe>
+<script>
+function testOpener(t, otherW, thisW, discardOtherBC, isDiscardedFromATask) {
+ assert_equals(otherW.opener, thisW, "opener before removal");
+
+ const openerDesc = Object.getOwnPropertyDescriptor(otherW, "opener"),
+ openerGet = openerDesc.get;
+
+ assert_equals(openerGet(), thisW, "opener before removal via directly invoking the getter");
+ discardOtherBC();
+ if (isDiscardedFromATask) {
+ t.step_timeout(() => {
+ testOpenerRemainder(t, otherW, openerDesc, openerGet);
+ }, 250);
+ } else {
+ testOpenerRemainder(t, otherW, openerDesc, openerGet);
+ }
+}
+
+function testOpenerRemainder(t, otherW, openerDesc, openerGet) {
+ assert_equals(otherW.opener, null, "opener after removal");
+ assert_equals(openerGet(), null, "opener after removal via directly invoking the getter");
+
+ otherW.opener = null;
+ assert_equals(openerGet(), null, "opener after setting it null via directly invoking the getter");
+ const openerDescNull = Object.getOwnPropertyDescriptor(otherW, "opener");
+ assert_not_equals(openerDescNull, openerDesc);
+ assert_object_equals(openerDescNull, openerDesc);
+
+ otherW.opener = "immaterial";
+ assert_equals(openerGet(), null, "opener after setting it \"immaterial\" via directly invoking the getter");
+ const openerDescImmaterial = Object.getOwnPropertyDescriptor(otherW, "opener");
+ assert_equals(openerDescImmaterial.value, "immaterial");
+ assert_true(openerDescImmaterial.writable);
+ assert_true(openerDescImmaterial.enumerable);
+ assert_true(openerDescImmaterial.configurable);
+
+ t.done();
+}
+
+async_test(t => {
+ const frame = document.querySelector("iframe"),
+ frameW = frame.contentWindow;
+ frame.onload = t.step_func(() => {
+ // Firefox and Chrome/Safari load differently
+ if (frame.contentWindow.location.href === "about:blank") {
+ return;
+ }
+
+ testOpener(t, frameW, window, () => frame.remove(), false);
+ });
+ window.open("/common/blank.html", "matchesastring");
+}, "opener of discarded nested browsing context");
+
+async_test(t => {
+ const popupW = window.open("/common/blank.html");
+ popupW.onload = t.step_func(() => {
+ testOpener(t, popupW, window, () => popupW.close(), true);
+ });
+}, "opener of discarded auxiliary browsing context");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/embedded-opener.html b/testing/web-platform/tests/html/browsers/windows/embedded-opener.html
new file mode 100644
index 0000000000..8e02664342
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/embedded-opener.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<title>opener and embedded documents; using window.open()</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<iframe name=matchesastring></iframe>
+<script>
+async_test(t => {
+ const frame = document.querySelector("iframe");
+ frame.onload = t.step_func(() => {
+ // Firefox and Chrome/Safari load differently
+ if (frame.contentWindow.location.href === "about:blank") {
+ return;
+ }
+
+ // Test bits
+ assert_equals(frame.contentWindow.opener, window, "opener before setting it to null");
+
+ const openerDesc = Object.getOwnPropertyDescriptor(frame.contentWindow, "opener"),
+ openerGet = openerDesc.get;
+
+ assert_equals(openerGet(), window, "opener before setting it to null via directly invoking the getter");
+ frame.contentWindow.opener = null;
+ frame.contentWindow.opener = "immaterial";
+ assert_equals(openerGet(), null, "opener after setting it to null via directly invoking the getter");
+ assert_equals(frame.contentWindow.opener, "immaterial");
+
+ t.done();
+ });
+ window.open("/common/blank.html", "matchesastring");
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-print.sub.html b/testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-print.sub.html
new file mode 100644
index 0000000000..d07db13776
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-print.sub.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<link rel=match href="iframe-nested-print-ref.html">
+<style>
+ body { margin: 0 }
+</style>
+<iframe frameborder=0 scrolling=no src="//{{hosts[alt][www]}}:{{ports[http][0]}}{{location[path]}}/../resources/iframe-nested-cross-origin.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-scaled-print.sub.html b/testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-scaled-print.sub.html
new file mode 100644
index 0000000000..2442563082
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/iframe-cross-origin-scaled-print.sub.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<link rel=match href="iframe-nested-scaled-print-ref.html">
+<style>
+ body { margin: 0 }
+ div {
+ transform-origin: top left;
+ transform: scale(2);
+ overflow: hidden;
+ }
+ iframe {
+ width: 100px;
+ height: 50px;
+ }
+</style>
+<div>
+<iframe frameborder=0 scrolling=no src="//{{hosts[alt][www]}}:{{ports[http][0]}}{{location[path]}}/../resources/iframe-nested-printing-pass.html"></iframe>
+</div>
diff --git a/testing/web-platform/tests/html/browsers/windows/iframe-nested-print-ref.html b/testing/web-platform/tests/html/browsers/windows/iframe-nested-print-ref.html
new file mode 100644
index 0000000000..c36c459881
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/iframe-nested-print-ref.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<style>
+ body { margin: 0 }
+ p {
+ /* 2 times the default margin of <body>, to account for the doubly-nested document */
+ margin: 16px;
+ }
+</style>
+<p>PASS
diff --git a/testing/web-platform/tests/html/browsers/windows/iframe-nested-print.html b/testing/web-platform/tests/html/browsers/windows/iframe-nested-print.html
new file mode 100644
index 0000000000..844f6ba373
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/iframe-nested-print.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<link rel=match href="iframe-nested-print-ref.html">
+<style>
+ body { margin: 0 }
+</style>
+<iframe frameborder=0 scrolling=no srcdoc="<iframe scrolling=no frameborder=0 srcdoc='PASS'></iframe>"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/windows/iframe-nested-scaled-print-ref.html b/testing/web-platform/tests/html/browsers/windows/iframe-nested-scaled-print-ref.html
new file mode 100644
index 0000000000..fceaf1e52c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/iframe-nested-scaled-print-ref.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<style>
+ body { margin: 0 }
+ div {
+ transform-origin: top left;
+ transform: scale(2);
+ }
+ iframe {
+ width: 100px;
+ height: 50px;
+ }
+</style>
+<div>
+<iframe frameborder=0 scrolling=no src="resources/iframe-nested-printing-pass.html"></iframe>
+</div>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement-siblings.sub.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement-siblings.sub.html
new file mode 100644
index 0000000000..0c814d26d9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement-siblings.sub.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>window.frameElement access to a same-origin-domain sibling</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe src="//{{hosts[][]}}:{{ports[http][0]}}/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessed.html"></iframe>
+<iframe src="//{{hosts[][www]}}:{{ports[http][0]}}/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessor.html"></iframe>
+
+<script>
+"use strict";
+setup({ explicit_done: true });
+
+window.onload = () => {
+ promise_test(async () => {
+ frames[1].postMessage({}, "*");
+ const result = await waitForMessage();
+
+ assert_equals(result, "SecurityError");
+ }, "it must give a \"SecurityError\" DOMException if the pages are different-origin domain");
+
+ promise_test(async () => {
+ document.domain = document.domain;
+
+ frames[0].postMessage({ newDocumentDomain: document.domain }, "*");
+ assert_equals(await waitForMessage(), "done");
+
+ frames[1].postMessage({ newDocumentDomain: document.domain }, "*");
+ const result = await waitForMessage();
+
+ assert_equals(result, "HTMLIFrameElement");
+ }, "it must return the iframe element if the pages are same-origin domain");
+
+ done();
+};
+
+function waitForMessage() {
+ return new Promise(resolve => {
+ window.addEventListener("message", e => resolve(e.data), { once: true });
+ });
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html
new file mode 100644
index 0000000000..7ea1182081
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/frameElement.sub.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <title>HTML Test: window.frameElement</title>
+ <link rel="author" title="Intel" href="http://www.intel.com/" />
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <!-- t1 (same-origin)-->
+ <iframe id="iframe_0"></iframe>
+ <iframe id="iframe_1" src="./resources/frameElement-nested-frame.html"></iframe>
+ <object id="object_id" name="object_name" type="text/html" data="about:blank"></object>
+ <embed id="embed_id" name="embed_name" type="image/svg+xml" src="/images/green.svg" />
+
+ <!-- t2 (cross-origin) -->
+ <iframe name="iframe_2" src="http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/nested-browsing-contexts/resources/frameElement-nested-frame.html"></iframe>
+
+ <!-- t3 (cross-origin) -->
+ <iframe id="iframe_3" src="http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/nested-browsing-contexts/resources/frameElement-window-post.html"></iframe>
+
+ <script>
+ test(function() {
+ assert_equals(window.frameElement, null,
+ "The frameElement attribute should be null.");
+ }, "The window's frameElement attribute must return null if it is not a nested browsing context");
+
+ var t1 = async_test("The window's frameElement attribute must return its container element if it is a nested browsing context");
+ window.addEventListener("load", t1.step_func_done(function() {
+ assert_equals(frames[0].frameElement, document.getElementById("iframe_0"),
+ "The frameElement attribute should be the first iframe element.");
+ assert_equals(window["object_name"].frameElement, document.getElementById("object_id"),
+ "The frameElement attribute should be the object element.");
+ assert_equals(window["embed_name"].frameElement, document.getElementById("embed_id"),
+ "The frameElement attribute should be the embed element.");
+ assert_equals(document.getElementById("iframe_1").contentWindow[0].frameElement,
+ document.getElementById("iframe_1").contentDocument.getElementById("f1"),
+ "The frameElement attribute should be the frame element in 'resources/frameElement-nested-frame.html'.");
+ }));
+
+ var t2 = async_test("The SecurityError must be thrown if the window accesses to frameElement attribute of a Window which does not have the same effective script origin");
+ window.addEventListener("load", t2.step_func_done(function() {
+ assert_throws_dom("SecurityError", function() {
+ frames["iframe_2"].frameElement;
+ },
+ "The SecurityError exception should be thrown.");
+ }));
+
+ var t3 = async_test("The window's frameElement attribute must return null if the container's document does not have the same effective script origin");
+ window.addEventListener("load", function() {
+ window.addEventListener("message", function(event) {
+ var data = JSON.parse(event.data);
+ if (data.name == "testcase3") {
+ t3.step(function() {
+ assert_equals(data.result, "window.frameElement = null",
+ "The frameElement attribute should be null.");
+ t3.done();
+ });
+ }
+ }, false);
+ document.getElementById("iframe_3").contentWindow.postMessage(null, "*");
+ })
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/name-attribute.window.js b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/name-attribute.window.js
new file mode 100644
index 0000000000..69908af71b
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/name-attribute.window.js
@@ -0,0 +1,58 @@
+// META: script=/common/get-host-info.sub.js
+
+[
+ "frame", // This works without <frameset>, so great
+ "iframe",
+ "object",
+ "embed",
+].forEach(element => {
+ [
+ null,
+ "",
+ "initialvalue"
+ ].forEach(initialNameValue => {
+ [
+ "same-origin",
+ "cross-origin"
+ ].forEach(originType => {
+ async_test(t => {
+ const ident = element + initialNameValue + originType,
+ file = `${new URL("resources/post-to-parent.html", location.href).pathname}?ident=${ident}`,
+ child = originType === "same-origin" ? file : `${get_host_info().HTTP_REMOTE_ORIGIN}${file}`,
+ frame = document.createElement(element),
+ expectedNameValue = initialNameValue || "";
+ let state = "set";
+ const listener = t.step_func(e => {
+ if (e.data.ident === ident) {
+ assert_equals(e.data.name, expectedNameValue); // This check is always the same
+ if (state === "set") {
+ frame.setAttribute("name", "meh");
+ state = "remove"
+ e.source.postMessage(null, "*");
+ return;
+ }
+ if (state === "remove") {
+ frame.removeAttribute("name");
+ state = "done";
+ e.source.postMessage(null, "*");
+ return;
+ }
+ if (state === "done") {
+ t.done();
+ }
+ }
+ });
+ frame.setAttribute(element === "object" ? "data" : "src", child);
+ if (initialNameValue !== null) {
+ frame.setAttribute("name", initialNameValue);
+ }
+ t.add_cleanup(() => {
+ self.removeEventListener("message", listener);
+ frame.remove();
+ });
+ self.addEventListener("message", listener);
+ document.body.append(frame);
+ }, `${originType} <${element}${initialNameValue !== null ? ' name=' + initialNameValue : ''}>`);
+ });
+ });
+});
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-nested-frame.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-nested-frame.html
new file mode 100644
index 0000000000..d066b8d4cb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-nested-frame.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<meta charset="utf-8"/>
+<title>HTML Test: child browsing context created by the frame element</title>
+<link rel="author" title="Intel" href="http://www.intel.com/" />
+<frameset>
+ <frame id="f1" name="frame">
+</frameset>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessed.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessed.html
new file mode 100644
index 0000000000..15245981ce
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessed.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>This page will set its document.domain on request so that its sibling can access it</title>
+
+<h1>I did get loaded</h1>
+
+<script>
+"use strict";
+
+window.onmessage = e => {
+ const { newDocumentDomain } = e.data;
+ document.domain = newDocumentDomain;
+
+ parent.postMessage("done", "*");
+};
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessor.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessor.html
new file mode 100644
index 0000000000..4b4c7a87bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessor.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>This page will attempt to access the frameElement of its sibling and report the results on request</title>
+
+<h1>I did get loaded</h1>
+
+<script>
+"use strict";
+
+window.onmessage = e => {
+ const { newDocumentDomain } = e.data;
+ if (newDocumentDomain) {
+ document.domain = newDocumentDomain;
+ }
+
+ const siblingWindow = parent.frames[0];
+
+ try {
+ const { frameElement } = siblingWindow;
+
+ let result = "something wierd happened";
+ if (frameElement === null) {
+ result = "null";
+ } else if (frameElement.constructor) {
+ result = frameElement.constructor.name;
+ }
+
+ parent.postMessage(result, "*");
+ } catch (e) {
+ parent.postMessage(e.name, "*");
+ }
+};
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-window-post.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-window-post.html
new file mode 100644
index 0000000000..d67bde26f4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/frameElement-window-post.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8"/>
+<title>Testcase 3: frameElement attribute must return null if the container\'s document does not have the same effective script origin</title>
+<script>
+window.addEventListener("message", function (event) {
+ try {
+ var result = "window.frameElement = " + window.frameElement;
+ } catch (e) {
+ result = e.message;
+ }
+ event.source.postMessage(JSON.stringify({name: "testcase3", result: result}),
+ "*");
+}, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-opener.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-opener.html
new file mode 100644
index 0000000000..65a825f573
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-opener.html
@@ -0,0 +1,7 @@
+<script>
+ if (window.opener) {
+ window.opener.postMessage({
+ "parent_isTop": (window.parent === window)
+ }, "*");
+ }
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-parent.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-parent.html
new file mode 100644
index 0000000000..302e9d9cc1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/resources/post-to-parent.html
@@ -0,0 +1,6 @@
+<script>
+const ident = new URL(location).searchParams.get("ident"),
+ post = () => parent.postMessage({ name: window.name, ident }, "*");
+onmessage = () => post();
+post();
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent-null.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent-null.html
new file mode 100644
index 0000000000..428312086e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent-null.html
@@ -0,0 +1,66 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>window.parent: `null`</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ var iframe = document.createElement('iframe');
+ iframe.onload = t.step_func_done(() => {
+ var iWindow = iframe.contentWindow;
+ assert_equals(iWindow.parent, window);
+ document.body.removeChild(iframe);
+ assert_equals(iWindow.parent, null);
+ });
+
+ document.body.appendChild(iframe);
+}, '`window.parent` is null when browsing context container element removed');
+
+async_test(t => {
+ var iframe = document.createElement('iframe');
+ var iframe2, removedEl;
+
+ var testFunc = t.step_func(() => {
+ var frameWindow = iframe.contentWindow;
+ var frame2Window = iframe2.contentWindow;
+
+ assert_equals(frameWindow.parent, window);
+ assert_equals(frame2Window.parent, frameWindow);
+
+ iframe.removeEventListener('load', nestFrame);
+ iframe2.removeEventListener('load', testFunc);
+ removedEl = document.body.removeChild(iframe);
+
+ assert_equals(frameWindow.parent, null);
+ assert_equals(frame2Window.parent, null);
+
+ removedEl.addEventListener('load', t.step_func_done(() => {
+ // reattached iframe's browsing context will report window.parent again
+ assert_equals(removedEl.contentWindow.parent, window);
+ // The following window s are no longer referenced by active browsing contexts
+ assert_equals(frameWindow.parent, null);
+ assert_equals(frame2Window.parent, null);
+ // Per #the-iframe-element, reattaching a removed iframe will result in the
+ // browser creating a new browsing context once again, with a fresh
+ // document in our case, so the second iframe or any other elements
+ // previously added to iframe.contentDocument will be gone
+ assert_equals(removedEl.contentDocument.querySelector('iframe'), null);
+ assert_equals(removedEl.contentDocument.querySelector('hr'), null);
+ }));
+ document.body.appendChild(removedEl);
+ });
+
+ var nestFrame = function () {
+ iframe.contentDocument.body.appendChild(document.createElement('hr'));
+ iframe2 = iframe.contentDocument.createElement('iframe');
+ // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1229707
+ iframe2.src = '/common/blank.html';
+ iframe2.addEventListener('load', testFunc);
+ iframe.contentDocument.body.appendChild(iframe2);
+ };
+
+ iframe.addEventListener('load', nestFrame);
+ document.body.appendChild(iframe);
+}, '`window.parent` null when parent browsing context container removed');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent.html
new file mode 100644
index 0000000000..ef662dca5e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-parent.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>window.parent</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+ test(function() {
+ assert_equals(window, parent)
+ }, '`window.parent` for top-level browsing context');
+
+async_test(t => {
+ var iframe = document.createElement('iframe');
+ iframe.onload = t.step_func_done(function () {
+ var iWindow = iframe.contentWindow;
+ assert_equals(iWindow.parent, window);
+ });
+ document.body.appendChild(iframe);
+}, '`window.parent` on single nested browsing context');
+
+async_test(t => {
+ var iframe = document.createElement('iframe');
+ var iframe2;
+
+ var testFunc = t.step_func_done(function () {
+ var frameWindow = iframe.contentWindow;
+ var frame2Window = iframe2.contentWindow;
+ assert_equals(frameWindow.parent, window);
+ assert_equals(frame2Window.parent, frameWindow);
+ assert_not_equals(frame2Window.parent, window);
+ });
+
+ var nestFrame = function () {
+ iframe2 = iframe.contentDocument.createElement('iframe');
+ // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1229707
+ iframe2.src = '/common/blank.html';
+ iframe2.addEventListener('load', testFunc);
+ iframe.contentDocument.body.appendChild(iframe2);
+ };
+
+ iframe.addEventListener('load', nestFrame);
+ document.body.appendChild(iframe);
+}, '`window.parent` for multiple nested browsing contexts');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top-null.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top-null.html
new file mode 100644
index 0000000000..cf7fcf2ae1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top-null.html
@@ -0,0 +1,66 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>window.top: `null`</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function (t) {
+ var iframe = document.createElement('iframe');
+ iframe.onload = t.step_func_done(() => {
+ var iWindow = iframe.contentWindow;
+ /**
+ * `top` should return the top-level browsing context but will return
+ * `null` if none exists, such as when any of the BC's ancestor browsing
+ * context container's document elements are disconnected/removed.
+ */
+ assert_equals(iWindow.top, window);
+ document.body.removeChild(iframe);
+ assert_equals(iWindow.top, null);
+ });
+
+ document.body.appendChild(iframe);
+}, '`window.top` is null when browsing context container element removed');
+
+async_test(t => {
+ var iframe = document.createElement('iframe');
+ var iframe2, removedEl;
+
+ var testFunc = t.step_func(() => {
+ var frameWindow = iframe.contentWindow;
+ var frame2Window = iframe2.contentWindow;
+
+ assert_equals(frameWindow.top, window);
+ assert_equals(frame2Window.top, window);
+
+ iframe.removeEventListener('load', nestFrame);
+ iframe2.removeEventListener('load', testFunc);
+
+ removedEl = document.body.removeChild(iframe);
+
+ assert_equals(frameWindow.top, null);
+ assert_equals(frame2Window.top, null);
+
+ removedEl.addEventListener('load', t.step_func_done(() => {
+ // reattached iframe's browsing context will report window.top
+ assert_equals(removedEl.contentWindow.top, window);
+ // removed/re-added iframes will have new browsing context / window
+ assert_equals(frameWindow.top, null);
+ assert_equals(frame2Window.top, null);
+ }));
+
+ document.body.appendChild(removedEl);
+ });
+
+ var nestFrame = function () {
+ iframe2 = iframe.contentDocument.createElement('iframe');
+ // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1229707
+ iframe2.src = '/common/blank.html';
+ iframe2.addEventListener('load', testFunc);
+ iframe.contentDocument.body.appendChild(iframe2);
+ };
+
+ iframe.addEventListener('load', nestFrame);
+ document.body.appendChild(iframe);
+}, '`window.top`null when any ancestor browsing context container removed');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top.html b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top.html
new file mode 100644
index 0000000000..e5590adeb8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/nested-browsing-contexts/window-top.html
@@ -0,0 +1,65 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>window.top</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_equals(window, top)
+}, "Top level browsing context");
+
+function step_func(test) {
+ return function (top_pointer) {
+ test.step(function() {assert_equals(top_pointer, window);})
+ test.done();
+ }
+}
+
+var t1 = async_test("One nested iframe");
+t1.step(function() {
+ var iframe = document.createElement("iframe");
+ //iframe.src = "data:text/html,"
+
+ iframe.onload = t1.step_func(
+ function() {
+ var doc = iframe.contentDocument;
+ iframe.contentWindow.test_func = step_func(t1);
+
+ var script = doc.createElement("script")
+ script.textContent = "test_func(top);"
+ doc.body.appendChild(script);
+ });
+ document.body.appendChild(iframe);
+});
+
+var t2 = async_test("Two nested iframes");
+t2.step(function() {
+ var iframe = document.createElement("iframe");
+ //iframe.src = "data:text/html,"
+
+ iframe.onload = t2.step_func(
+ function() {
+ var doc = iframe.contentDocument;
+ iframe2 = document.createElement("iframe");
+ //iframe2.src = "data:text/html,"
+ // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1229707
+ iframe2.src = '/common/blank.html';
+
+ iframe2.onload = t2.step_func(
+ function() {
+ var doc2 = iframe2.contentDocument;
+
+ iframe2.contentWindow.test_func = step_func(t2);
+
+ var script = doc2.createElement("script")
+ script.textContent = "test_func(top);"
+ doc2.body.appendChild(script);
+ });
+ doc.body.appendChild(iframe2);
+ });
+
+ document.body.appendChild(iframe);
+});
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-close-manual.sub.html b/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-close-manual.sub.html
new file mode 100644
index 0000000000..8e2740c268
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-close-manual.sub.html
@@ -0,0 +1,3 @@
+<meta charset=utf-8>
+<p>Follow this link to open a new browsing context and then confirm it can be closed:
+<a rel=noreferrer target=reallydoesnotmatter href="//天気の良い日.{{location[host]}}/html/browsers/windows/resources/window-close-button.html">link</a>.
diff --git a/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-manual.html b/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-manual.html
new file mode 100644
index 0000000000..f5879ee6d7
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-manual.html
@@ -0,0 +1,10 @@
+<ol>
+ <li><p>After clicking these two links in order a single browsing context should be open showing
+ <code>example.org</code>:
+ <a target=doesnotmatter href="http://example.com/">one</a>,
+ <a target=doesnotmatter href="http://example.org/">two</a>.
+
+ <li><p>After clicking these two links two browsing contexts should have been opened:
+ <a rel=noreferrer target=reallydoesnotmatter href="http://example.com/">one</a>,
+ <a rel=noreferrer target=reallydoesnotmatter href="http://example.com/">two</a>.
+</ol>
diff --git a/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-window-name-manual.sub.html b/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-window-name-manual.sub.html
new file mode 100644
index 0000000000..c598ffbfaa
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/noreferrer-cross-origin-window-name-manual.sub.html
@@ -0,0 +1,3 @@
+<meta charset=utf-8>
+<p>Follow this link to open a new browsing context and then confirm it says "idonteven":
+<a rel=noreferrer target=idonteven href="//天気の良い日.{{location[host]}}/html/browsers/windows/resources/echo-window-name.html">link</a>.
diff --git a/testing/web-platform/tests/html/browsers/windows/noreferrer-null-opener.html b/testing/web-platform/tests/html/browsers/windows/noreferrer-null-opener.html
new file mode 100644
index 0000000000..f308abc05e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/noreferrer-null-opener.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>rel=noreferrer nullifies window.opener</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+ async_test(function(t) {
+ localStorage.clear()
+
+ var hyperlink = document.body.appendChild(document.createElement("a"))
+ hyperlink.rel = "noreferrer"
+ hyperlink.target = "_blank"
+ hyperlink.href = "resources/window-opener.html"
+ hyperlink.click()
+ document.body.removeChild(hyperlink)
+
+ addEventListener("storage", function(e) {
+ t.step(function() {
+ assert_equals(e.newValue, "null")
+ localStorage.clear()
+ t.done()
+ })
+ })
+ })
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/noreferrer-window-name.html b/testing/web-platform/tests/html/browsers/windows/noreferrer-window-name.html
new file mode 100644
index 0000000000..5fe649d172
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/noreferrer-window-name.html
@@ -0,0 +1,86 @@
+<!doctype html>
+<title>rel=noreferrer and reuse of names</title>
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+ async_test(function(t) {
+ localStorage.clear()
+
+ function makeHyperlink(n) {
+ var hyperlink = document.body.appendChild(document.createElement("a"))
+ hyperlink.rel = "noreferrer"
+ hyperlink.target = "sufficientlyrandomwindownameamiright"
+ hyperlink.href = "resources/noreferrer-window-name.html#" + n
+ return hyperlink
+ }
+
+ var hyperlink1 = makeHyperlink(1),
+ hyperlink2 = makeHyperlink(2)
+
+ t.add_cleanup(function() {
+ localStorage.setItem("x", "close")
+ localStorage.clear()
+ document.body.removeChild(hyperlink1)
+ document.body.removeChild(hyperlink2)
+ })
+
+ addEventListener("storage", function(e) {
+ t.step(function() {
+ if(localStorage.getItem("window1") && localStorage.getItem("window2")) {
+ localStorage.setItem("x", "close")
+ t.done()
+ }
+ })
+ })
+
+ hyperlink1.click()
+ hyperlink2.click()
+ }, "Following a noreferrer link with a named target should not cause creation of a window that can be targeted by another noreferrer link with the same named target");
+
+ async_test(function(t) {
+ var ifr = document.createElement("iframe");
+ ifr.name = "sufficientlyrandomwindownameamiright2";
+ ifr.onload = t.step_func(function() {
+ var hyperlink = document.body.appendChild(document.createElement("a"));
+ t.add_cleanup(function() {
+ hyperlink.remove();
+ });
+ hyperlink.rel = "noreferrer";
+ hyperlink.href = URL.createObjectURL(new Blob(["hello subframe"],
+ { type: "text/html"}));
+ hyperlink.target = "sufficientlyrandomwindownameamiright2";
+ ifr.onload = t.step_func_done(function() {
+ assert_equals(ifr.contentDocument.documentElement.textContent,
+ "hello subframe");
+ });
+ hyperlink.click();
+ });
+ document.body.appendChild(ifr);
+ t.add_cleanup(function() {
+ ifr.remove();
+ });
+ }, "Targeting a rel=noreferrer link at an existing named subframe should work");
+
+ async_test(function(t) {
+ var win = window.open("", "sufficientlyrandomwindownameamiright3");
+ t.add_cleanup(function() {
+ win.close();
+ });
+
+ var hyperlink = document.body.appendChild(document.createElement("a"));
+ t.add_cleanup(function() {
+ hyperlink.remove();
+ });
+ hyperlink.rel = "noreferrer";
+ hyperlink.href = URL.createObjectURL(new Blob(["hello window"],
+ { type: "text/html"}));
+ hyperlink.target = "sufficientlyrandomwindownameamiright3";
+ win.onload = t.step_func_done(function() {
+ assert_equals(win.document.documentElement.textContent,
+ "hello window");
+ });
+ hyperlink.click();
+ }, "Targeting a rel=noreferrer link at an existing named window should work");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/windows/opener-cross-origin-manual.sub.html b/testing/web-platform/tests/html/browsers/windows/opener-cross-origin-manual.sub.html
new file mode 100644
index 0000000000..0c018663a2
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/opener-cross-origin-manual.sub.html
@@ -0,0 +1,10 @@
+<ol>
+ <li><p>Clicking this link must navigate this page to a resource that contains "THE END":
+ <a href=//{{domains[www1]}}:{{location[port]}}/html/browsers/windows/resources/opener-cross-origin.html target=_blank>test</a>
+
+ <li><p>Clicking this link must open a new browsing context that is empty:
+ <a rel=noreferrer href=//{{domains[www1]}}:{{location[port]}}/html/browsers/windows/resources/opener-cross-origin.html target=_blank>test</a>
+
+ <li><p>Clicking this link must navigate this page to a resource that contains "THE END":
+ <a href=//{{domains[www1]}}:{{location[port]}}/html/browsers/windows/resources/opener-cross-origin-embed.sub.html target=_blank>test</a>
+</ol>
diff --git a/testing/web-platform/tests/html/browsers/windows/opener-string.window.js b/testing/web-platform/tests/html/browsers/windows/opener-string.window.js
new file mode 100644
index 0000000000..a39c584d20
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/opener-string.window.js
@@ -0,0 +1,14 @@
+test(t => {
+ const popup = window.open();
+ t.add_cleanup(() => popup.close());
+ assert_equals(popup.opener, self, "The opener of the popup is me");
+ assert_equals(Object.getOwnPropertyDescriptor(popup, "opener").writable, undefined);
+
+ popup.opener = "blah";
+ assert_equals(popup.opener, "blah", "The popup's opener is now a string");
+ assert_equals(Object.getOwnPropertyDescriptor(popup, "opener").writable, true);
+
+ const openerGetter = Object.getOwnPropertyDescriptor(self, "opener").get;
+ const popupOpener = openerGetter.call(popup);
+ assert_equals(popupOpener, self, "The underlying opener of the popup is still me");
+}, "Setting popup.opener to a string");
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-cross-partition.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-cross-partition.sub.html
new file mode 100644
index 0000000000..f91d9403ea
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-cross-partition.sub.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: First-Party to First-Party, Cross-Partition</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window) set up listener and open Site 2 Window.
+// Step 2. (Site 2 Window) send "Site 2 Window" message to Site 1 Window.
+// Step 3. (Site 1 Window) receive "Site 2 Window" message and exit.
+
+async_test(t => {
+ // Step 3
+ const listener = t.step_func(e => {
+ if (e.data === "Site 2 Window") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2Window = window.open("http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/first-party-to-first-party-cross-partition-window.html", "", "noopener=false");
+ t.add_cleanup(() => site2Window.close());
+}, "postMessage: First-Party to First-Party, Cross-Partition");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-same-partition.html b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-same-partition.html
new file mode 100644
index 0000000000..6fc915298b
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-first-party-same-partition.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: First-Party to First-Party, Same-Partition</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window A) set up listener and open Site 1 Window B.
+// Step 2. (Site 1 Window B) send "Site 1 Window B" message to Site 1 Window A.
+// Step 3. (Site 1 Window A) receive "Site 1 Window B" message and exit.
+
+async_test(t => {
+ // Step 3
+ const listener = t.step_func(e => {
+ if (e.data === "Site 1 Window B") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site1WindowB = window.open("/html/browsers/windows/post-message/resources/first-party-to-first-party-same-partition-window.html", "", "noopener=false");
+ t.add_cleanup(() => site1WindowB.close());
+}, "postMessage: First-Party to First-Party, Same-Partition");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-cross-origin.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-cross-origin.sub.html
new file mode 100644
index 0000000000..de776f8381
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-cross-origin.sub.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: First-Party to Third-Party, Cross-Partition, Cross-Origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window) set up listener and open Site 2 Window.
+// Step 2. (Site 2 Window) open Site 3 Frame.
+// Step 3. (Site 3 Frame) send "Site 3 Frame" message to Site 1 Window.
+// Step 4. (Site 1 Window) receive "Site 1 Frame" message and exit.
+
+async_test(t => {
+ // Step 4
+ const listener = t.step_func(e => {
+ if (e.data === "Site 3 Frame") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2Window = window.open("https://{{hosts[alt][]}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-window.sub.https.html", "", "noopener=false");
+ t.add_cleanup(() => site2Window.close());
+}, "postMessage: First-Party to Third-Party, Cross-Partition, Cross-Origin");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-same-origin.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-same-origin.sub.html
new file mode 100644
index 0000000000..490b647fa4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-same-origin.sub.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: First-Party to Third-Party, Cross-Partition, Same-Origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window) set up listener and open Site 2 Window.
+// Step 2. (Site 2 Window) open Site 1 Frame.
+// Step 3. (Site 1 Frame) send "Site 1 Frame" message to Site 1 Window.
+// Step 4. (Site 1 Window) receive "Site 1 Frame" message and exit.
+
+async_test(t => {
+ // Step 4
+ const listener = t.step_func(e => {
+ if (e.data === "Site 1 Frame") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2Window = window.open("http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-window.sub.html", "", "noopener=false");
+ t.add_cleanup(() => site2Window.close());
+}, "postMessage: First-Party to Third-Party, Cross-Partition, Same-Origin");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-cross-partition-window.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-cross-partition-window.html
new file mode 100644
index 0000000000..cdfa9d95ca
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-cross-partition-window.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 2 (html/browsers/windows/post-message/first-party-to-first-party-cross-partition.sub.html)
+window.opener.postMessage("Site 2 Window", "*");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-same-partition-window.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-same-partition-window.html
new file mode 100644
index 0000000000..4baf45d3c8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-first-party-same-partition-window.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 2 (html/browsers/windows/post-message/first-party-to-first-party-same-partition.html)
+window.opener.postMessage("Site 1 Window B", window.opener.origin);
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-iframe.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-iframe.https.html
new file mode 100644
index 0000000000..eef594831a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-iframe.https.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 3 (html/browsers/windows/post-message/first-party-to-third-party-cross-partition-cross-origin.sub.html)
+window.top.opener.postMessage("Site 3 Frame", "*");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-window.sub.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-window.sub.https.html
new file mode 100644
index 0000000000..7edfbd9328
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-window.sub.https.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<!--Step 2 (html/browsers/windows/post-message/first-party-to-third-party-cross-partition-cross-origin.sub.html)-->
+<iframe src="https://{{host}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-cross-origin-iframe.https.html"></iframe>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-iframe.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-iframe.html
new file mode 100644
index 0000000000..eb17036c8c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-iframe.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 3 (html/browsers/windows/post-message/first-party-to-third-party-cross-partition-same-origin.sub.html)
+window.top.opener.postMessage("Site 1 Frame", window.top.opener.origin);
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-window.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-window.sub.html
new file mode 100644
index 0000000000..f99b96c466
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-window.sub.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<!--Step 2 (html/browsers/windows/post-message/first-party-to-third-party-cross-partition-same-origin.sub.html)-->
+<iframe src="http://{{host}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/first-party-to-third-party-cross-partition-same-origin-iframe.html"></iframe>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-iframe.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-iframe.sub.html
new file mode 100644
index 0000000000..348efb3f9c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-iframe.sub.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 4 (html/browsers/windows/post-message/third-party-to-first-party-cross-partition-cross-origin.sub.html)
+let site2Window;
+const listener = e => {
+ if (e.data === "Site 3 Window") {
+ site2Window.close();
+ window.top.postMessage("Site 2 Frame", "*");
+ }
+};
+// Step 2 (html/browsers/windows/post-message/third-party-to-first-party-cross-partition-cross-origin.sub.html)
+window.addEventListener("message", listener);
+site2Window = window.open("https://{{hosts[alt][]}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-window.https.html", "", "noopener=false");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-window.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-window.https.html
new file mode 100644
index 0000000000..0045909494
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-window.https.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 3 (html/browsers/windows/post-message/third-party-to-first-party-cross-partition-cross-origin.sub.html)
+window.opener.postMessage("Site 3 Window", "*");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-iframe.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-iframe.sub.html
new file mode 100644
index 0000000000..405b1053d3
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-iframe.sub.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 4 (html/browsers/windows/post-message/third-party-to-first-party-cross-partition-same-origin.sub.html)
+let site2Window;
+const listener = e => {
+ if (e.data === "Site 2 Window") {
+ site2Window.close();
+ window.top.postMessage("Site 2 Frame", "*");
+ }
+};
+// Step 2 (html/browsers/windows/post-message/third-party-to-first-party-cross-partition-same-origin.sub.html)
+window.addEventListener("message", listener);
+site2Window = window.open("http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-window.html", "", "noopener=false");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-window.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-window.html
new file mode 100644
index 0000000000..0ae51e3fc1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-window.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 3 (html/browsers/windows/post-message/third-party-to-first-party-cross-partition-same-origin.sub.html)
+window.opener.postMessage("Site 2 Window", window.opener.origin);
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-a.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-a.sub.html
new file mode 100644
index 0000000000..a11f3640e8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-a.sub.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 5 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html)
+let site3Window;
+const listener = e => {
+ if (e.data === "Site 4 Frame") {
+ site3Window.close();
+ window.top.postMessage("Site 2 Frame", "*");
+ }
+};
+// Step 2 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html)
+window.addEventListener("message", listener);
+site3Window = window.open("https://{{host}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-window.sub.https.html", "", "noopener=false");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-b.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-b.https.html
new file mode 100644
index 0000000000..f56e2b35d8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-b.https.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 4 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html)
+window.top.opener.postMessage("Site 4 Frame", "*");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-window.sub.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-window.sub.https.html
new file mode 100644
index 0000000000..1307287587
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-window.sub.https.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<!--Step 3 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html)-->
+<iframe src="https://{{hosts[alt][]}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-b.https.html"></iframe>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-a.sub.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-a.sub.https.html
new file mode 100644
index 0000000000..ec551bfdec
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-a.sub.https.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 5 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html)
+let site3Window;
+const listener = e => {
+ if (e.data === "Site 2 Frame B") {
+ site3Window.close();
+ window.top.postMessage("Site 2 Frame A", "*");
+ }
+};
+// Step 2 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html)
+window.addEventListener("message", listener);
+site3Window = window.open("https://{{host}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-window.sub.https.html", "", "noopener=false");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-b.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-b.https.html
new file mode 100644
index 0000000000..fc15b1f125
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-b.https.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 4 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html)
+window.top.opener.postMessage("Site 2 Frame B", window.top.opener.origin);
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-window.sub.https.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-window.sub.https.html
new file mode 100644
index 0000000000..f26f709db3
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-window.sub.https.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<!--Step 3 (html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html)-->
+<iframe src="https://{{hosts[alt][]}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-b.https.html"></iframe>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-a.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-a.sub.html
new file mode 100644
index 0000000000..339dc9f06e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-a.sub.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 5 (html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html)
+let site2WindowB;
+const listener = e => {
+ if (e.data === "Site 2 Frame B") {
+ site2WindowB.close();
+ window.top.postMessage("Site 2 Frame A", "*");
+ }
+};
+// Step 2 (html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html)
+window.addEventListener("message", listener);
+site2WindowB = window.open("http://{{host}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-window.sub.html", "", "noopener=false");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-b.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-b.html
new file mode 100644
index 0000000000..daaf236bfc
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-b.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<script>
+// Step 4 (html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html)
+window.top.opener.postMessage("Site 2 Frame B", window.top.opener.origin);
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-window.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-window.sub.html
new file mode 100644
index 0000000000..7cea58f235
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-window.sub.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<!--Step 3 (html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html)-->
+<iframe src="http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-b.html"></iframe>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-cross-origin.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-cross-origin.sub.html
new file mode 100644
index 0000000000..2618e966de
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-cross-origin.sub.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: Third-Party to First-Party, Cross-Partition, Cross-Origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window) set up listener and open Site 2 Frame.
+// Step 2. (Site 2 Frame) set up listener and open Site 3 Window.
+// Step 3. (Site 3 Window) send "Site 3 Window" message to Site 2 Frame.
+// Step 4. (Site 2 Frame) receive "Site 3 Window" message and send "Site 2 Frame" message to Site 1 Window.
+// Step 5. (Site 1 Window) receive "Site 2 Frame" message and exit.
+
+async_test(t => {
+ // Step 5
+ const listener = t.step_func(e => {
+ if (e.data === "Site 2 Frame") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2Frame = document.createElement("iframe");
+ site2Frame.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-cross-origin-iframe.sub.html";
+ document.body.appendChild(site2Frame);
+}, "postMessage: Third-Party to First-Party, Cross-Partition, Cross-Origin");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-same-origin.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-same-origin.sub.html
new file mode 100644
index 0000000000..735b458841
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-first-party-cross-partition-same-origin.sub.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: Third-Party to First-Party, Cross-Partition, Same-Origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window) set up listener and open Site 2 Frame.
+// Step 2. (Site 2 Frame) set up listener and open Site 2 Window.
+// Step 3. (Site 2 Window) send "Site 2 Window" message to Site 2 Frame.
+// Step 4. (Site 2 Frame) receive "Site 2 Window" message and send "Site 2 Frame" message to Site 1 Window.
+// Step 5. (Site 1 Window) receive "Site 2 Frame" message and exit.
+
+async_test(t => {
+ // Step 5
+ const listener = t.step_func(e => {
+ if (e.data === "Site 2 Frame") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2Frame = document.createElement("iframe");
+ site2Frame.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/third-party-to-first-party-cross-partition-same-origin-iframe.sub.html";
+ document.body.appendChild(site2Frame);
+}, "postMessage: Third-Party to First-Party, Cross-Partition, Same-Origin");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html
new file mode 100644
index 0000000000..1083071f7d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-cross-origin.sub.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: Third-Party to Third-Party, Cross-Partition, Cross-Origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window) set up listener and open Site 2 Frame.
+// Step 2. (Site 2 Frame) set up listener and open Site 3 Window.
+// Step 3. (Site 3 Window) open Site 4 Frame.
+// Step 4. (Site 4 Frame) send "Site 4 Frame" message to Site 2 Frame.
+// Step 5. (Site 2 Frame) receive "Site 4 Frame" message and send "Site 2 Frame" message to Site 1 Window.
+// Step 6. (Site 1 Window) receive "Site 2 Frame" message and exit.
+
+async_test(t => {
+ // Step 6
+ const listener = t.step_func(e => {
+ if (e.data === "Site 2 Frame") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2FrameA = document.createElement("iframe");
+ site2FrameA.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-cross-origin-iframe-a.sub.html";
+ document.body.appendChild(site2FrameA);
+}, "postMessage: Third-Party to Third-Party, Cross-Partition, Cross-Origin");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html
new file mode 100644
index 0000000000..9caf6c11e4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-cross-partition-same-origin.sub.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: Third-Party to Third-Party, Cross-Partition, Same-Origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window) set up listener and open Site 2 Frame A.
+// Step 2. (Site 2 Frame A) set up listener and open Site 3 Window.
+// Step 3. (Site 3 Window) open Site 2 Frame B.
+// Step 4. (Site 2 Frame B) send "Site 2 Frame B" message to Site 2 Frame A.
+// Step 5. (Site 2 Frame A) receive "Site 2 Frame B" message and send "Site 2 Frame A" message to Site 1 Window.
+// Step 6. (Site 1 Window) receive "Site 2 Frame A" message and exit.
+
+async_test(t => {
+ // Step 6
+ const listener = t.step_func(e => {
+ if (e.data === "Site 2 Frame A") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2FrameA = document.createElement("iframe");
+ site2FrameA.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-cross-partition-same-origin-iframe-a.sub.https.html";
+ document.body.appendChild(site2FrameA);
+}, "postMessage: Third-Party to Third-Party, Cross-Partition, Same-Origin");
+</script>
+</body>
diff --git a/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html
new file mode 100644
index 0000000000..c90a055268
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/post-message/third-party-to-third-party-same-partition.sub.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>postMessage: Third-Party to Third-Party, Same-Partition</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// Here's the set-up for this test:
+// Step 1. (Site 1 Window A) set up listener and open Site 2 Frame A.
+// Step 2. (Site 2 Frame A) set up listener and open Site 1 Window B.
+// Step 3. (Site 1 Window B) open Site 2 Frame B.
+// Step 4. (Site 2 Frame B) send "Site 2 Frame B" message to Site 2 Frame A.
+// Step 5. (Site 2 Frame A) receive "Site 2 Frame B" message and send "Site 2 Frame A" message to Site 1 Window A.
+// Step 6. (Site 1 Window A) receive "Site 2 Frame A" message and exit.
+
+async_test(t => {
+ // Step 6
+ const listener = t.step_func(e => {
+ if (e.data === "Site 2 Frame A") {
+ t.done();
+ }
+ });
+ // Step 1
+ window.addEventListener("message", listener);
+ const site2FrameA = document.createElement("iframe");
+ site2FrameA.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/third-party-to-third-party-same-partition-iframe-a.sub.html";
+ document.body.appendChild(site2FrameA);
+}, "postMessage: Third-Party to Third-Party, Same-Partition");
+</script>
+</body>
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>
diff --git a/testing/web-platform/tests/html/browsers/windows/restore-window-name-manual.https.html b/testing/web-platform/tests/html/browsers/windows/restore-window-name-manual.https.html
new file mode 100644
index 0000000000..13e8381e31
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/restore-window-name-manual.https.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<html>
+<head>
+ <title>Restore window.name when navigating back from a cross-origin</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/utils.js"></script>
+</head>
+<body>
+ <script>
+ function runTest() {
+ const name = token();
+ window.open(`resources/restore-window-name.sub.html?name=${name}`, "start");
+ }
+
+ </script>
+ <p>Please click the following link and follow the instructions in the page for testing</p>
+ <a target="start" href="javascript:void(0)" onclick="runTest()">run test</a>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html b/testing/web-platform/tests/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html
new file mode 100644
index 0000000000..44d4fbad6b
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Targeting nested browsing contexts</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+ <script src="/common/get-host-info.sub.js"></script>
+ <script>
+ async_test(function (t) {
+ var windowsToClose = [];
+ window.onmessage = t.step_func(function (e) {
+ if (e.data.name == "openee") {
+ var a = document.body.appendChild(document.createElement('a'));
+ a.target = "nested1";
+ a.href = "resources/post-to-opener.html";
+ a.click();
+ windowsToClose.push(e.source);
+ } else {
+ assert_equals(e.data.name, "nested1");
+ assert_equals(e.data.isTop, true);
+ windowsToClose.push(e.source);
+ windowsToClose.forEach(function (w) {
+ w.close();
+ });
+ t.done();
+ }
+ });
+
+ var a = document.body.appendChild(document.createElement('a'));
+ a.target = "openee";
+ a.href = get_host_info().HTTP_REMOTE_ORIGIN + "/html/browsers/windows/resources/nested-post-to-opener.html";
+ a.click();
+ });
+ </script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/windows/targeting-multiple-cross-origin-manual.sub.html b/testing/web-platform/tests/html/browsers/windows/targeting-multiple-cross-origin-manual.sub.html
new file mode 100644
index 0000000000..c8f8cfbe29
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/targeting-multiple-cross-origin-manual.sub.html
@@ -0,0 +1,9 @@
+<meta charset=utf-8>
+<p>Follow this link to open a new browsing context in a separate origin. Follow the instructions
+in that new window, and then come back to this window.
+<a target=first href="{{location[scheme]}}://{{domains[天気の良い日]}}:{{location[port]}}/html/browsers/windows/resources/target-cross-origin.sub.html">link</a>.
+
+<p>Once you come back to this page, follow this link.
+<a target=second href="resources/echo-window-name.html">link</a>.
+
+<p>After clicking that link, you should have three additional windows open.
diff --git a/testing/web-platform/tests/html/browsers/windows/targeting-with-embedded-null-in-target.html b/testing/web-platform/tests/html/browsers/windows/targeting-with-embedded-null-in-target.html
new file mode 100644
index 0000000000..7407248ffe
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/windows/targeting-with-embedded-null-in-target.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Targeting with embedded null in target</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+ <iframe name="abc">
+ </iframe>
+ <a href="resources/message-parent.html" target="abc">Click me</a>
+ <script>
+ var t = async_test();
+ var target_name = "abc\u0000def";
+
+ onmessage = t.step_func_done(function (e) {
+ assert_equals(e.data.name, target_name,
+ "Should come from a window with the right name");
+ assert_equals(e.source, frames[1],
+ "Should come frome the right window");
+ });
+
+ t.step(function() {
+ var iframe = document.createElement("iframe");
+ iframe.setAttribute("name", target_name);
+ document.body.appendChild(iframe);
+ var a = document.querySelector("a");
+ a.target = target_name;
+ a.click();
+ });
+ </script>
+</body>
+</html>