summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/windows/browsing-context-names
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/html/browsers/windows/browsing-context-names
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/browsers/windows/browsing-context-names')
-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
35 files changed, 585 insertions, 0 deletions
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>