widget/tests/window_state_windows.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/tests/window_state_windows.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,87 @@
     1.4 +<?xml version="1.0"?>
     1.5 +
     1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.9 +
    1.10 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
    1.11 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
    1.12 +
    1.13 +<window id="NativeWindow"
    1.14 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.15 +        width="300"
    1.16 +        height="300"
    1.17 +        onload="onLoad();"
    1.18 +        title="Window State Tests">
    1.19 +
    1.20 +  <script type="application/javascript"
    1.21 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.22 +  <script type="application/javascript">
    1.23 +    <![CDATA[
    1.24 +
    1.25 +    let Cc = Components.classes;
    1.26 +    let Ci = Components.interfaces;
    1.27 +    let Cu = Components.utils;
    1.28 +    Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    1.29 +
    1.30 +    SimpleTest.waitForExplicitFinish();
    1.31 +
    1.32 +    function onLoad() {
    1.33 +      var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
    1.34 +      var win = wm.getMostRecentWindow("navigator:browser");
    1.35 +
    1.36 +      /*
    1.37 +      switch(win.windowState) {
    1.38 +        case win.STATE_FULLSCREEN:
    1.39 +        dump("STATE_FULLSCREEN \n");
    1.40 +        break;
    1.41 +        case win.STATE_MAXIMIZED:
    1.42 +        dump("STATE_MAXIMIZED \n");
    1.43 +        break;
    1.44 +        case win.STATE_MINIMIZED:
    1.45 +        dump("STATE_MINIMIZED \n");
    1.46 +        break;
    1.47 +        case win.STATE_NORMAL:
    1.48 +        dump("STATE_NORMAL \n");
    1.49 +        break;
    1.50 +      }
    1.51 +      */
    1.52 +
    1.53 +      // Make sure size mode changes are reflected in the widget.
    1.54 +      win.restore();
    1.55 +      ok(win.windowState == win.STATE_NORMAL, "window state is restored.");
    1.56 +      win.minimize();
    1.57 +      ok(win.windowState == win.STATE_MINIMIZED, "window state is minimized.");
    1.58 +      
    1.59 +      // Windows resizes children to 0x0. Code in nsWindow filters these changes out. Without
    1.60 +      // this all sorts of screwy things can happen in child widgets.
    1.61 +      ok(document.height > 0, "document height should not be zero for a minimized window!");
    1.62 +      ok(document.width > 0, "document width should not be zero for a minimized window!");
    1.63 +      
    1.64 +      // Make sure size mode changes are reflected in the widget.
    1.65 +      win.restore();
    1.66 +      ok(win.windowState == win.STATE_NORMAL, "window state is restored.");
    1.67 +      win.maximize();
    1.68 +      ok(win.windowState == win.STATE_MAXIMIZED, "window state is maximized.");
    1.69 +      win.restore();
    1.70 +      ok(win.windowState == win.STATE_NORMAL, "window state is restored.");
    1.71 +
    1.72 +      /*
    1.73 +      dump(win.screenX + "\n");
    1.74 +      win.minimize();
    1.75 +      dump(win.screenX + "\n");
    1.76 +      win.restore();
    1.77 +      dump(win.screenX + "\n");
    1.78 +      */
    1.79 +      
    1.80 +      SimpleTest.finish();
    1.81 +    }
    1.82 +
    1.83 +  ]]>
    1.84 +  </script>
    1.85 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.86 +    <p id="display"></p>
    1.87 +    <div id="content" style="display: none"></div>
    1.88 +    <pre id="test"></pre>
    1.89 +  </body>
    1.90 +</window>

mercurial