accessible/tests/mochitest/tree/test_dochierarchy.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE html>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test document hierarchy</title>
michael@0 5 <link rel="stylesheet" type="text/css"
michael@0 6 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 7
michael@0 8 <script type="application/javascript"
michael@0 9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10
michael@0 11 <script type="application/javascript"
michael@0 12 src="../common.js"></script>
michael@0 13 <script type="application/javascript"
michael@0 14 src="../role.js"></script>
michael@0 15 <script type="application/javascript"
michael@0 16 src="../states.js"></script>
michael@0 17
michael@0 18 <script type="application/javascript">
michael@0 19 function doTest()
michael@0 20 {
michael@0 21 // tabDoc and testDoc are different documents depending on whether test
michael@0 22 // is running in standalone mode or not.
michael@0 23
michael@0 24 var root = getRootAccessible();
michael@0 25 var tabDoc = window.parent ?
michael@0 26 getAccessible(window.parent.document, [nsIAccessibleDocument]) :
michael@0 27 getAccessible(document, [nsIAccessibleDocument]);
michael@0 28 var testDoc = getAccessible(document, [nsIAccessibleDocument]);
michael@0 29 var iframeDoc = getAccessible("iframe").firstChild.
michael@0 30 QueryInterface(nsIAccessibleDocument);
michael@0 31
michael@0 32 is(root.parentDocument, null,
michael@0 33 "Wrong parent document of root accessible");
michael@0 34 is(root.childDocumentCount, 1,
michael@0 35 "Wrong child document count of root accessible");
michael@0 36 is(root.getChildDocumentAt(0), tabDoc,
michael@0 37 "Wrong child document at index 0 of root accessible");
michael@0 38
michael@0 39 is(tabDoc.parentDocument, root,
michael@0 40 "Wrong parent document of tab document");
michael@0 41 is(tabDoc.childDocumentCount, 1,
michael@0 42 "Wrong child document count of tab document");
michael@0 43 is(tabDoc.getChildDocumentAt(0), (tabDoc == testDoc ? iframeDoc : testDoc),
michael@0 44 "Wrong child document at index 0 of tab document");
michael@0 45
michael@0 46 if (tabDoc != testDoc) {
michael@0 47 is(testDoc.parentDocument, tabDoc,
michael@0 48 "Wrong parent document of test document");
michael@0 49 is(testDoc.childDocumentCount, 1,
michael@0 50 "Wrong child document count of test document");
michael@0 51 is(testDoc.getChildDocumentAt(0), iframeDoc,
michael@0 52 "Wrong child document at index 0 of test document");
michael@0 53 }
michael@0 54
michael@0 55 is(iframeDoc.parentDocument, (tabDoc == testDoc ? tabDoc : testDoc),
michael@0 56 "Wrong parent document of iframe document");
michael@0 57 is(iframeDoc.childDocumentCount, 0,
michael@0 58 "Wrong child document count of iframe document");
michael@0 59
michael@0 60 SimpleTest.finish();
michael@0 61 }
michael@0 62
michael@0 63 SimpleTest.waitForExplicitFinish();
michael@0 64 addA11yLoadEvent(doTest);
michael@0 65 </script>
michael@0 66 </head>
michael@0 67
michael@0 68 <body>
michael@0 69 <a target="_blank"
michael@0 70 href="https://bugzilla.mozilla.org/show_bug.cgi?id=592913"
michael@0 71 title="Provide a way to quickly determine whether an accessible object is a descendant of a tab document">
michael@0 72 Mozilla Bug 592913
michael@0 73 </a>
michael@0 74 <p id="display"></p>
michael@0 75 <div id="content" style="display: none"></div>
michael@0 76 <pre id="test">
michael@0 77 </pre>
michael@0 78
michael@0 79 <iframe src="about:mozilla" id="iframe"></iframe>
michael@0 80 </body>
michael@0 81 </html>

mercurial