Backed out changeset db55605b2a4c (relanding bug 121341)
[wine-gecko.git] / accessible / tests / mochitest / test_nsIAccessibleDocument.html
blob88b919855fb8f92e44fe6890ef8043a3ec4651ea
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" />
9 <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
12 <script type="application/javascript">
13 const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
14 const nsIAccessibleRole = Components.interfaces.nsIAccessibleRole;
15 const nsIAccessibleDocument = Components.interfaces.nsIAccessibleDocument;
16 const nsIDOMDocument = Components.interfaces.nsIDOMDocument;
17 const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
19 // needed state flag
20 const state_focusable =
21 Components.interfaces.nsIAccessibleStates.STATE_FOCUSABLE;
22 const state_readonly =
23 Components.interfaces.nsIAccessibleStates.STATE_READONLY;
25 var gAccRetrieval = null;
27 function doTest()
29 gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
30 getService(nsIAccessibleRetrieval);
32 // Get accessible for body tag.
33 var docAcc = null;
34 try {
35 docAcc = gAccRetrieval.getAccessibleFor(document).
36 QueryInterface(nsIAccessibleDocument);
37 } catch(e) {}
38 ok(docAcc, "No accessible with interface for document!");
40 if (docAcc) {
41 // nsIAccessible
42 is(docAcc.name, "nsIAccessibleDocument chrome tests",
43 "Name for document accessible not correct!");
44 is(docAcc.role, nsIAccessibleRole.ROLE_DOCUMENT,
45 "Wrong role for document!");
47 // check if it is focusable, read-only.
48 var state = {}, extraState = {}
49 docAcc.getFinalState(state, extraState);
50 var desiredStates = (state_focusable | state_readonly);
51 is(state.value & desiredStates, desiredStates,
52 "Wrong state bits for document!");
54 // No actions wanted on doc
55 is(docAcc.numActions, 0, "Wrong number of actions for document!");
57 // attributes should contain tag:body
58 attributes = docAcc.attributes;
59 is(attributes.getStringProperty("tag"), "BODY",
60 "Wrong attribute on document!");
62 // nsIAccessibleDocument
63 is(docAcc.URL, "chrome://mochikit/content/a11y/accessible/test_nsIAccessibleDocument.html",
64 "Wrong URL for document!");
65 is(docAcc.title, "nsIAccessibleDocument chrome tests",
66 "Wrong title for document!");
67 is(docAcc.mimeType, "text/html",
68 "Wrong mime type for document!");
69 // nsDocAccessible::getDocType currently returns NS_ERROR_FAILURE.
70 // See bug 442005. After fixing, please remove this comment and
71 // uncomment the below two lines to enable the test.
72 // is(docAcc.docType, "HTML",
73 // "Wrong type of document!");
75 // Test for correct nsIDOMDocument retrieval.
76 var domDoc = null;
77 try {
78 domDoc = docAcc.document.QueryInterface(nsIDOMDocument);
79 } catch(e) {}
80 ok(domDoc, "no nsIDOMDocument for this doc accessible!");
81 is(domDoc, document, "Document nodes do not match!");
83 // Test for correct nsIDOMWindow retrieval.
84 var domWindow = null;
85 try {
86 domWindow = docAcc.window.QueryInterface(nsIDOMWindow);
87 } catch(e) {}
88 ok(domWindow, "no nsIDOMWindow for this doc accessible!");
89 is(domWindow, window, "Window nodes do not match!");
92 SimpleTest.finish();
95 SimpleTest.waitForExplicitFinish();
96 addLoadEvent(doTest);
97 </script>
98 </head>
99 <body>
101 <a target="_blank"
102 href="https://bugzilla.mozilla.org/show_bug.cgi?id=441737"
103 title="nsAccessibleDocument chrome tests">
104 Mozilla Bug 441737
105 </a>
106 <p id="display"></p>
107 <div id="content" style="display: none"></div>
108 <pre id="test">
109 </pre>
110 </body>
111 </html>