aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDelan Azabani <dazabani@igalia.com>2023-03-21 14:06:05 +0800
committerDelan Azabani <dazabani@igalia.com>2023-03-23 18:07:50 +0800
commitc831a136b27a9b7c139c3004bbd0c187120f2bd5 (patch)
tree4b4044f6afd277b030f6da8333527d08a1faba8a /tests
parentfb2acb0b02be16bf5dd518adbc82ec08579efe4c (diff)
downloadservo-c831a136b27a9b7c139c3004bbd0c187120f2bd5.tar.gz
servo-c831a136b27a9b7c139c3004bbd0c187120f2bd5.zip
clarify and test interactions with indexed access
Diffstat (limited to 'tests')
-rw-r--r--tests/wpt/web-platform-tests/html/browsers/the-window-object/window-indexed-access-vs-named-access.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/html/browsers/the-window-object/window-indexed-access-vs-named-access.html b/tests/wpt/web-platform-tests/html/browsers/the-window-object/window-indexed-access-vs-named-access.html
new file mode 100644
index 00000000000..4918d7a5031
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/browsers/the-window-object/window-indexed-access-vs-named-access.html
@@ -0,0 +1,49 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Interactions between indexed and named access on the Window object</title>
+<link rel="author" title="Delan Azabani" href="dazabani@igalia.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#named-access-on-the-window-object">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=0></div>
+<div id=3></div>
+<iframe name=2></iframe>
+<iframe name=1></iframe>
+<script>
+const divs = document.querySelectorAll("div");
+const iframes = document.querySelectorAll("iframe");
+const wp = Object.getPrototypeOf(window);
+test(function() {
+ assert_equals(window[0], iframes[0].contentWindow);
+ assert_equals(window["0"], iframes[0].contentWindow);
+}, "WindowProxy: document-tree child navigable with index 0 (indexed access)");
+test(function() {
+ assert_equals(window[1], iframes[1].contentWindow);
+ assert_equals(window["1"], iframes[1].contentWindow);
+}, "WindowProxy: document-tree child navigable with index 1 (indexed access)");
+test(function() {
+ assert_equals(window[2], iframes[0].contentWindow);
+ assert_equals(window["2"], iframes[0].contentWindow);
+}, "WindowProxy: document-tree child navigable with target name 2 (named access)");
+test(function() {
+ assert_equals(window[3], divs[1]);
+ assert_equals(window["3"], divs[1]);
+}, "WindowProxy: element with id 3 (named access)");
+test(function() {
+ assert_equals(wp[0], divs[0]);
+ assert_equals(wp["0"], divs[0]);
+}, "Window prototype: element with id 0 (named access)");
+test(function() {
+ assert_equals(wp[1], iframes[1].contentWindow);
+ assert_equals(wp["1"], iframes[1].contentWindow);
+}, "Window prototype: document-tree child navigable with target name 1 (named access)");
+test(function() {
+ assert_equals(wp[2], iframes[0].contentWindow);
+ assert_equals(wp["2"], iframes[0].contentWindow);
+}, "Window prototype: document-tree child navigable with target name 2 (named access)");
+test(function() {
+ assert_equals(wp[3], divs[1]);
+ assert_equals(wp["3"], divs[1]);
+}, "Window prototype: element with id 3 (named access)");
+</script>