1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/pivot/test_virtualcursor.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,127 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<head> 1.7 + <title>Tests pivot functionality in virtual cursors</title> 1.8 + <meta charset="utf-8" /> 1.9 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.10 + 1.11 + <script type="application/javascript" 1.12 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"> 1.13 + </script> 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/chrome-harness.js"> 1.16 + </script> 1.17 + 1.18 + <script type="application/javascript" src="../common.js"></script> 1.19 + <script type="application/javascript" src="../browser.js"></script> 1.20 + <script type="application/javascript" src="../events.js"></script> 1.21 + <script type="application/javascript" src="../role.js"></script> 1.22 + <script type="application/javascript" src="../states.js"></script> 1.23 + <script type="application/javascript" src="../pivot.js"></script> 1.24 + <script type="application/javascript" src="../layout.js"></script> 1.25 + 1.26 + <script type="application/javascript"> 1.27 + var gBrowserWnd = null; 1.28 + var gQueue = null; 1.29 + 1.30 + function doTest() 1.31 + { 1.32 + var rootAcc = getAccessible(browserDocument(), [nsIAccessibleDocument]); 1.33 + ok(rootAcc.virtualCursor, 1.34 + "root document does not have virtualCursor"); 1.35 + 1.36 + var doc = currentTabDocument(); 1.37 + var docAcc = getAccessible(doc, [nsIAccessibleDocument]); 1.38 + 1.39 + // Test that embedded documents have their own virtual cursor. 1.40 + is(docAcc.childDocumentCount, 1, "Expecting one child document"); 1.41 + ok(docAcc.getChildDocumentAt(0).virtualCursor, 1.42 + "child document does not have virtualCursor"); 1.43 + 1.44 + gQueue = new eventQueue(); 1.45 + 1.46 + gQueue.onFinish = function onFinish() 1.47 + { 1.48 + closeBrowserWindow(); 1.49 + } 1.50 + 1.51 + queueTraversalSequence(gQueue, docAcc, HeadersTraversalRule, null, 1.52 + ['heading-1-1', 'heading-2-1', 'heading-2-2']); 1.53 + 1.54 + queueTraversalSequence( 1.55 + gQueue, docAcc, ObjectTraversalRule, null, 1.56 + ['Main Title', 'Lorem ipsum ', 1.57 + 'dolor', ' sit amet. Integer vitae urna leo, id ', 1.58 + 'semper', ' nulla. ', 'Second Section Title', 1.59 + 'Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.', 1.60 + 'An ', 'embedded', ' document.', 'Hide me', 'Link 1', 'Link 2', 1.61 + 'Link 3', 'Hello', 'World']); 1.62 + 1.63 + // Just a random smoke test to see if our setTextRange works. 1.64 + gQueue.push( 1.65 + new setVCRangeInvoker( 1.66 + docAcc, 1.67 + getAccessible(doc.getElementById('paragraph-2'), nsIAccessibleText), 1.68 + [2,6])); 1.69 + 1.70 + gQueue.push(new removeVCPositionInvoker( 1.71 + docAcc, doc.getElementById('hide-me'))); 1.72 + 1.73 + gQueue.push(new removeVCRootInvoker( 1.74 + doc.getElementById('links'))); 1.75 + 1.76 + var [x, y] = getBounds(getAccessible(doc.getElementById('heading-1-1'))); 1.77 + gQueue.push(new moveVCCoordInvoker(docAcc, x + 1, y + 1, true, 1.78 + HeadersTraversalRule, 'heading-1-1')); 1.79 + 1.80 + // Already on the point, so we should not get a move event. 1.81 + gQueue.push(new moveVCCoordInvoker(docAcc, x + 1, y + 1, true, 1.82 + HeadersTraversalRule, false)); 1.83 + 1.84 + // Attempting a coordinate outside any header, should not move. 1.85 + gQueue.push(new moveVCCoordInvoker(docAcc, x - 1, y - 1, true, 1.86 + HeadersTraversalRule, false)); 1.87 + 1.88 + // Attempting a coordinate outside any header, should move to null 1.89 + gQueue.push(new moveVCCoordInvoker(docAcc, x - 1, y - 1, false, 1.90 + HeadersTraversalRule, null)); 1.91 + 1.92 + queueTraversalSequence( 1.93 + gQueue, docAcc, ObjectTraversalRule, 1.94 + getAccessible(doc.getElementById('paragraph-1')), 1.95 + ['Lorem ipsum ', 'dolor', ' sit amet. Integer vitae urna leo, id ', 1.96 + 'semper', ' nulla. ']); 1.97 + 1.98 + gQueue.push(new setModalRootInvoker(docAcc, docAcc.parent, 1.99 + NS_ERROR_INVALID_ARG)); 1.100 + 1.101 + // Put cursor in an ignored subtree 1.102 + gQueue.push(new setVCPosInvoker(docAcc, null, null, 1.103 + getAccessible(doc.getElementById("hidden-link")))); 1.104 + // Next item shoud be outside of that subtree 1.105 + gQueue.push(new setVCPosInvoker(docAcc, "moveNext", ObjectTraversalRule, "An ")); 1.106 + 1.107 + gQueue.invoke(); 1.108 + } 1.109 + 1.110 + SimpleTest.waitForExplicitFinish(); 1.111 + addLoadEvent(function () { 1.112 + /* We open a new browser because we need to test with a top-level content 1.113 + document. */ 1.114 + openBrowserWindow( 1.115 + doTest, 1.116 + getRootDirectory(window.location.href) + "doc_virtualcursor.html"); 1.117 + }); 1.118 + </script> 1.119 +</head> 1.120 +<body id="body"> 1.121 + 1.122 + <a target="_blank" 1.123 + title="Introduce virtual cursor/soft focus functionality to a11y API" 1.124 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=698823">Mozilla Bug 698823</a> 1.125 + <p id="display"></p> 1.126 + <div id="content" style="display: none"></div> 1.127 + <pre id="test"> 1.128 + </pre> 1.129 +</body> 1.130 +</html>