Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/browsers/the-window-object/named-access-on-the-window-object/multi-match.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Named access on the window object - Multiple matches</title>
<link rel="author" title="Matthew Phillips" href="mailto:matthew@matthewphillips.info">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
test(() => {
const img1 = document.createElement("img");
img1.setAttribute("name", "foo");
document.body.appendChild(img1);
const img0 = document.createElement("img");
img0.setAttribute("name", "foo");
document.body.insertBefore(img0, img1);
const div = document.createElement("div");
div.setAttribute("id", "foo");
document.body.appendChild(div);
assert_true(window.foo instanceof window.HTMLCollection);
assert_equals(window.foo.length, 3);
assert_true(window.foo[0] === img0);
assert_true(window.foo[1] === img1);
assert_true(window.foo[2] === div);
}, "A named property must return a HTMLCollection if there are multiple matches");
</script>