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