tor-browser

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

browser_accessible_moved.js (1854B)


      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 function assertBoundsNonZero(acc) {
      8  // XXX We don't use getBounds because it uses BoundsInCSSPixels(), but that
      9  // isn't implemented for the cache yet.
     10  let x = {};
     11  let y = {};
     12  let width = {};
     13  let height = {};
     14  acc.getBounds(x, y, width, height);
     15  Assert.greater(x.value, 0, "x is non-0");
     16  Assert.greater(y.value, 0, "y is non-0");
     17  Assert.greater(width.value, 0, "width is non-0");
     18  Assert.greater(height.value, 0, "height is non-0");
     19 }
     20 
     21 /**
     22 * Test that bounds aren't 0 after an Accessible is moved (but not re-created).
     23 */
     24 addAccessibleTask(
     25  `
     26 <div id="root" role="group"><div id="scrollable" role="presentation" style="height: 1px;"><button id="button">test</button></div></div>
     27  `,
     28  async function (browser, docAcc) {
     29    let button = findAccessibleChildByID(docAcc, "button");
     30    assertBoundsNonZero(button);
     31 
     32    const root = findAccessibleChildByID(docAcc, "root");
     33    let reordered = waitForEvent(EVENT_REORDER, root);
     34    // scrollable wasn't in the a11y tree, but this will force it to be created.
     35    // button will be moved inside it.
     36    await invokeContentTask(browser, [], () => {
     37      content.document.getElementById("scrollable").style.overflow = "scroll";
     38    });
     39    await reordered;
     40 
     41    const scrollable = findAccessibleChildByID(docAcc, "scrollable");
     42    assertBoundsNonZero(scrollable);
     43    // XXX button's RemoteAccessible was recreated, so we have to fetch it
     44    // again. This shouldn't be necessary once bug 1739050 is fixed.
     45    button = findAccessibleChildByID(docAcc, "button");
     46    assertBoundsNonZero(button);
     47  },
     48  { topLevel: true, iframe: true, remoteIframe: true }
     49 );