Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <html> |
michael@0 | 2 | |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Accessible caret move events testing</title> |
michael@0 | 5 | |
michael@0 | 6 | <link rel="stylesheet" type="text/css" |
michael@0 | 7 | href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" |
michael@0 | 10 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 13 | |
michael@0 | 14 | <script type="application/javascript" |
michael@0 | 15 | src="../common.js"></script> |
michael@0 | 16 | <script type="application/javascript" |
michael@0 | 17 | src="../events.js"></script> |
michael@0 | 18 | |
michael@0 | 19 | <script type="application/javascript"> |
michael@0 | 20 | /** |
michael@0 | 21 | * Click checker. |
michael@0 | 22 | */ |
michael@0 | 23 | function clickChecker(aCaretOffset, aID, aExtraNodeOrID, aExtraCaretOffset) |
michael@0 | 24 | { |
michael@0 | 25 | this.__proto__ = new caretMoveChecker(aCaretOffset, aID); |
michael@0 | 26 | |
michael@0 | 27 | this.extraNode = getNode(aExtraNodeOrID); |
michael@0 | 28 | |
michael@0 | 29 | this.check = function clickChecker_check(aEvent) |
michael@0 | 30 | { |
michael@0 | 31 | this.__proto__.check(aEvent); |
michael@0 | 32 | |
michael@0 | 33 | if (this.extraNode) { |
michael@0 | 34 | var acc = getAccessible(this.extraNode, [nsIAccessibleText]); |
michael@0 | 35 | is(acc.caretOffset, aExtraCaretOffset, |
michael@0 | 36 | "Wrong caret offset for " + aExtraNodeOrID); |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | /** |
michael@0 | 42 | * Do tests. |
michael@0 | 43 | */ |
michael@0 | 44 | var gQueue = null; |
michael@0 | 45 | |
michael@0 | 46 | // gA11yEventDumpID = "eventdump"; // debug stuff |
michael@0 | 47 | //gA11yEventDumpToConsole = true; |
michael@0 | 48 | |
michael@0 | 49 | function doTests() |
michael@0 | 50 | { |
michael@0 | 51 | // test caret move events and caret offsets |
michael@0 | 52 | gQueue = new eventQueue(); |
michael@0 | 53 | |
michael@0 | 54 | var id = "textbox"; |
michael@0 | 55 | gQueue.push(new synthFocus(id, new caretMoveChecker(5, id))); |
michael@0 | 56 | gQueue.push(new synthSelectAll(id, new caretMoveChecker(5, id))); |
michael@0 | 57 | gQueue.push(new synthClick(id, new caretMoveChecker(0, id))); |
michael@0 | 58 | gQueue.push(new synthRightKey(id, new caretMoveChecker(1, id))); |
michael@0 | 59 | |
michael@0 | 60 | id = "textarea"; |
michael@0 | 61 | gQueue.push(new synthClick(id, new caretMoveChecker(0, id))); |
michael@0 | 62 | gQueue.push(new synthRightKey(id, new caretMoveChecker(1, id))); |
michael@0 | 63 | gQueue.push(new synthDownKey(id, new caretMoveChecker(12, id))); |
michael@0 | 64 | |
michael@0 | 65 | id = "textarea_wrapped"; |
michael@0 | 66 | gQueue.push(new setCaretOffset(id, 4, id)); |
michael@0 | 67 | gQueue.push(new synthLeftKey(id, new caretMoveChecker(4, id))); |
michael@0 | 68 | |
michael@0 | 69 | id = "p"; |
michael@0 | 70 | gQueue.push(new synthClick(id, new caretMoveChecker(0, id))); |
michael@0 | 71 | gQueue.push(new synthRightKey(id, new caretMoveChecker(1, id))); |
michael@0 | 72 | gQueue.push(new synthDownKey(id, new caretMoveChecker(6, id))); |
michael@0 | 73 | |
michael@0 | 74 | id = "p1_in_div"; |
michael@0 | 75 | gQueue.push(new synthClick(id, new clickChecker(0, id, "p2_in_div", -1))); |
michael@0 | 76 | |
michael@0 | 77 | id = "p"; |
michael@0 | 78 | gQueue.push(new synthShiftTab(id, new caretMoveChecker(0, id))); |
michael@0 | 79 | id = "textarea"; |
michael@0 | 80 | gQueue.push(new synthShiftTab(id, new caretMoveChecker(12, id))); |
michael@0 | 81 | id = "p"; |
michael@0 | 82 | gQueue.push(new synthTab(id, new caretMoveChecker(0, id))); |
michael@0 | 83 | |
michael@0 | 84 | // Set caret after a child of span element, i.e. after 'text' text. |
michael@0 | 85 | gQueue.push(new moveCaretToDOMPoint("test1", getNode("test1_span"), 1, |
michael@0 | 86 | 4, "test1")); |
michael@0 | 87 | gQueue.push(new moveCaretToDOMPoint("test2", getNode("test2_span"), 1, |
michael@0 | 88 | 4, "test2")); |
michael@0 | 89 | |
michael@0 | 90 | // empty text element |
michael@0 | 91 | gQueue.push(new moveCaretToDOMPoint("test3", getNode("test3"), 0, |
michael@0 | 92 | 0, "test3")); |
michael@0 | 93 | gQueue.push(new moveCaretToDOMPoint("test4", getNode("test4_span"), 0, |
michael@0 | 94 | 0, "test4")); |
michael@0 | 95 | |
michael@0 | 96 | gQueue.invoke(); // Will call SimpleTest.finish(); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 100 | addA11yLoadEvent(doTests); |
michael@0 | 101 | </script> |
michael@0 | 102 | </head> |
michael@0 | 103 | |
michael@0 | 104 | <body> |
michael@0 | 105 | |
michael@0 | 106 | <a target="_blank" |
michael@0 | 107 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=454377" |
michael@0 | 108 | title="Accessible caret move events testing"> |
michael@0 | 109 | Bug 454377 |
michael@0 | 110 | </a> |
michael@0 | 111 | <a target="_blank" |
michael@0 | 112 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=567571" |
michael@0 | 113 | title="caret-moved events missing at the end of a wrapped line of text"> |
michael@0 | 114 | Bug 567571 |
michael@0 | 115 | </a> |
michael@0 | 116 | <a target="_blank" |
michael@0 | 117 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=824901" |
michael@0 | 118 | title="HyperTextAccessible::DOMPointToHypertextOffset fails for node and offset equal to node child count"> |
michael@0 | 119 | Bug 824901 |
michael@0 | 120 | </a> |
michael@0 | 121 | <p id="display"></p> |
michael@0 | 122 | <div id="content" style="display: none"></div> |
michael@0 | 123 | <pre id="test"> |
michael@0 | 124 | </pre> |
michael@0 | 125 | |
michael@0 | 126 | <input id="textbox" value="hello"/> |
michael@0 | 127 | <textarea id="textarea">text<br>text</textarea> |
michael@0 | 128 | <p id="p" contentEditable="true"><span>text</span><br/>text</p> |
michael@0 | 129 | <div id="div" contentEditable="true"><p id="p1_in_div">text</p><p id="p2_in_div">text</p></div> |
michael@0 | 130 | |
michael@0 | 131 | <p contentEditable="true" id="test1"><span id="test1_span">text</span>ohoho</p> |
michael@0 | 132 | <p contentEditable="true" id="test2"><span><span id="test2_span">text</span></span>ohoho</p> |
michael@0 | 133 | <p contentEditable="true" id="test3"></p> |
michael@0 | 134 | <p contentEditable="true" id="test4"><span id="test4_span"></span></p> |
michael@0 | 135 | |
michael@0 | 136 | <textarea id="textarea_wrapped" cols="5">hey friend</textarea> |
michael@0 | 137 | |
michael@0 | 138 | <div id="eventdump"></div> |
michael@0 | 139 | </body> |
michael@0 | 140 | </html> |