accessible/tests/mochitest/test_nsIAccessibleDocument.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 <html>
michael@0 2 <!--
michael@0 3 https://bugzilla.mozilla.org/show_bug.cgi?id=441737
michael@0 4 -->
michael@0 5 <head>
michael@0 6 <title>nsIAccessibleDocument chrome tests</title>
michael@0 7 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 8
michael@0 9 <script type="application/javascript" 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 src="chrome://mochikit/content/chrome-harness.js"></script>
michael@0 20
michael@0 21 <script type="application/javascript">
michael@0 22 function doTest()
michael@0 23 {
michael@0 24 var docAcc = getAccessible(document, [nsIAccessibleDocument]);
michael@0 25 if (docAcc) {
michael@0 26 // nsIAccessible
michael@0 27 is(docAcc.name, "nsIAccessibleDocument chrome tests",
michael@0 28 "Name for document accessible not correct!");
michael@0 29
michael@0 30 testRole(docAcc, ROLE_DOCUMENT);
michael@0 31
michael@0 32 // check if it is focusable, read-only.
michael@0 33 testStates(docAcc, (STATE_READONLY | STATE_FOCUSABLE));
michael@0 34
michael@0 35 // No actions wanted on doc
michael@0 36 is(docAcc.actionCount, 0, "Wrong number of actions for document!");
michael@0 37
michael@0 38 // attributes should contain tag:body
michael@0 39 attributes = docAcc.attributes;
michael@0 40 is(attributes.getStringProperty("tag"), "body",
michael@0 41 "Wrong attribute on document!");
michael@0 42
michael@0 43 // Document URL.
michael@0 44 var rootDir = getRootDirectory(window.location.href);
michael@0 45 is(docAcc.URL, rootDir + "test_nsIAccessibleDocument.html",
michael@0 46 "Wrong URL for document!");
michael@0 47
michael@0 48 // Document title and mime type.
michael@0 49 is(docAcc.title, "nsIAccessibleDocument chrome tests",
michael@0 50 "Wrong title for document!");
michael@0 51 is(docAcc.mimeType, "text/html",
michael@0 52 "Wrong mime type for document!");
michael@0 53
michael@0 54 // DocAccessible::getDocType currently returns NS_ERROR_FAILURE.
michael@0 55 // See bug 442005. After fixing, please remove this comment and
michael@0 56 // uncomment the below two lines to enable the test.
michael@0 57 // is(docAcc.docType, "HTML",
michael@0 58 // "Wrong type of document!");
michael@0 59
michael@0 60 // Test for correct nsIDOMDocument retrieval.
michael@0 61 var domDoc = null;
michael@0 62 try {
michael@0 63 domDoc = docAcc.DOMDocument.QueryInterface(nsIDOMDocument);
michael@0 64 } catch(e) {}
michael@0 65 ok(domDoc, "no nsIDOMDocument for this doc accessible!");
michael@0 66 is(domDoc, document, "Document nodes do not match!");
michael@0 67
michael@0 68 // Test for correct nsIDOMWindow retrieval.
michael@0 69 var domWindow = null;
michael@0 70 try {
michael@0 71 domWindow = docAcc.window.QueryInterface(nsIDOMWindow);
michael@0 72 } catch(e) {}
michael@0 73 ok(domWindow, "no nsIDOMWindow for this doc accessible!");
michael@0 74 is(domWindow, window, "Window nodes do not match!");
michael@0 75 }
michael@0 76
michael@0 77 SimpleTest.finish();
michael@0 78 }
michael@0 79
michael@0 80 SimpleTest.waitForExplicitFinish();
michael@0 81 addA11yLoadEvent(doTest);
michael@0 82 </script>
michael@0 83 </head>
michael@0 84 <body>
michael@0 85
michael@0 86 <a target="_blank"
michael@0 87 href="https://bugzilla.mozilla.org/show_bug.cgi?id=441737"
michael@0 88 title="nsAccessibleDocument chrome tests">
michael@0 89 Mozilla Bug 441737
michael@0 90 </a>
michael@0 91 <p id="display"></p>
michael@0 92 <div id="content" style="display: none"></div>
michael@0 93 <pre id="test">
michael@0 94 </pre>
michael@0 95 </body>
michael@0 96 </html>

mercurial