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