accessible/tests/mochitest/pivot/test_virtualcursor.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial