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.
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>nsIHyper>TextAccessible in dynamic tests</title>
5 <link rel="stylesheet" type="text/css"
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
8 <script type="application/javascript"
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <script type="application/javascript"
12 src="../common.js"></script>
13 <script type="application/javascript"
14 src="../events.js"></script>
16 <script type="application/javascript">
17 const kLinksCount = 128;
18 function addLinks(aContainerID)
19 {
20 this.containerNode = getNode(aContainerID);
22 this.eventSeq = [
23 new invokerChecker(EVENT_REORDER, this.containerNode)
24 ];
26 this.invoke = function addLinks_invoke()
27 {
28 for (var jdx = 0; jdx < kLinksCount; jdx++) {
29 var a = document.createElement("a");
30 a.setAttribute("href", "mozilla.org");
31 a.textContent = "mozilla";
32 this.containerNode.appendChild(a);
34 var span = document.createElement("span");
35 span.textContent = " text ";
36 this.containerNode.appendChild(span);
37 }
38 }
40 this.finalCheck = function addLinks_finalCheck()
41 {
42 // getLinkAt and getLinkIndex.
43 var htAcc = getAccessible(this.containerNode, [nsIAccessibleHyperText]);
44 for (var jdx = 0; jdx < kLinksCount; jdx++) {
45 var link = htAcc.getLinkAt(jdx);
46 ok(link, "No link at index " + jdx + " for '" + aContainerID + "'");
48 var linkIdx = htAcc.getLinkIndex(link);
49 is(linkIdx, jdx, "Wrong link index for '" + aContainerID + "'!");
50 }
51 }
53 this.getID = function addLinks_getID()
54 {
55 return "Add links for '" + aContainerID + "'";
56 }
57 }
59 function updateText(aContainerID)
60 {
61 this.containerNode = getNode(aContainerID);
62 this.container = getAccessible(this.containerNode, nsIAccessibleHyperText);
63 this.text = this.container.firstChild;
64 this.textNode = this.text.DOMNode;
65 this.textLen = this.textNode.data.length;
67 this.eventSeq = [
68 new invokerChecker(EVENT_TEXT_INSERTED, this.containerNode)
69 ];
71 this.invoke = function updateText_invoke()
72 {
73 is(this.container.getLinkIndexAtOffset(this.textLen), 0,
74 "Wrong intial text offsets!");
76 this.text.DOMNode.appendData(" my");
77 }
79 this.finalCheck = function updateText_finalCheck()
80 {
81 is(this.container.getLinkIndexAtOffset(this.textLen), -1,
82 "Text offsets weren't updated!");
83 }
85 this.getID = function updateText_getID()
86 {
87 return "update text for '" + aContainerID + "'";
88 }
89 }
91 /**
92 * Text offsets must be updated when hypertext child is removed.
93 */
94 function removeChild(aContainerID, aChildID, aInitialText, aFinalText)
95 {
96 this.containerNode = getNode(aContainerID);
97 this.container = getAccessible(this.containerNode, nsIAccessibleText);
98 this.childNode = getNode(aChildID);
100 // Call first to getText so offsets are cached
101 is(this.container.getText(0, -1), aInitialText,
102 "Wrong text before child removal");
104 this.eventSeq = [
105 new invokerChecker(EVENT_REORDER, this.containerNode)
106 ];
108 this.invoke = function removeChild_invoke()
109 {
110 this.containerNode.removeChild(this.childNode);
111 }
113 this.finalCheck = function removeChild_finalCheck()
114 {
115 is(this.container.getText(0, -1), aFinalText,
116 "Wrong text after child removal");
117 is(this.container.characterCount, aFinalText.length,
118 "Wrong text after child removal");
119 }
121 this.getID = function removeChild_getID()
122 {
123 return "check text after removing child from '" + aContainerID + "'";
124 }
125 }
129 //gA11yEventDumpToConsole = true; // debug stuff
131 var gQueue = null;
132 function doTest()
133 {
134 gQueue = new eventQueue();
135 gQueue.push(new addLinks("p1"));
136 gQueue.push(new updateText("p2"));
137 gQueue.push(new removeChild("div1","div2",
138 "hello my good friend", "hello friend"));
140 gQueue.invoke(); // Will call SimpleTest.finish();
141 }
143 SimpleTest.waitForExplicitFinish();
144 addA11yLoadEvent(doTest);
145 </script>
146 </head>
147 <body>
149 <a target="_blank"
150 title="Cache links within hypertext accessible"
151 href="https://bugzilla.mozilla.org/show_bug.cgi?id=572394">
152 Mozilla Bug 572394
153 </a>
154 <a target="_blank"
155 title="Text offsets don't get updated when text of first child text accessible is changed"
156 href="https://bugzilla.mozilla.org/show_bug.cgi?id=625009">
157 Mozilla Bug 625009
158 </a>
159 <a target="_blank"
160 title="Crash in nsHyperTextAccessible::GetText()"
161 href="https://bugzilla.mozilla.org/show_bug.cgi?id=630841">
162 Mozilla Bug 630841
163 </a><br>
164 <p id="display"></p>
165 <div id="content" style="display: none"></div>
166 <pre id="test">
167 </pre>
169 <p id="p1"></p>
170 <p id="p2"><b>hello</b><a>friend</a></p>
171 <div id="div1">hello<span id="div2"> my<span id="div3"> good</span></span> friend</span></div>
172 </body>
173 </html>