tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

window-indexed-access-vs-named-access.html (2700B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Interactions between indexed and named access on the Window object</title>
      4 <link rel="author" title="Delan Azabani" href="dazabani@igalia.com">
      5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts">
      6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#named-access-on-the-window-object">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <div id=0></div>
     10 <div id=4></div>
     11 <iframe name=3></iframe>
     12 <iframe name=2></iframe>
     13 <iframe name=1></iframe>
     14 <script>
     15 const divs = document.querySelectorAll("div");
     16 const iframes = document.querySelectorAll("iframe");
     17 const wp = Object.getPrototypeOf(window);
     18 test(function() {
     19    assert_equals(window[0], iframes[0].contentWindow);
     20    assert_equals(window["0"], iframes[0].contentWindow);
     21 }, "WindowProxy: document-tree child navigable with index 0 (indexed access)");
     22 test(function() {
     23    assert_equals(window[1], iframes[1].contentWindow);
     24    assert_equals(window["1"], iframes[1].contentWindow);
     25 }, "WindowProxy: document-tree child navigable with index 1 (indexed access)");
     26 test(function() {
     27    assert_equals(window[2], iframes[2].contentWindow);
     28    assert_equals(window["2"], iframes[2].contentWindow);
     29 }, "WindowProxy: document-tree child navigable with index 2 (indexed access)");
     30 test(function() {
     31    assert_equals(window[3], iframes[0].contentWindow);
     32    assert_equals(window["3"], iframes[0].contentWindow);
     33 }, "WindowProxy: document-tree child navigable with target name 3 (named access)");
     34 test(function() {
     35    assert_equals(window[4], divs[1]);
     36    assert_equals(window["4"], divs[1]);
     37 }, "WindowProxy: element with id 4 (named access)");
     38 test(function() {
     39    assert_equals(wp[0], divs[0]);
     40    assert_equals(wp["0"], divs[0]);
     41 }, "Window prototype: element with id 0 (named access)");
     42 test(function() {
     43    assert_equals(wp[1], iframes[2].contentWindow);
     44    assert_equals(wp["1"], iframes[2].contentWindow);
     45 }, "Window prototype: document-tree child navigable with target name 1 (named access)");
     46 test(function() {
     47    assert_equals(wp[2], iframes[1].contentWindow);
     48    assert_equals(wp["2"], iframes[1].contentWindow);
     49 }, "Window prototype: document-tree child navigable with target name 2 (named access)");
     50 test(function() {
     51    assert_equals(wp[3], iframes[0].contentWindow);
     52    assert_equals(wp["3"], iframes[0].contentWindow);
     53 }, "Window prototype: document-tree child navigable with target name 3 (named access)");
     54 test(function() {
     55    assert_equals(wp[4], divs[1]);
     56    assert_equals(wp["4"], divs[1]);
     57 }, "Window prototype: element with id 4 (named access)");
     58 </script>