accessible/tests/mochitest/pivot/test_virtualcursor.html

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:4fcf1d5c5c62
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Tests pivot functionality in virtual cursors</title>
5 <meta charset="utf-8" />
6 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
7
8 <script type="application/javascript"
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js">
10 </script>
11 <script type="application/javascript"
12 src="chrome://mochikit/content/chrome-harness.js">
13 </script>
14
15 <script type="application/javascript" src="../common.js"></script>
16 <script type="application/javascript" src="../browser.js"></script>
17 <script type="application/javascript" src="../events.js"></script>
18 <script type="application/javascript" src="../role.js"></script>
19 <script type="application/javascript" src="../states.js"></script>
20 <script type="application/javascript" src="../pivot.js"></script>
21 <script type="application/javascript" src="../layout.js"></script>
22
23 <script type="application/javascript">
24 var gBrowserWnd = null;
25 var gQueue = null;
26
27 function doTest()
28 {
29 var rootAcc = getAccessible(browserDocument(), [nsIAccessibleDocument]);
30 ok(rootAcc.virtualCursor,
31 "root document does not have virtualCursor");
32
33 var doc = currentTabDocument();
34 var docAcc = getAccessible(doc, [nsIAccessibleDocument]);
35
36 // Test that embedded documents have their own virtual cursor.
37 is(docAcc.childDocumentCount, 1, "Expecting one child document");
38 ok(docAcc.getChildDocumentAt(0).virtualCursor,
39 "child document does not have virtualCursor");
40
41 gQueue = new eventQueue();
42
43 gQueue.onFinish = function onFinish()
44 {
45 closeBrowserWindow();
46 }
47
48 queueTraversalSequence(gQueue, docAcc, HeadersTraversalRule, null,
49 ['heading-1-1', 'heading-2-1', 'heading-2-2']);
50
51 queueTraversalSequence(
52 gQueue, docAcc, ObjectTraversalRule, null,
53 ['Main Title', 'Lorem ipsum ',
54 'dolor', ' sit amet. Integer vitae urna leo, id ',
55 'semper', ' nulla. ', 'Second Section Title',
56 'Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.',
57 'An ', 'embedded', ' document.', 'Hide me', 'Link 1', 'Link 2',
58 'Link 3', 'Hello', 'World']);
59
60 // Just a random smoke test to see if our setTextRange works.
61 gQueue.push(
62 new setVCRangeInvoker(
63 docAcc,
64 getAccessible(doc.getElementById('paragraph-2'), nsIAccessibleText),
65 [2,6]));
66
67 gQueue.push(new removeVCPositionInvoker(
68 docAcc, doc.getElementById('hide-me')));
69
70 gQueue.push(new removeVCRootInvoker(
71 doc.getElementById('links')));
72
73 var [x, y] = getBounds(getAccessible(doc.getElementById('heading-1-1')));
74 gQueue.push(new moveVCCoordInvoker(docAcc, x + 1, y + 1, true,
75 HeadersTraversalRule, 'heading-1-1'));
76
77 // Already on the point, so we should not get a move event.
78 gQueue.push(new moveVCCoordInvoker(docAcc, x + 1, y + 1, true,
79 HeadersTraversalRule, false));
80
81 // Attempting a coordinate outside any header, should not move.
82 gQueue.push(new moveVCCoordInvoker(docAcc, x - 1, y - 1, true,
83 HeadersTraversalRule, false));
84
85 // Attempting a coordinate outside any header, should move to null
86 gQueue.push(new moveVCCoordInvoker(docAcc, x - 1, y - 1, false,
87 HeadersTraversalRule, null));
88
89 queueTraversalSequence(
90 gQueue, docAcc, ObjectTraversalRule,
91 getAccessible(doc.getElementById('paragraph-1')),
92 ['Lorem ipsum ', 'dolor', ' sit amet. Integer vitae urna leo, id ',
93 'semper', ' nulla. ']);
94
95 gQueue.push(new setModalRootInvoker(docAcc, docAcc.parent,
96 NS_ERROR_INVALID_ARG));
97
98 // Put cursor in an ignored subtree
99 gQueue.push(new setVCPosInvoker(docAcc, null, null,
100 getAccessible(doc.getElementById("hidden-link"))));
101 // Next item shoud be outside of that subtree
102 gQueue.push(new setVCPosInvoker(docAcc, "moveNext", ObjectTraversalRule, "An "));
103
104 gQueue.invoke();
105 }
106
107 SimpleTest.waitForExplicitFinish();
108 addLoadEvent(function () {
109 /* We open a new browser because we need to test with a top-level content
110 document. */
111 openBrowserWindow(
112 doTest,
113 getRootDirectory(window.location.href) + "doc_virtualcursor.html");
114 });
115 </script>
116 </head>
117 <body id="body">
118
119 <a target="_blank"
120 title="Introduce virtual cursor/soft focus functionality to a11y API"
121 href="https://bugzilla.mozilla.org/show_bug.cgi?id=698823">Mozilla Bug 698823</a>
122 <p id="display"></p>
123 <div id="content" style="display: none"></div>
124 <pre id="test">
125 </pre>
126 </body>
127 </html>

mercurial