tor-browser

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

test_docload_root.html (3639B)


      1 <html>
      2 
      3 <head>
      4  <title>Accessible events testing for document</title>
      5 
      6  <link rel="stylesheet" type="text/css"
      7        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
      8 
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     10 
     11  <script type="application/javascript"
     12          src="../../common.js"></script>
     13  <script type="application/javascript"
     14          src="../../role.js"></script>
     15  <script type="application/javascript"
     16          src="../../events.js"></script>
     17 
     18  <script type="application/javascript">
     19    // //////////////////////////////////////////////////////////////////////////
     20    // Invokers
     21 
     22    let gDialog;
     23    let gDialogDoc;
     24    let gRootAcc;
     25 
     26    function openDialogWnd(aURL) {
     27      // Get application root accessible.
     28      let docAcc = getAccessible(document);
     29      while (docAcc) {
     30        gRootAcc = docAcc;
     31        try {
     32          docAcc = docAcc.parent;
     33        } catch (e) {
     34          ok(false, `Can't get parent for ${prettyName(docAcc)}`);
     35          throw e;
     36        }
     37      }
     38 
     39      this.eventSeq = [
     40        new asyncInvokerChecker(EVENT_REORDER, gRootAcc),
     41        // We use a function here to get the target because gDialog isn't set
     42        // yet, but it will be when the function is called.
     43        new invokerChecker(EVENT_FOCUS, () => gDialog.document)
     44      ];
     45 
     46      this.invoke = () => (gDialog = window.browsingContext.topChromeWindow.openDialog(aURL));
     47 
     48      this.finalCheck = () => {
     49        const accTree = {
     50          role: ROLE_APP_ROOT,
     51          children: [
     52            {
     53              role: ROLE_CHROME_WINDOW,
     54            },
     55            {
     56              role: ROLE_CHROME_WINDOW,
     57            },
     58          ],
     59        };
     60 
     61        testAccessibleTree(gRootAcc, accTree);
     62 
     63        gDialogDoc = gDialog.document;
     64        ok(isAccessibleInCache(gDialogDoc),
     65          `The document accessible for '${aURL}' is not in cache!`);
     66      };
     67 
     68      this.getID = () => `open dialog '${aURL}'`;
     69    }
     70 
     71    function closeDialogWnd() {
     72      this.eventSeq = [ new invokerChecker(EVENT_FOCUS, getAccessible(document)) ];
     73 
     74      this.invoke = () => {
     75        gDialog.close();
     76        window.focus();
     77      };
     78 
     79      this.finalCheck = () => {
     80        ok(!isAccessibleInCache(gDialogDoc),
     81          `The document accessible for dialog is in cache still!`);
     82 
     83        gDialog = gDialogDoc = gRootAcc = null;
     84      };
     85 
     86      this.getID = () => "close dialog";
     87    }
     88 
     89    // //////////////////////////////////////////////////////////////////////////
     90    // Do tests
     91 
     92    function doTests() {
     93      if (Services.appShell.hasHiddenWindow) {
     94        // Front end stuff sometimes likes to stuff things in the hidden window(s)
     95        // in which case we should repress all accessibles for those.
     96 
     97        // Try to create an accessible for the hidden window's document.
     98        let doc = Services.appShell.hiddenDOMWindow.document;
     99        let hiddenDocAcc = gAccService.getAccessibleFor(doc);
    100        ok(!hiddenDocAcc, "hiddenDOMWindow should not have an accessible.");
    101      }
    102 
    103      const gQueue = new eventQueue();
    104      gQueue.push(new openDialogWnd("about:about"));
    105      gQueue.push(new closeDialogWnd());
    106      gQueue.invoke(); // Will call SimpleTest.finish();
    107    }
    108 
    109    SimpleTest.waitForExplicitFinish();
    110    addA11yLoadEvent(doTests);
    111  </script>
    112 </head>
    113 
    114 <body>
    115 
    116  <a target="_blank"
    117     href="https://bugzilla.mozilla.org/show_bug.cgi?id=506206"
    118     title="Fire event_reorder application root accessible">
    119    Mozilla Bug 506206
    120  </a>
    121 
    122  <p id="display"></p>
    123  <div id="content" style="display: none"></div>
    124  <pre id="test">
    125  </pre>
    126 </body>
    127 </html>