tor-browser

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

browser_test_zoom_text.js (2070B)


      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 /* import-globals-from ../../mochitest/layout.js */
      8 
      9 async function runTests(browser, accDoc) {
     10  async function testTextNode(id) {
     11    let hyperTextNode = findAccessibleChildByID(accDoc, id);
     12    let textNode = hyperTextNode.firstChild;
     13 
     14    let contentDPR = await getContentDPR(browser);
     15    let [x, y, width, height] = getBounds(textNode, contentDPR);
     16    testTextBounds(
     17      hyperTextNode,
     18      0,
     19      -1,
     20      [x, y, width, height],
     21      COORDTYPE_SCREEN_RELATIVE
     22    );
     23  }
     24 
     25  async function testEmptyInputNode(id) {
     26    let inputNode = findAccessibleChildByID(accDoc, id);
     27 
     28    let [x, y, width, height] = getBounds(inputNode);
     29    testTextBounds(
     30      inputNode,
     31      0,
     32      -1,
     33      [x, y, width, height],
     34      COORDTYPE_SCREEN_RELATIVE
     35    );
     36    // A 0 range in an empty input should still return
     37    // rect of input node.
     38    testTextBounds(
     39      inputNode,
     40      0,
     41      0,
     42      [x, y, width, height],
     43      COORDTYPE_SCREEN_RELATIVE
     44    );
     45  }
     46 
     47  await testTextNode("p1");
     48  await testTextNode("p2");
     49  await testEmptyInputNode("i1");
     50 
     51  await SpecialPowers.spawn(browser, [], () => {
     52    const { Layout } = ChromeUtils.importESModule(
     53      "chrome://mochitests/content/browser/accessible/tests/browser/Layout.sys.mjs"
     54    );
     55    Layout.zoomDocument(content.document, 2.0);
     56  });
     57 
     58  await testTextNode("p1");
     59 
     60  await SpecialPowers.spawn(browser, [], () => {
     61    const { Layout } = ChromeUtils.importESModule(
     62      "chrome://mochitests/content/browser/accessible/tests/browser/Layout.sys.mjs"
     63    );
     64    Layout.zoomDocument(content.document, 1.0);
     65  });
     66 }
     67 
     68 /**
     69 * Test the text range boundary when page is zoomed
     70 */
     71 addAccessibleTask(
     72  `
     73  <p id='p1' style='font-family: monospace;'>Tilimilitryamdiya</p>
     74  <p id='p2'>ل</p>
     75  <form><input id='i1' /></form>`,
     76  runTests,
     77  { iframe: true, remoteIframe: true }
     78 );