tor-browser

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

browser_content_prompt.js (1874B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Want to test relations.
      7 /* import-globals-from ../../mochitest/name.js */
      8 /* import-globals-from ../../mochitest/relations.js */
      9 /* import-globals-from ../../mochitest/role.js */
     10 loadScripts(
     11  { name: "relations.js", dir: MOCHITESTS_DIR },
     12  { name: "name.js", dir: MOCHITESTS_DIR },
     13  { name: "role.js", dir: MOCHITESTS_DIR }
     14 );
     15 
     16 addAccessibleTask(``, async function (browser) {
     17  info("Showing alert");
     18  let shown = waitForEvent(
     19    EVENT_SHOW,
     20    evt => evt.accessible.role == ROLE_INTERNAL_FRAME
     21  );
     22  // Let's make sure the dialog content gets focus.
     23  // On macOS, we unfortunately focus the label. We focus the OK button on
     24  // all other platforms. See https://phabricator.services.mozilla.com/D204908
     25  // for more discussion.
     26  let expectedRole =
     27    AppConstants.platform == "macosx" ? ROLE_LABEL : ROLE_PUSHBUTTON;
     28  let focused = waitForEvent(EVENT_FOCUS, evt => {
     29    return evt.accessible.role == expectedRole;
     30  });
     31  await invokeContentTask(browser, [], () => {
     32    // Use setTimeout to avoid blocking the return of the content task
     33    // on the alert, which is otherwise synchronous.
     34    content.setTimeout(() => content.alert("test"), 0);
     35  });
     36  const frame = (await shown).accessible;
     37  const focusedEl = (await focused).accessible;
     38  ok(true, "Dialog shown and something got focused");
     39  let dialog = getAccessible(focusedEl.DOMNode.ownerDocument);
     40  testRole(dialog, ROLE_DIALOG);
     41  let infoBody = focusedEl.DOMNode.ownerDocument.getElementById("infoBody");
     42  testRelation(dialog, RELATION_DESCRIBED_BY, infoBody);
     43  testDescr(dialog, "test  ");
     44  info("Dismissing alert");
     45  let hidden = waitForEvent(EVENT_HIDE, frame);
     46  EventUtils.synthesizeKey("KEY_Escape", {}, frame.DOMNode.contentWindow);
     47  await hidden;
     48 });