widget/tests/test_position_on_resize.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/tests/test_position_on_resize.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.7 +                 type="text/css"?>
     1.8 +
     1.9 +<window title="Window Position On Resize Test"
    1.10 +        onload="startTest()"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.15 +  <script type="application/javascript"
    1.16 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    1.17 +
    1.18 +<script class="testbody" type="application/javascript"><![CDATA[
    1.19 +  SimpleTest.waitForExplicitFinish();
    1.20 +  let win, x, y;
    1.21 +
    1.22 +  function startTest() {
    1.23 +    win = window.openDialog("about:blank",
    1.24 +                            null,
    1.25 +                            "chrome,dialog=no,outerHeight=170,outerWidth=200");
    1.26 +    waitForSuccess(function() { return win.mozPaintCount },
    1.27 +                   "No paint received", checkInitialSize);
    1.28 +  }
    1.29 +
    1.30 +  function checkInitialSize() {
    1.31 +    let runtime = Components.classes["@mozilla.org/xre/app-info;1"]
    1.32 +                            .getService(Components.interfaces.nsIXULRuntime);
    1.33 +    let test = runtime.widgetToolkit == "windows" ? todo_is : is; // bug 602745
    1.34 +    test(win.outerHeight,170, "initial outerHeight");
    1.35 +    test(win.outerWidth, 200, "initial outerWidth");
    1.36 +    x = win.screenX;
    1.37 +    y = win.screenY;
    1.38 +    shrink();
    1.39 +  }
    1.40 +  function shrink() {
    1.41 +    win.resizeTo(180, 160);
    1.42 +    waitForSuccess(function() { return win.outerHeight == 160 },
    1.43 +                   "outerHeight did not change to 160", checkShrink);
    1.44 +  }
    1.45 +  function checkShrink() {
    1.46 +    is(win.outerWidth, 180, "resized outerWidth");
    1.47 +    is(win.screenY, y, "resized window top should not change");
    1.48 +    y = win.screenY;
    1.49 +    restore();
    1.50 +  }
    1.51 +  function restore() {
    1.52 +    win.resizeBy(20, 10);
    1.53 +    waitForSuccess(function() { return win.outerHeight == 170 },
    1.54 +                   "outerHeight did not change to 170", checkRestore);
    1.55 +  }
    1.56 +  function checkRestore() {
    1.57 +    is(win.outerWidth, 200, "restored outerWidth");
    1.58 +    is(win.screenX, x, "restored window left should not change");
    1.59 +    is(win.screenY, y, "restored window top should not change");
    1.60 +    done();
    1.61 +  }
    1.62 +  function done() {
    1.63 +    win.close();
    1.64 +    SimpleTest.finish();
    1.65 +  }
    1.66 +
    1.67 +  function waitForSuccess(testForSuccess, failureMsg, nextFunc) {
    1.68 +    var waitCount = 0;
    1.69 +
    1.70 +    function repeatWait() {
    1.71 +      ++waitCount;
    1.72 +
    1.73 +      if (testForSuccess()) {
    1.74 +        nextFunc();
    1.75 +      }
    1.76 +      else if (waitCount > 50) {
    1.77 +        ok(false, failureMsg);
    1.78 +        nextFunc();
    1.79 +      } else {
    1.80 +        setTimeout(repeatWait, 100);
    1.81 +      }
    1.82 +    }
    1.83 +
    1.84 +    repeatWait();
    1.85 +  }
    1.86 +]]></script>
    1.87 +
    1.88 +<body xmlns="http://www.w3.org/1999/xhtml">
    1.89 +<p id="display">
    1.90 +</p>
    1.91 +<div id="content" style="display: none">
    1.92 +</div>
    1.93 +<pre id="test">
    1.94 +</pre>
    1.95 +</body>
    1.96 +
    1.97 +</window>

mercurial