accessible/tests/mochitest/tree/test_dochierarchy.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/tree/test_dochierarchy.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test document hierarchy</title>
     1.8 +  <link rel="stylesheet" type="text/css"
     1.9 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.10 +
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +
    1.14 +  <script type="application/javascript"
    1.15 +          src="../common.js"></script>
    1.16 +  <script type="application/javascript"
    1.17 +          src="../role.js"></script>
    1.18 +  <script type="application/javascript"
    1.19 +          src="../states.js"></script>
    1.20 +
    1.21 +  <script type="application/javascript">
    1.22 +  function doTest()
    1.23 +  {
    1.24 +    // tabDoc and testDoc are different documents depending on whether test
    1.25 +    // is running in standalone mode or not.
    1.26 +
    1.27 +    var root = getRootAccessible();
    1.28 +    var tabDoc = window.parent ?
    1.29 +      getAccessible(window.parent.document, [nsIAccessibleDocument]) :
    1.30 +      getAccessible(document, [nsIAccessibleDocument]);
    1.31 +    var testDoc = getAccessible(document, [nsIAccessibleDocument]);
    1.32 +    var iframeDoc = getAccessible("iframe").firstChild.
    1.33 +      QueryInterface(nsIAccessibleDocument);
    1.34 +
    1.35 +    is(root.parentDocument, null,
    1.36 +       "Wrong parent document of root accessible");
    1.37 +    is(root.childDocumentCount, 1,
    1.38 +       "Wrong child document count of root accessible");
    1.39 +    is(root.getChildDocumentAt(0), tabDoc,
    1.40 +       "Wrong child document at index 0 of root accessible");
    1.41 +
    1.42 +    is(tabDoc.parentDocument, root,
    1.43 +       "Wrong parent document of tab document");
    1.44 +    is(tabDoc.childDocumentCount, 1,
    1.45 +       "Wrong child document count of tab document");
    1.46 +    is(tabDoc.getChildDocumentAt(0), (tabDoc == testDoc ? iframeDoc : testDoc),
    1.47 +       "Wrong child document at index 0 of tab document");
    1.48 +
    1.49 +    if (tabDoc != testDoc) {
    1.50 +      is(testDoc.parentDocument, tabDoc,
    1.51 +         "Wrong parent document of test document");
    1.52 +      is(testDoc.childDocumentCount, 1,
    1.53 +         "Wrong child document count of test document");
    1.54 +      is(testDoc.getChildDocumentAt(0), iframeDoc,
    1.55 +         "Wrong child document at index 0 of test document");
    1.56 +    }
    1.57 +
    1.58 +    is(iframeDoc.parentDocument, (tabDoc == testDoc ? tabDoc : testDoc),
    1.59 +       "Wrong parent document of iframe document");
    1.60 +    is(iframeDoc.childDocumentCount, 0,
    1.61 +       "Wrong child document count of iframe document");
    1.62 +
    1.63 +    SimpleTest.finish();
    1.64 +  }
    1.65 +
    1.66 +  SimpleTest.waitForExplicitFinish();
    1.67 +  addA11yLoadEvent(doTest);
    1.68 +  </script>
    1.69 +</head>
    1.70 +
    1.71 +<body>
    1.72 +  <a target="_blank"
    1.73 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=592913"
    1.74 +     title="Provide a way to quickly determine whether an accessible object is a descendant of a tab document">
    1.75 +    Mozilla Bug 592913
    1.76 +  </a>
    1.77 +  <p id="display"></p>
    1.78 +  <div id="content" style="display: none"></div>
    1.79 +  <pre id="test">
    1.80 +  </pre>
    1.81 +
    1.82 +  <iframe src="about:mozilla" id="iframe"></iframe>
    1.83 +</body>
    1.84 +</html>

mercurial