tor-browser

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

tabindex-getter-frame.html (1821B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML Test: tabIndex getter return value for frames</title>
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <!-- <frame> elements are harder to test than the rest so they get their own file -->
      9 
     10 <body>
     11 
     12 <script>
     13 "use strict";
     14 test(() => {
     15  const frame = document.createElement("frame");
     16  assert_equals(frame.tabIndex, 0);
     17 }, "disconnected frame element .tabIndex should return 0 by default");
     18 
     19 for (const setValue of [-1, 0, 1]) {
     20  test(() => {
     21    const frame = document.createElement("frame");
     22    frame.setAttribute("tabindex", setValue);
     23    assert_equals(frame.tabIndex, setValue);
     24  }, `disconnected frame element .tabIndex should return ${setValue} when set to ${setValue}`);
     25 }
     26 
     27 promise_test(async t => {
     28  const frame = await getFrame(t);
     29  assert_equals(frame.tabIndex, 0);
     30 }, "connected frame element inside frameset .tabIndex should return 0 by default");
     31 
     32 for (const setValue of [-1, 0, 1]) {
     33  promise_test(async t => {
     34    const frame = await getFrame(t);
     35    frame.setAttribute("tabindex", setValue);
     36    assert_equals(frame.tabIndex, setValue);
     37  }, `connected frame element inside frameset .tabIndex should return ${setValue} when set to ${setValue}`);
     38 }
     39 
     40 
     41 function getFrame(t) {
     42  return new Promise((resolve, reject) => {
     43    const iframe = document.createElement("iframe");
     44    t.add_cleanup(() => iframe.remove());
     45 
     46    iframe.src = "resources/frameset-using-page.html";
     47    iframe.onload = () => {
     48      resolve(iframe.contentDocument.querySelector("frame"));
     49    };
     50    iframe.onerror = () => reject(new Error("Could not load frameset page"));
     51 
     52    document.body.append(iframe);
     53  });
     54 }
     55 </script>