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.
1 <?xml version="1.0"?>
3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
4 - License, v. 2.0. If a copy of the MPL was not distributed with this
5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
9 <window id="215405Test"
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
11 width="600"
12 height="600"
13 onload="onLoad();"
14 title="215405 test">
16 <script type="application/javascript"><![CDATA[
17 var imports = [ "SimpleTest", "is", "isnot", "ok"];
18 for each (var name in imports) {
19 window[name] = window.opener.wrappedJSObject[name];
20 }
22 const text="MOZILLA";
23 const nostoreURI = "http://mochi.test:8888/tests/docshell/test/chrome/" +
24 "215405_nostore.html";
25 const nocacheURI = "https://example.com:443/tests/docshell/test/chrome/" +
26 "215405_nocache.html";
28 var gBrowser;
29 var gTestsIterator;
30 var scrollX = 0;
31 var scrollY = 0;
33 function finish() {
34 gBrowser.removeEventListener("pageshow", eventListener, true);
35 // Work around bug 467960
36 var history = gBrowser.webNavigation.sessionHistory;
37 history.PurgeHistory(history.count);
39 window.close();
40 window.opener.wrappedJSObject.SimpleTest.finish();
41 }
43 function onLoad(e) {
44 gBrowser = document.getElementById("content");
45 gBrowser.addEventListener("pageshow", eventListener, true);
47 gTestsIterator = testsIterator();
48 nextTest();
49 }
51 function eventListener(event) {
52 setTimeout(nextTest, 0);
53 }
55 function nextTest() {
56 try {
57 gTestsIterator.next();
58 } catch (err if err instanceof StopIteration) {
59 finish();
60 }
61 }
63 function testsIterator() {
64 // No-store tests
65 var testName = "[nostore]";
67 // Load a page with a no-store header
68 gBrowser.loadURI(nostoreURI);
69 yield undefined;
72 // Now that the page has loaded, amend the form contents
73 var form = gBrowser.contentDocument.getElementById("inp");
74 form.value = text;
76 // Attempt to scroll the page
77 var originalXPosition = gBrowser.contentWindow.scrollX;
78 var originalYPosition = gBrowser.contentWindow.scrollY;
79 var scrollToX = gBrowser.contentWindow.scrollMaxX;
80 var scrollToY = gBrowser.contentWindow.scrollMaxY;
81 gBrowser.contentWindow.scrollBy(scrollToX, scrollToY);
83 // Save the scroll position for future comparison
84 scrollX = gBrowser.contentWindow.scrollX;
85 scrollY = gBrowser.contentWindow.scrollY;
86 isnot(scrollX, originalXPosition,
87 testName + " failed to scroll window horizontally");
88 isnot(scrollY, originalYPosition,
89 testName + " failed to scroll window vertically");
91 // Load a new document into the browser
92 var simple = "data:text/html,<html><head><title>test2</title></head>" +
93 "<body>test2</body></html>";
94 gBrowser.loadURI(simple);
95 yield undefined;
98 // Now go back in history. First page should not have been cached.
99 gBrowser.goBack();
100 yield undefined;
103 // First uncacheable page will now be reloaded. Check scroll position
104 // restored, and form contents not
105 is(gBrowser.contentWindow.scrollX, scrollX, testName +
106 " horizontal axis scroll position not correctly restored");
107 is(gBrowser.contentWindow.scrollY, scrollY, testName +
108 " vertical axis scroll position not correctly restored");
109 var formValue = gBrowser.contentDocument.getElementById("inp").value;
110 isnot(formValue, text, testName + " form value incorrectly restored");
113 // https no-cache
114 testName = "[nocache]";
116 // Load a page with a no-cache header
117 gBrowser.loadURI(nocacheURI);
118 yield undefined;
121 // Now that the page has loaded, amend the form contents
122 form = gBrowser.contentDocument.getElementById("inp");
123 form.value = text;
125 // Attempt to scroll the page
126 originalXPosition = gBrowser.contentWindow.scrollX;
127 originalYPosition = gBrowser.contentWindow.scrollY;
128 scrollToX = gBrowser.contentWindow.scrollMaxX;
129 scrollToY = gBrowser.contentWindow.scrollMaxY;
130 gBrowser.contentWindow.scrollBy(scrollToX, scrollToY);
132 // Save the scroll position for future comparison
133 scrollX = gBrowser.contentWindow.scrollX;
134 scrollY = gBrowser.contentWindow.scrollY;
135 isnot(scrollX, originalXPosition,
136 testName + " failed to scroll window horizontally");
137 isnot(scrollY, originalYPosition,
138 testName + " failed to scroll window vertically");
140 gBrowser.loadURI(simple);
141 yield undefined;
144 // Now go back in history. First page should not have been cached.
145 gBrowser.goBack();
146 yield undefined;
149 // First uncacheable page will now be reloaded. Check scroll position
150 // restored, and form contents not
151 is(gBrowser.contentWindow.scrollX, scrollX, testName +
152 " horizontal axis scroll position not correctly restored");
153 is(gBrowser.contentWindow.scrollY, scrollY, testName +
154 " vertical axis scroll position not correctly restored");
155 var formValue = gBrowser.contentDocument.getElementById("inp").value;
156 isnot(formValue, text, testName + " form value incorrectly restored");
158 // nextTest has to be called from here, as no events are fired in this
159 // step
160 setTimeout(nextTest, 0);
161 yield undefined;
162 }
163 ]]></script>
165 <browser type="content-primary" flex="1" id="content" src="about:blank"/>
166 </window>