tor-browser

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

browser_src_change.js (2054B)


      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/role.js */
      8 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
      9 
     10 addAccessibleTask(
     11  `<input id="textbox" value="hello"/>`,
     12  async function (browser, iframeDocAcc, contentDocAcc) {
     13    info(
     14      "Check that the IFRAME and the IFRAME document are accessible initially."
     15    );
     16    let iframeAcc = findAccessibleChildByID(contentDocAcc, DEFAULT_IFRAME_ID);
     17    ok(isAccessible(iframeAcc), "IFRAME should be accessible");
     18    ok(isAccessible(iframeDocAcc), "IFRAME document should be accessible");
     19 
     20    info("Replace src URL for the IFRAME with one with different origin.");
     21    const onDocLoad = waitForEvent(
     22      EVENT_DOCUMENT_LOAD_COMPLETE,
     23      DEFAULT_IFRAME_DOC_BODY_ID
     24    );
     25 
     26    await SpecialPowers.spawn(
     27      browser,
     28      [DEFAULT_IFRAME_ID, CURRENT_CONTENT_DIR],
     29      (id, olddir) => {
     30        const { src } = content.document.getElementById(id);
     31        content.document.getElementById(id).src = src.replace(
     32          olddir,
     33          // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     34          "http://example.net/browser/accessible/tests/browser/"
     35        );
     36      }
     37    );
     38    const newiframeDocAcc = (await onDocLoad).accessible;
     39 
     40    ok(isAccessible(iframeAcc), "IFRAME should be accessible");
     41    ok(
     42      isAccessible(newiframeDocAcc),
     43      "new IFRAME document should be accessible"
     44    );
     45    isnot(
     46      iframeDocAcc,
     47      newiframeDocAcc,
     48      "A new accessible is created for a IFRAME document."
     49    );
     50    is(
     51      iframeAcc.firstChild,
     52      newiframeDocAcc,
     53      "An IFRAME has a new accessible for a IFRAME document as a child."
     54    );
     55    is(
     56      newiframeDocAcc.parent,
     57      iframeAcc,
     58      "A new accessible for a IFRAME document has an IFRAME as a parent."
     59    );
     60  },
     61  { topLevel: false, iframe: true, remoteIframe: true }
     62 );