tor-browser

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

browser_test_browser.js (1867B)


      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  // Hit testing. See bug #726097
      9  await invokeContentTask(browser, [], () =>
     10    content.document.getElementById("hittest").scrollIntoView(true)
     11  );
     12 
     13  const dpr = await getContentDPR(browser);
     14  const hititem = findAccessibleChildByID(accDoc, "hititem");
     15  const hittest = findAccessibleChildByID(accDoc, "hittest");
     16  const outerDocAcc = accDoc.parent;
     17  const rootAcc = CommonUtils.getRootAccessible(document);
     18 
     19  const [hitX, hitY, hitWidth, hitHeight] = Layout.getBounds(hititem, dpr);
     20  // "hititem" node has the full screen width, so when we divide it by 2, we are
     21  // still way outside the inline content.
     22  const tgtX = hitX + hitWidth / 2;
     23  const tgtY = hitY + hitHeight / 2;
     24 
     25  let hitAcc = rootAcc.getDeepestChildAtPoint(tgtX, tgtY);
     26  is(
     27    hitAcc,
     28    hititem,
     29    `Hit match at ${tgtX},${tgtY} (root doc deepest child). Found: ${prettyName(
     30      hitAcc
     31    )}`
     32  );
     33 
     34  const hitAcc2 = accDoc.getDeepestChildAtPoint(tgtX, tgtY);
     35  is(
     36    hitAcc,
     37    hitAcc2,
     38    `Hit match at ${tgtX},${tgtY} (doc deepest child). Found: ${prettyName(
     39      hitAcc2
     40    )}`
     41  );
     42 
     43  hitAcc = outerDocAcc.getChildAtPoint(tgtX, tgtY);
     44  is(
     45    hitAcc,
     46    accDoc,
     47    `Hit match at ${tgtX},${tgtY} (outer doc child). Found: ${prettyName(
     48      hitAcc
     49    )}`
     50  );
     51 
     52  hitAcc = accDoc.getChildAtPoint(tgtX, tgtY);
     53  is(
     54    hitAcc,
     55    hittest,
     56    `Hit match at ${tgtX},${tgtY} (doc child). Found: ${prettyName(hitAcc)}`
     57  );
     58 }
     59 
     60 addAccessibleTask(
     61  `
     62  <div id="hittest">
     63    <div id="hititem"><span role="img">img</span>item</div>
     64  </div>
     65 `,
     66  runTests,
     67  { iframe: true, remoteIframe: true }
     68 );