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 | <head> |
michael@0 | 3 | <title>visibility state testing</title> |
michael@0 | 4 | |
michael@0 | 5 | <link rel="stylesheet" type="text/css" |
michael@0 | 6 | href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/MochiKit/packed.js"></script> |
michael@0 | 10 | <script type="application/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="../common.js"></script> |
michael@0 | 15 | <script type="application/javascript" |
michael@0 | 16 | src="../role.js"></script> |
michael@0 | 17 | <script type="application/javascript" |
michael@0 | 18 | src="../states.js"></script> |
michael@0 | 19 | <script type="application/javascript" |
michael@0 | 20 | src="../events.js"></script> |
michael@0 | 21 | <script type="application/javascript" |
michael@0 | 22 | src="../browser.js"></script> |
michael@0 | 23 | |
michael@0 | 24 | <script type="application/javascript"> |
michael@0 | 25 | //////////////////////////////////////////////////////////////////////////// |
michael@0 | 26 | // Invokers |
michael@0 | 27 | |
michael@0 | 28 | function loadURIInvoker(aURI, aFunc) |
michael@0 | 29 | { |
michael@0 | 30 | this.invoke = function loadURIInvoker_invoke() |
michael@0 | 31 | { |
michael@0 | 32 | tabBrowser().loadURI(aURI); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | this.eventSeq = [ |
michael@0 | 36 | new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument) |
michael@0 | 37 | ]; |
michael@0 | 38 | |
michael@0 | 39 | this.finalCheck = function loadURIInvoker_finalCheck() |
michael@0 | 40 | { |
michael@0 | 41 | aFunc.call(); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | this.getID = function loadURIInvoker_getID() |
michael@0 | 45 | { |
michael@0 | 46 | return "load uri " + aURI; |
michael@0 | 47 | } |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function addTabInvoker(aURL, aFunc) |
michael@0 | 51 | { |
michael@0 | 52 | this.eventSeq = [ |
michael@0 | 53 | new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 1) |
michael@0 | 54 | ]; |
michael@0 | 55 | |
michael@0 | 56 | this.invoke = function addTabInvoker_invoke() |
michael@0 | 57 | { |
michael@0 | 58 | tabBrowser().loadOneTab(aURL, null, "", null, false); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | this.finalCheck = function addTabInvoker_finalCheck() |
michael@0 | 62 | { |
michael@0 | 63 | aFunc.call(); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | this.getID = function addTabInvoker_getID() |
michael@0 | 67 | { |
michael@0 | 68 | return "add tab: " + aURL; |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | //////////////////////////////////////////////////////////////////////////// |
michael@0 | 73 | // Tests |
michael@0 | 74 | |
michael@0 | 75 | function testBackgroundTab() |
michael@0 | 76 | { |
michael@0 | 77 | // Accessibles in background tab should have offscreen state and no |
michael@0 | 78 | // invisible state. |
michael@0 | 79 | var tabDoc = tabDocumentAt(0); |
michael@0 | 80 | var input = getAccessible(tabDoc.getElementById("input")); |
michael@0 | 81 | testStates(input, STATE_OFFSCREEN, 0, STATE_INVISIBLE); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function testScrolledOff() |
michael@0 | 85 | { |
michael@0 | 86 | var tabDoc = tabDocumentAt(1); |
michael@0 | 87 | |
michael@0 | 88 | // scrolled off |
michael@0 | 89 | input = getAccessible(tabDoc.getElementById("input_scrolledoff")); |
michael@0 | 90 | testStates(input, STATE_OFFSCREEN, 0, STATE_INVISIBLE); |
michael@0 | 91 | |
michael@0 | 92 | // scrolled off item (twice) |
michael@0 | 93 | var lastLiNode = tabDoc.getElementById("li_last"); |
michael@0 | 94 | var lastLi = getAccessible(lastLiNode); |
michael@0 | 95 | testStates(lastLi, STATE_OFFSCREEN, 0, STATE_INVISIBLE); |
michael@0 | 96 | |
michael@0 | 97 | // scroll into view the item |
michael@0 | 98 | lastLiNode.scrollIntoView(true); |
michael@0 | 99 | testStates(lastLi, 0, 0, STATE_OFFSCREEN | STATE_INVISIBLE); |
michael@0 | 100 | |
michael@0 | 101 | // first item is scrolled off now (testcase for bug 768786) |
michael@0 | 102 | var firstLi = getAccessible(tabDoc.getElementById("li_first")); |
michael@0 | 103 | testStates(firstLi, STATE_OFFSCREEN, 0, STATE_INVISIBLE); |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | var gInputDocURI = "data:text/html,<html><body>"; |
michael@0 | 107 | gInputDocURI += "<input id='input'></body></html>"; |
michael@0 | 108 | |
michael@0 | 109 | var gDocURI = "data:text/html,<html><body>"; |
michael@0 | 110 | gDocURI += "<div style='border:2px solid blue; width: 500px; height: 600px;'></div>"; |
michael@0 | 111 | gDocURI += "<input id='input_scrolledoff'>"; |
michael@0 | 112 | gDocURI += "<ul style='border:2px solid red; width: 100px; height: 50px; overflow: auto;'>"; |
michael@0 | 113 | gDocURI += " <li id='li_first'>item1</li><li>item2</li><li>item3</li>"; |
michael@0 | 114 | gDocURI += " <li>item4</li><li>item5</li><li id='li_last'>item6</li>"; |
michael@0 | 115 | gDocURI += "</ul>"; |
michael@0 | 116 | gDocURI += "</body></html>"; |
michael@0 | 117 | |
michael@0 | 118 | function doTests() |
michael@0 | 119 | { |
michael@0 | 120 | testStates("div", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); |
michael@0 | 121 | testStates("div_off", STATE_OFFSCREEN, 0, STATE_INVISIBLE); |
michael@0 | 122 | testStates("div_transformed", STATE_OFFSCREEN, 0, STATE_INVISIBLE); |
michael@0 | 123 | testStates("div_abschild", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); |
michael@0 | 124 | |
michael@0 | 125 | gQueue = new eventQueue(); |
michael@0 | 126 | |
michael@0 | 127 | gQueue.push(new addTabInvoker("about:blank", testBackgroundTab)); |
michael@0 | 128 | gQueue.push(new loadURIInvoker(gDocURI, testScrolledOff)); |
michael@0 | 129 | |
michael@0 | 130 | gQueue.onFinish = function() { closeBrowserWindow(); } |
michael@0 | 131 | gQueue.invoke(); // Will call SimpleTest.finish(); |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 135 | openBrowserWindow(doTests, gInputDocURI, { width: 600, height: 600 }); |
michael@0 | 136 | </script> |
michael@0 | 137 | |
michael@0 | 138 | </head> |
michael@0 | 139 | |
michael@0 | 140 | <body> |
michael@0 | 141 | |
michael@0 | 142 | <a target="_blank" |
michael@0 | 143 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=591363" |
michael@0 | 144 | title="(in)visible state is not always correct?"> |
michael@0 | 145 | Mozilla Bug 591363 |
michael@0 | 146 | </a> |
michael@0 | 147 | <a target="_blank" |
michael@0 | 148 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=768786" |
michael@0 | 149 | title="Offscreen state is not exposed under certain circumstances"> |
michael@0 | 150 | Mozilla Bug 768786 |
michael@0 | 151 | </a> |
michael@0 | 152 | <p id="display"></p> |
michael@0 | 153 | <div id="content" style="display: none"></div> |
michael@0 | 154 | <pre id="test"> |
michael@0 | 155 | </pre> |
michael@0 | 156 | |
michael@0 | 157 | <div id="outer_div"> |
michael@0 | 158 | |
michael@0 | 159 | <!-- trivial cases --> |
michael@0 | 160 | <div id="div">div</div> |
michael@0 | 161 | <div id="div_off" style="position: absolute; left:-999px; top:-999px"> |
michael@0 | 162 | offscreen! |
michael@0 | 163 | </div> |
michael@0 | 164 | <div id="div_transformed" style="transform: translate(-999px, -999px);"> |
michael@0 | 165 | transformed! |
michael@0 | 166 | </div> |
michael@0 | 167 | |
michael@0 | 168 | <!-- edge case: no rect but has out of flow child --> |
michael@0 | 169 | <div id="div_abschild"> |
michael@0 | 170 | <p style="position: absolute; left: 120px; top:120px;">absolute</p> |
michael@0 | 171 | </div> |
michael@0 | 172 | |
michael@0 | 173 | </div> |
michael@0 | 174 | </body> |
michael@0 | 175 | </html> |