widget/tests/window_state_windows.xul

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 9
michael@0 10 <window id="NativeWindow"
michael@0 11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 12 width="300"
michael@0 13 height="300"
michael@0 14 onload="onLoad();"
michael@0 15 title="Window State Tests">
michael@0 16
michael@0 17 <script type="application/javascript"
michael@0 18 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 19 <script type="application/javascript">
michael@0 20 <![CDATA[
michael@0 21
michael@0 22 let Cc = Components.classes;
michael@0 23 let Ci = Components.interfaces;
michael@0 24 let Cu = Components.utils;
michael@0 25 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 26
michael@0 27 SimpleTest.waitForExplicitFinish();
michael@0 28
michael@0 29 function onLoad() {
michael@0 30 var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
michael@0 31 var win = wm.getMostRecentWindow("navigator:browser");
michael@0 32
michael@0 33 /*
michael@0 34 switch(win.windowState) {
michael@0 35 case win.STATE_FULLSCREEN:
michael@0 36 dump("STATE_FULLSCREEN \n");
michael@0 37 break;
michael@0 38 case win.STATE_MAXIMIZED:
michael@0 39 dump("STATE_MAXIMIZED \n");
michael@0 40 break;
michael@0 41 case win.STATE_MINIMIZED:
michael@0 42 dump("STATE_MINIMIZED \n");
michael@0 43 break;
michael@0 44 case win.STATE_NORMAL:
michael@0 45 dump("STATE_NORMAL \n");
michael@0 46 break;
michael@0 47 }
michael@0 48 */
michael@0 49
michael@0 50 // Make sure size mode changes are reflected in the widget.
michael@0 51 win.restore();
michael@0 52 ok(win.windowState == win.STATE_NORMAL, "window state is restored.");
michael@0 53 win.minimize();
michael@0 54 ok(win.windowState == win.STATE_MINIMIZED, "window state is minimized.");
michael@0 55
michael@0 56 // Windows resizes children to 0x0. Code in nsWindow filters these changes out. Without
michael@0 57 // this all sorts of screwy things can happen in child widgets.
michael@0 58 ok(document.height > 0, "document height should not be zero for a minimized window!");
michael@0 59 ok(document.width > 0, "document width should not be zero for a minimized window!");
michael@0 60
michael@0 61 // Make sure size mode changes are reflected in the widget.
michael@0 62 win.restore();
michael@0 63 ok(win.windowState == win.STATE_NORMAL, "window state is restored.");
michael@0 64 win.maximize();
michael@0 65 ok(win.windowState == win.STATE_MAXIMIZED, "window state is maximized.");
michael@0 66 win.restore();
michael@0 67 ok(win.windowState == win.STATE_NORMAL, "window state is restored.");
michael@0 68
michael@0 69 /*
michael@0 70 dump(win.screenX + "\n");
michael@0 71 win.minimize();
michael@0 72 dump(win.screenX + "\n");
michael@0 73 win.restore();
michael@0 74 dump(win.screenX + "\n");
michael@0 75 */
michael@0 76
michael@0 77 SimpleTest.finish();
michael@0 78 }
michael@0 79
michael@0 80 ]]>
michael@0 81 </script>
michael@0 82 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 83 <p id="display"></p>
michael@0 84 <div id="content" style="display: none"></div>
michael@0 85 <pre id="test"></pre>
michael@0 86 </body>
michael@0 87 </window>

mercurial