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