Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <html> |
michael@0 | 2 | |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Text accessible caret 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 | |
michael@0 | 12 | <script type="application/javascript" |
michael@0 | 13 | src="../common.js"></script> |
michael@0 | 14 | <script type="application/javascript" |
michael@0 | 15 | src="../events.js"></script> |
michael@0 | 16 | |
michael@0 | 17 | <script type="application/javascript"> |
michael@0 | 18 | /** |
michael@0 | 19 | * Turn on/off the caret browsing mode. |
michael@0 | 20 | */ |
michael@0 | 21 | function turnCaretBrowsing(aIsOn) |
michael@0 | 22 | { |
michael@0 | 23 | var prefs = Components.classes["@mozilla.org/preferences-service;1"]. |
michael@0 | 24 | getService(Components.interfaces.nsIPrefBranch); |
michael@0 | 25 | prefs.setBoolPref("accessibility.browsewithcaret", aIsOn); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * Test caret offset for the given accessible. |
michael@0 | 30 | */ |
michael@0 | 31 | function testCaretOffset(aID, aCaretOffset) |
michael@0 | 32 | { |
michael@0 | 33 | var acc = getAccessible(aID, [nsIAccessibleText]); |
michael@0 | 34 | is(acc.caretOffset, aCaretOffset, |
michael@0 | 35 | "Wrong caret offset for " + aID); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function testCaretOffsets(aList) |
michael@0 | 39 | { |
michael@0 | 40 | for (var i = 0; i < aList.length; i++) |
michael@0 | 41 | testCaretOffset(aList[0][0], aList[0][1]); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function queueTraversalList(aList, aFocusNode) |
michael@0 | 45 | { |
michael@0 | 46 | for (var i = 0 ; i < aList.length; i++) { |
michael@0 | 47 | var node = aList[i].DOMPoint[0]; |
michael@0 | 48 | var nodeOffset = aList[i].DOMPoint[1]; |
michael@0 | 49 | |
michael@0 | 50 | var textAcc = aList[i].point[0]; |
michael@0 | 51 | var textOffset = aList[i].point[1]; |
michael@0 | 52 | var textList = aList[i].pointList; |
michael@0 | 53 | var invoker = |
michael@0 | 54 | new moveCaretToDOMPoint(textAcc, node, nodeOffset, textOffset, |
michael@0 | 55 | ((i == 0) ? aFocusNode : null), |
michael@0 | 56 | testCaretOffsets.bind(null, textList)) |
michael@0 | 57 | gQueue.push(invoker); |
michael@0 | 58 | } |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | /** |
michael@0 | 62 | * Do tests. |
michael@0 | 63 | */ |
michael@0 | 64 | var gQueue = null; |
michael@0 | 65 | |
michael@0 | 66 | //gA11yEventDumpID = "eventdump"; // debug stuff |
michael@0 | 67 | //gA11yEventDumpToConsole = true; |
michael@0 | 68 | |
michael@0 | 69 | function doTests() |
michael@0 | 70 | { |
michael@0 | 71 | turnCaretBrowsing(true); |
michael@0 | 72 | |
michael@0 | 73 | // test caret offsets |
michael@0 | 74 | testCaretOffset(document, 16); |
michael@0 | 75 | testCaretOffset("textbox", -1); |
michael@0 | 76 | testCaretOffset("textarea", -1); |
michael@0 | 77 | testCaretOffset("p", -1); |
michael@0 | 78 | |
michael@0 | 79 | // test caret move events and caret offsets |
michael@0 | 80 | gQueue = new eventQueue(); |
michael@0 | 81 | |
michael@0 | 82 | gQueue.push(new setCaretOffset("textbox", 1, "textbox")); |
michael@0 | 83 | gQueue.push(new setCaretOffset("link", 1, "link")); |
michael@0 | 84 | gQueue.push(new setCaretOffset("heading", 1, document)); |
michael@0 | 85 | |
michael@0 | 86 | // a*b*c |
michael@0 | 87 | var p2Doc = getNode("p2_container").contentDocument; |
michael@0 | 88 | var traversalList = [ |
michael@0 | 89 | { // before 'a' |
michael@0 | 90 | DOMPoint: [ getNode("p2", p2Doc).firstChild, 0 ], |
michael@0 | 91 | point: [ getNode("p2", p2Doc), 0 ], |
michael@0 | 92 | pointList: [ [ p2Doc, 0 ] ] |
michael@0 | 93 | }, |
michael@0 | 94 | { // after 'a' (before anchor) |
michael@0 | 95 | DOMPoint: [ getNode("p2", p2Doc).firstChild, 1 ], |
michael@0 | 96 | point: [ getNode("p2", p2Doc), 1 ], |
michael@0 | 97 | pointList: [ [ p2Doc, 0 ] ] |
michael@0 | 98 | }, |
michael@0 | 99 | { // before 'b' (inside anchor) |
michael@0 | 100 | DOMPoint: [ getNode("p2_a", p2Doc).firstChild, 0 ], |
michael@0 | 101 | point: [ getNode("p2_a", p2Doc), 0 ], |
michael@0 | 102 | pointList: [ |
michael@0 | 103 | [ getNode("p2", p2Doc), 1 ], |
michael@0 | 104 | [ p2Doc, 0 ] |
michael@0 | 105 | ] |
michael@0 | 106 | }, |
michael@0 | 107 | { // after 'b' (inside anchor) |
michael@0 | 108 | DOMPoint: [ getNode("p2_a", p2Doc).firstChild, 1 ], |
michael@0 | 109 | point: [ getNode("p2_a", p2Doc), 1 ], |
michael@0 | 110 | pointList: [ |
michael@0 | 111 | [ getNode("p2", p2Doc), 1 ] , |
michael@0 | 112 | [ p2Doc, 0 ] |
michael@0 | 113 | ] |
michael@0 | 114 | }, |
michael@0 | 115 | { // before 'c' (after anchor) |
michael@0 | 116 | DOMPoint: [ getNode("p2", p2Doc).lastChild, 0 ], |
michael@0 | 117 | point: [ getNode("p2", p2Doc), 2 ], |
michael@0 | 118 | pointList: [ [ p2Doc, 0 ] ] |
michael@0 | 119 | }, |
michael@0 | 120 | { // after 'c' |
michael@0 | 121 | DOMPoint: [ getNode("p2", p2Doc).lastChild, 1 ], |
michael@0 | 122 | point: [ getNode("p2", p2Doc), 3 ], |
michael@0 | 123 | pointList: [ [ p2Doc, 0 ] ] |
michael@0 | 124 | } |
michael@0 | 125 | ]; |
michael@0 | 126 | queueTraversalList(traversalList, getNode("p2", p2Doc)); |
michael@0 | 127 | |
michael@0 | 128 | gQueue.onFinish = function() |
michael@0 | 129 | { |
michael@0 | 130 | turnCaretBrowsing(false); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | gQueue.invoke(); // Will call SimpleTest.finish(); |
michael@0 | 134 | } |
michael@0 | 135 | |
michael@0 | 136 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 137 | addA11yLoadEvent(doTests); |
michael@0 | 138 | </script> |
michael@0 | 139 | </head> |
michael@0 | 140 | |
michael@0 | 141 | <body> |
michael@0 | 142 | |
michael@0 | 143 | <a target="_blank" |
michael@0 | 144 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=448744" |
michael@0 | 145 | title="caretOffset should return -1 if the system caret is not currently with in that particular object"> |
michael@0 | 146 | Bug 448744 |
michael@0 | 147 | </a> |
michael@0 | 148 | <a target="_blank" |
michael@0 | 149 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=524115" |
michael@0 | 150 | title="HyperText accessible should get focus when the caret is positioned inside of it, text is changed or copied into clipboard by ATs"> |
michael@0 | 151 | Bug 524115 |
michael@0 | 152 | </a> |
michael@0 | 153 | <a target="_blank" |
michael@0 | 154 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=546068" |
michael@0 | 155 | title="Position is not being updated when atk_text_set_caret_offset is used"> |
michael@0 | 156 | Bug 546068 |
michael@0 | 157 | </a> |
michael@0 | 158 | <a target="_blank" |
michael@0 | 159 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=672717" |
michael@0 | 160 | title="Broken caret when moving into/out of embedded objects with right arrow"> |
michael@0 | 161 | Bug 672717 |
michael@0 | 162 | </a> |
michael@0 | 163 | <a target="_blank" |
michael@0 | 164 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=725581" |
michael@0 | 165 | title="caretOffset for textarea should be -1 when textarea doesn't have a focus"> |
michael@0 | 166 | Bug 725581 |
michael@0 | 167 | </a> |
michael@0 | 168 | <p id="display"></p> |
michael@0 | 169 | <div id="content" style="display: none"></div> |
michael@0 | 170 | <pre id="test"> |
michael@0 | 171 | </pre> |
michael@0 | 172 | |
michael@0 | 173 | <input id="textbox" value="hello"/> |
michael@0 | 174 | <textarea id="textarea">text<br>text</textarea> |
michael@0 | 175 | <p id="p" contentEditable="true"><span>text</span><br/>text</p> |
michael@0 | 176 | <a id="link" href="about:">about mozilla</a> |
michael@0 | 177 | <h5 id="heading">heading</h5> |
michael@0 | 178 | <iframe id="p2_container" |
michael@0 | 179 | src="data:text/html,<p id='p2' contentEditable='true'>a<a id='p2_a' href='mozilla.org'>b</a>c</p>"></iframe> |
michael@0 | 180 | |
michael@0 | 181 | <div id="eventdump"></div> |
michael@0 | 182 | </body> |
michael@0 | 183 | </html> |