widget/tests/test_position_on_resize.xul

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:b9fd21f4c717
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"?>
5
6 <window title="Window Position On Resize Test"
7 onload="startTest()"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9
10 <script type="application/javascript"
11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
12 <script type="application/javascript"
13 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
14
15 <script class="testbody" type="application/javascript"><![CDATA[
16 SimpleTest.waitForExplicitFinish();
17 let win, x, y;
18
19 function startTest() {
20 win = window.openDialog("about:blank",
21 null,
22 "chrome,dialog=no,outerHeight=170,outerWidth=200");
23 waitForSuccess(function() { return win.mozPaintCount },
24 "No paint received", checkInitialSize);
25 }
26
27 function checkInitialSize() {
28 let runtime = Components.classes["@mozilla.org/xre/app-info;1"]
29 .getService(Components.interfaces.nsIXULRuntime);
30 let test = runtime.widgetToolkit == "windows" ? todo_is : is; // bug 602745
31 test(win.outerHeight,170, "initial outerHeight");
32 test(win.outerWidth, 200, "initial outerWidth");
33 x = win.screenX;
34 y = win.screenY;
35 shrink();
36 }
37 function shrink() {
38 win.resizeTo(180, 160);
39 waitForSuccess(function() { return win.outerHeight == 160 },
40 "outerHeight did not change to 160", checkShrink);
41 }
42 function checkShrink() {
43 is(win.outerWidth, 180, "resized outerWidth");
44 is(win.screenY, y, "resized window top should not change");
45 y = win.screenY;
46 restore();
47 }
48 function restore() {
49 win.resizeBy(20, 10);
50 waitForSuccess(function() { return win.outerHeight == 170 },
51 "outerHeight did not change to 170", checkRestore);
52 }
53 function checkRestore() {
54 is(win.outerWidth, 200, "restored outerWidth");
55 is(win.screenX, x, "restored window left should not change");
56 is(win.screenY, y, "restored window top should not change");
57 done();
58 }
59 function done() {
60 win.close();
61 SimpleTest.finish();
62 }
63
64 function waitForSuccess(testForSuccess, failureMsg, nextFunc) {
65 var waitCount = 0;
66
67 function repeatWait() {
68 ++waitCount;
69
70 if (testForSuccess()) {
71 nextFunc();
72 }
73 else if (waitCount > 50) {
74 ok(false, failureMsg);
75 nextFunc();
76 } else {
77 setTimeout(repeatWait, 100);
78 }
79 }
80
81 repeatWait();
82 }
83 ]]></script>
84
85 <body xmlns="http://www.w3.org/1999/xhtml">
86 <p id="display">
87 </p>
88 <div id="content" style="display: none">
89 </div>
90 <pre id="test">
91 </pre>
92 </body>
93
94 </window>

mercurial