tor-browser

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

browser_reframe_root.js (3270B)


      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/states.js */
      8 /* import-globals-from ../../mochitest/role.js */
      9 loadScripts(
     10  { name: "role.js", dir: MOCHITESTS_DIR },
     11  { name: "states.js", dir: MOCHITESTS_DIR }
     12 );
     13 
     14 addAccessibleTask(
     15  `<input id="textbox" value="hello"/>`,
     16  async function (browser, iframeDocAcc, contentDocAcc) {
     17    info(
     18      "Check that the IFRAME and the IFRAME document are accessible initially."
     19    );
     20    let iframeAcc = findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_ID);
     21    ok(!isDefunct(iframeAcc), "IFRAME should be accessible");
     22    ok(!isDefunct(iframeDocAcc), "IFRAME document should be accessible");
     23 
     24    info("Move the IFRAME under a new hidden root.");
     25    let onEvents = waitForEvent(EVENT_REORDER, contentDocAcc);
     26    await SpecialPowers.spawn(browser, [DEFAULT_IFRAME_ID], id => {
     27      const doc = content.document;
     28      const root = doc.createElement("div");
     29      root.style.display = "none";
     30      doc.body.appendChild(root);
     31      root.appendChild(doc.getElementById(id));
     32    });
     33    await onEvents;
     34 
     35    ok(
     36      isDefunct(iframeAcc),
     37      "IFRAME accessible should be defunct when hidden."
     38    );
     39    ok(
     40      isDefunct(iframeDocAcc),
     41      "IFRAME document's accessible should be defunct when the IFRAME is hidden."
     42    );
     43    ok(
     44      !findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_ID),
     45      "No accessible for an IFRAME present."
     46    );
     47    ok(
     48      !findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_DOC_BODY_ID),
     49      "No accessible for the IFRAME document present."
     50    );
     51 
     52    info("Move the IFRAME back under the content document's body.");
     53    onEvents = waitForEvents([
     54      [EVENT_REORDER, contentDocAcc],
     55      [
     56        EVENT_STATE_CHANGE,
     57        event => {
     58          const scEvent = event.QueryInterface(nsIAccessibleStateChangeEvent);
     59          const id = getAccessibleDOMNodeID(event.accessible);
     60          return (
     61            id === DEFAULT_IFRAME_DOC_BODY_ID &&
     62            scEvent.state === STATE_BUSY &&
     63            scEvent.isEnabled === false
     64          );
     65        },
     66      ],
     67    ]);
     68    await SpecialPowers.spawn(browser, [DEFAULT_IFRAME_ID], id => {
     69      content.document.body.appendChild(content.document.getElementById(id));
     70    });
     71    await onEvents;
     72 
     73    iframeAcc = findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_ID);
     74    const newiframeDocAcc = iframeAcc.firstChild;
     75 
     76    ok(!isDefunct(iframeAcc), "IFRAME should be accessible");
     77    is(iframeAcc.childCount, 1, "IFRAME accessible should have a single child");
     78    ok(!isDefunct(newiframeDocAcc), "IFRAME document should be accessible");
     79    ok(
     80      isDefunct(iframeDocAcc),
     81      "Original IFRAME document accessible should be defunct."
     82    );
     83    isnot(
     84      iframeAcc.firstChild,
     85      iframeDocAcc,
     86      "A new accessible is created for a IFRAME document."
     87    );
     88    is(
     89      iframeAcc.firstChild,
     90      newiframeDocAcc,
     91      "A new accessible for a IFRAME document is the child of the IFRAME accessible"
     92    );
     93  },
     94  { topLevel: false, iframe: true, remoteIframe: true }
     95 );