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 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 2 | <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 3 | screenX="200" screenY="200" width="300" height="300" |
michael@0 | 4 | onload="setTimeout(doTest, 0)"> |
michael@0 | 5 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 6 | <script><![CDATA[ |
michael@0 | 7 | var is = window.opener.SimpleTest.is; |
michael@0 | 8 | |
michael@0 | 9 | function doTest() { |
michael@0 | 10 | // from test_resizer.xul |
michael@0 | 11 | var expectX = 200; |
michael@0 | 12 | var expectY = 200; |
michael@0 | 13 | var expectXMost = 500; |
michael@0 | 14 | var expectYMost = 500; |
michael@0 | 15 | var screenScale = expectX/window.screenX; |
michael@0 | 16 | var root = document.documentElement; |
michael@0 | 17 | |
michael@0 | 18 | var oldScreenX = window.screenX; |
michael@0 | 19 | var oldScreenY = window.screenY; |
michael@0 | 20 | var oldWidth = window.outerWidth; |
michael@0 | 21 | var oldHeight = window.outerHeight; |
michael@0 | 22 | |
michael@0 | 23 | function testResizer(dx, dy) { |
michael@0 | 24 | var offset = 20; |
michael@0 | 25 | var scale = 5; |
michael@0 | 26 | // target the centre of the resizer |
michael@0 | 27 | var offsetX = window.innerWidth/2 + (window.innerWidth/3)*dx; |
michael@0 | 28 | var offsetY = window.innerHeight/2 + (window.innerHeight/3)*dy; |
michael@0 | 29 | |
michael@0 | 30 | for (var mouseX = -1; mouseX <= 1; ++mouseX) { |
michael@0 | 31 | for (var mouseY = -1; mouseY <= 1; ++mouseY) { |
michael@0 | 32 | var newExpectX = expectX; |
michael@0 | 33 | var newExpectXMost = expectXMost; |
michael@0 | 34 | var newExpectY = expectY; |
michael@0 | 35 | var newExpectYMost = expectYMost; |
michael@0 | 36 | if (dx < 0) { |
michael@0 | 37 | newExpectX += mouseX*scale; |
michael@0 | 38 | } else if (dx > 0) { |
michael@0 | 39 | newExpectXMost += mouseX*scale; |
michael@0 | 40 | } |
michael@0 | 41 | if (dy < 0) { |
michael@0 | 42 | newExpectY += mouseY*scale; |
michael@0 | 43 | } else if (dy > 0) { |
michael@0 | 44 | newExpectYMost += mouseY*scale; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | synthesizeMouse(root, offsetX, offsetY, { type:"mousedown" }); |
michael@0 | 48 | synthesizeMouse(root, offsetX + mouseX*scale, offsetY + mouseY*scale, { type:"mousemove" }); |
michael@0 | 49 | is(window.screenX*screenScale, newExpectX, |
michael@0 | 50 | "Bad x for " + dx + "," + dy + " moving " + mouseX + "," + mouseY); |
michael@0 | 51 | is(window.screenY*screenScale, newExpectY, |
michael@0 | 52 | "Bad y for " + dx + "," + dy + " moving " + mouseX + "," + mouseY); |
michael@0 | 53 | is(window.outerWidth, newExpectXMost - newExpectX, |
michael@0 | 54 | "Bad width for " + dx + "," + dy + " moving " + mouseX + "," + mouseY); |
michael@0 | 55 | is(window.outerHeight, newExpectYMost - newExpectY, |
michael@0 | 56 | "Bad height for " + dx + "," + dy + " moving " + mouseX + "," + mouseY); |
michael@0 | 57 | |
michael@0 | 58 | // move it back before we release! Adjust for any window movement |
michael@0 | 59 | synthesizeMouse(root, offsetX - (newExpectX - expectX), |
michael@0 | 60 | offsetY - (newExpectY - expectY), { type:"mousemove" }); |
michael@0 | 61 | synthesizeMouse(root, offsetX, offsetY, { type:"mouseup" }); |
michael@0 | 62 | } |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | testResizer(-1, -1); |
michael@0 | 67 | testResizer(-1, 0); |
michael@0 | 68 | testResizer(-1, 1); |
michael@0 | 69 | testResizer(0, -1); |
michael@0 | 70 | testResizer(0, 1); |
michael@0 | 71 | testResizer(1, -1); |
michael@0 | 72 | testResizer(1, 0); |
michael@0 | 73 | testResizer(1, 1); |
michael@0 | 74 | |
michael@0 | 75 | var resizers = document.getElementsByTagName("resizer"); |
michael@0 | 76 | Array.forEach(resizers, function (element) { |
michael@0 | 77 | is(getComputedStyle(element, "").cursor, |
michael@0 | 78 | element.getAttribute("expectedcursor"), |
michael@0 | 79 | "cursor for " + element.dir); |
michael@0 | 80 | }); |
michael@0 | 81 | |
michael@0 | 82 | // now check the cursors in rtl. The bottomend resizer |
michael@0 | 83 | // should be reversed |
michael@0 | 84 | document.getElementById("bottomend").setAttribute("rtl", "true"); |
michael@0 | 85 | Array.forEach(resizers, function (element) { |
michael@0 | 86 | is(getComputedStyle(element, "").cursor, |
michael@0 | 87 | element.dir == "bottomend" ? "sw-resize" : |
michael@0 | 88 | element.getAttribute("expectedcursor"), |
michael@0 | 89 | "cursor for " + element.dir); |
michael@0 | 90 | }); |
michael@0 | 91 | |
michael@0 | 92 | window.close(); |
michael@0 | 93 | window.opener.lastResizerTest(); |
michael@0 | 94 | } |
michael@0 | 95 | ]]></script> |
michael@0 | 96 | <hbox id="container" flex="1"> |
michael@0 | 97 | <vbox flex="1"> |
michael@0 | 98 | <resizer dir="topleft" expectedcursor="nw-resize" flex="1"/> |
michael@0 | 99 | <resizer dir="left" expectedcursor="ew-resize" flex="1"/> |
michael@0 | 100 | <resizer dir="bottomleft" expectedcursor="sw-resize" flex="1"/> |
michael@0 | 101 | </vbox> |
michael@0 | 102 | <vbox flex="1"> |
michael@0 | 103 | <resizer dir="top" expectedcursor="ns-resize" flex="1"/> |
michael@0 | 104 | <resizer id="bottomend" dir="bottomend" expectedcursor="se-resize" flex="1"/> |
michael@0 | 105 | <resizer dir="bottom" expectedcursor="ns-resize" flex="1"/> |
michael@0 | 106 | </vbox> |
michael@0 | 107 | <vbox flex="1"> |
michael@0 | 108 | <resizer dir="topright" expectedcursor="ne-resize" flex="1"/> |
michael@0 | 109 | <resizer dir="right" expectedcursor="ew-resize" flex="1"/> |
michael@0 | 110 | <resizer dir="bottomright" expectedcursor="se-resize" flex="1"/> |
michael@0 | 111 | </vbox> |
michael@0 | 112 | </hbox> |
michael@0 | 113 | </window> |