3 https://bugzilla.mozilla.org/show_bug.cgi?id=441737
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;
20 const state_focusable =
21 Components.interfaces.nsIAccessibleStates.STATE_FOCUSABLE;
22 const state_readonly =
23 Components.interfaces.nsIAccessibleStates.STATE_READONLY;
25 var gAccRetrieval = null;
29 gAccRetrieval = Components.classes[
"@mozilla.org/accessibleRetrieval;1"].
30 getService(nsIAccessibleRetrieval);
32 // Get accessible for body tag.
35 docAcc = gAccRetrieval.getAccessibleFor(document).
36 QueryInterface(nsIAccessibleDocument);
38 ok(docAcc,
"No accessible with interface for document!");
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.
78 domDoc = docAcc.document.QueryInterface(nsIDOMDocument);
80 ok(domDoc,
"no nsIDOMDocument for this doc accessible!");
81 is(domDoc, document,
"Document nodes do not match!");
83 // Test for correct nsIDOMWindow retrieval.
86 domWindow = docAcc.window.QueryInterface(nsIDOMWindow);
88 ok(domWindow,
"no nsIDOMWindow for this doc accessible!");
89 is(domWindow, window,
"Window nodes do not match!");
95 SimpleTest.waitForExplicitFinish();
102 href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=441737"
103 title=
"nsAccessibleDocument chrome tests">
107 <div id=
"content" style=
"display: none"></div>