Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / tests / test_position_on_resize.xhtml
bloba7c55510180800f7c642bc6b1dbc082b71710276
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
4 type="text/css"?>
6 <window title="Window Position On Resize Test"
7 onload="startTest()"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
13 <script class="testbody" type="application/javascript"><![CDATA[
14 SimpleTest.waitForExplicitFinish();
15 let win, x, y;
17 function startTest() {
18 win = window.browsingContext.topChromeWindow.openDialog(
19 "about:blank",
20 null,
21 "chrome,dialog=no,outerHeight=170,outerWidth=200");
22 waitForSuccess(function() { return SpecialPowers.DOMWindowUtils.paintCount },
23 "No paint received", checkInitialSize);
26 function checkInitialSize() {
27 is(win.outerHeight,170, "initial outerHeight");
28 is(win.outerWidth, 200, "initial outerWidth");
29 x = win.screenX;
30 y = win.screenY;
31 shrink();
33 function shrink() {
34 win.resizeTo(180, 160);
35 waitForSuccess(function() { return win.outerHeight == 160 },
36 "outerHeight did not change to 160", checkShrink);
38 function checkShrink() {
39 is(win.outerWidth, 180, "resized outerWidth");
40 is(win.screenY, y, "resized window top should not change");
41 y = win.screenY;
42 restore();
44 function restore() {
45 win.resizeBy(20, 10);
46 waitForSuccess(function() { return win.outerHeight == 170 },
47 "outerHeight did not change to 170", checkRestore);
49 function checkRestore() {
50 is(win.outerWidth, 200, "restored outerWidth");
51 is(win.screenX, x, "restored window left should not change");
52 is(win.screenY, y, "restored window top should not change");
53 done();
55 function done() {
56 win.close();
57 SimpleTest.finish();
60 function waitForSuccess(testForSuccess, failureMsg, nextFunc) {
61 var waitCount = 0;
63 function repeatWait() {
64 ++waitCount;
66 if (testForSuccess()) {
67 nextFunc();
69 else if (waitCount > 50) {
70 ok(false, failureMsg);
71 nextFunc();
72 } else {
73 setTimeout(repeatWait, 100);
77 repeatWait();
79 ]]></script>
81 <body xmlns="http://www.w3.org/1999/xhtml">
82 <p id="display">
83 </p>
84 <div id="content" style="display: none">
85 </div>
86 <pre id="test">
87 </pre>
88 </body>
90 </window>