tor-browser

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

test_nsIAccessibleDocument.html (3062B)


      1 <html>
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=441737
      4 -->
      5 <head>
      6  <title>nsIAccessibleDocument chrome tests</title>
      7  <link rel="stylesheet" type="text/css" 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="states.js"></script>
     17 
     18  <script src="chrome://mochikit/content/chrome-harness.js"></script>
     19 
     20  <script type="application/javascript">
     21    function doTest() {
     22      var docAcc = getAccessible(document, [nsIAccessibleDocument]);
     23      if (docAcc) {
     24        // nsIAccessible
     25        is(docAcc.name, "nsIAccessibleDocument chrome tests",
     26           "Name for document accessible not correct!");
     27 
     28        testRole(docAcc, ROLE_DOCUMENT);
     29 
     30        // check if it is focusable, read-only.
     31        testStates(docAcc, (STATE_READONLY | STATE_FOCUSABLE));
     32 
     33        // No actions wanted on doc
     34        is(docAcc.actionCount, 0, "Wrong number of actions for document!");
     35 
     36        // attributes should contain tag:body
     37        const attributes = docAcc.attributes;
     38        is(attributes.getStringProperty("tag"), "body",
     39           "Wrong attribute on document!");
     40 
     41        // Document URL.
     42        var rootDir = getRootDirectory(window.location.href);
     43        is(docAcc.URL, rootDir + "test_nsIAccessibleDocument.html",
     44           "Wrong URL for document!");
     45 
     46        // Document title and mime type.
     47        is(docAcc.title, "nsIAccessibleDocument chrome tests",
     48           "Wrong title for document!");
     49        is(docAcc.mimeType, "text/html",
     50           "Wrong mime type for document!");
     51 
     52        // DocAccessible::getDocType currently returns NS_ERROR_FAILURE.
     53        // See bug 442005. After fixing, please remove this comment and
     54        // uncomment the below two lines to enable the test.
     55 //        is(docAcc.docType, "HTML",
     56 //           "Wrong type of document!");
     57 
     58        // Test for correct Document retrieval.
     59        var domDoc = null;
     60        try {
     61          domDoc = docAcc.DOMDocument;
     62        } catch (e) {}
     63        ok(domDoc, "no Document for this doc accessible!");
     64        is(domDoc, document, "Document nodes do not match!");
     65 
     66        // Test for correct nsIDOMWindow retrieval.
     67        var domWindow = null;
     68        try {
     69          domWindow = docAcc.window;
     70        } catch (e) {}
     71        ok(domWindow, "no nsIDOMWindow for this doc accessible!");
     72        is(domWindow, window, "Window nodes do not match!");
     73      }
     74 
     75      SimpleTest.finish();
     76    }
     77 
     78    SimpleTest.waitForExplicitFinish();
     79    addA11yLoadEvent(doTest);
     80  </script>
     81 </head>
     82 <body>
     83 
     84  <a target="_blank"
     85     href="https://bugzilla.mozilla.org/show_bug.cgi?id=441737"
     86     title="nsAccessibleDocument chrome tests">
     87    Mozilla Bug 441737
     88  </a>
     89  <p id="display"></p>
     90  <div id="content" style="display: none"></div>
     91  <pre id="test">
     92  </pre>
     93 </body>
     94 </html>