tor-browser

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

browser_test_shadowroot.js (1657B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 async function runTests(browser, accDoc) {
      8  const dpr = await getContentDPR(browser);
      9  let componentAcc = findAccessibleChildByID(accDoc, "component1");
     10  await testChildAtPoint(
     11    dpr,
     12    1,
     13    1,
     14    componentAcc,
     15    componentAcc.firstChild,
     16    componentAcc.firstChild
     17  );
     18 
     19  componentAcc = findAccessibleChildByID(accDoc, "component2");
     20  await testChildAtPoint(
     21    dpr,
     22    1,
     23    1,
     24    componentAcc,
     25    componentAcc.firstChild,
     26    componentAcc.firstChild
     27  );
     28 }
     29 
     30 addAccessibleTask(
     31  `
     32  <div role="group" class="components" id="component1" style="display: inline-block;">
     33  <!--
     34    <div role="button" id="component-child"
     35         style="width: 100px; height: 100px; background-color: pink;">
     36    </div>
     37  -->
     38  </div>
     39  <div role="group" class="components"  id="component2" style="display: inline-block;">
     40  <!--
     41    <button>Hello world</button>
     42  -->
     43  </div>
     44  <script>
     45    // This routine adds the comment children of each 'component' to its
     46    // shadow root.
     47    var components = document.querySelectorAll(".components");
     48    for (var i = 0; i < components.length; i++) {
     49      var component = components[i];
     50      var shadow = component.attachShadow({mode: "open"});
     51      for (var child = component.firstChild; child; child = child.nextSibling) {
     52        if (child.nodeType === 8)
     53          shadow.innerHTML = child.data;
     54      }
     55    }
     56  </script>
     57  `,
     58  runTests,
     59  { iframe: true, remoteIframe: true }
     60 );