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

     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" />
     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>
    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>
    23   <script type="application/javascript">
    24     var gBrowserWnd = null;
    25     var gQueue = null;
    27     function doTest()
    28     {
    29       var rootAcc = getAccessible(browserDocument(), [nsIAccessibleDocument]);
    30       ok(rootAcc.virtualCursor,
    31          "root document does not have virtualCursor");
    33       var doc = currentTabDocument();
    34       var docAcc = getAccessible(doc, [nsIAccessibleDocument]);
    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");
    41       gQueue = new eventQueue();
    43       gQueue.onFinish = function onFinish()
    44       {
    45         closeBrowserWindow();
    46       }
    48       queueTraversalSequence(gQueue, docAcc, HeadersTraversalRule, null,
    49                              ['heading-1-1', 'heading-2-1', 'heading-2-2']);
    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']);
    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]));
    67       gQueue.push(new removeVCPositionInvoker(
    68         docAcc, doc.getElementById('hide-me')));
    70       gQueue.push(new removeVCRootInvoker(
    71         doc.getElementById('links')));
    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'));
    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));
    81       // Attempting a coordinate outside any header, should not move.
    82       gQueue.push(new moveVCCoordInvoker(docAcc, x - 1, y - 1, true,
    83                                          HeadersTraversalRule, false));
    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));
    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. ']);
    95       gQueue.push(new setModalRootInvoker(docAcc, docAcc.parent,
    96                                           NS_ERROR_INVALID_ARG));
    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 "));
   104       gQueue.invoke();
   105     }
   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">
   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