|
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" type="text/css"?> |
|
4 <!-- |
|
5 https://bugzilla.mozilla.org/show_bug.cgi?id=602962 |
|
6 --> |
|
7 <window title="Mozilla Bug 602962" onload="openWindow()" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
9 |
|
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
11 |
|
12 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602962">Mozilla Bug 602962</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 </div> |
|
17 </body> |
|
18 |
|
19 <script class="testbody" type="application/javascript;version=1.8"><![CDATA[ |
|
20 /** Test for Bug 602962 **/ |
|
21 var scrollbox, sbo, content; |
|
22 var scrollX = 0, scrollY = 0; |
|
23 |
|
24 var oldWidth = 0, oldHeight = 0; |
|
25 var win = null; |
|
26 |
|
27 function openWindow() { |
|
28 win = window.open("chrome://mochitests/content/chrome/dom/events/test/bug602962.xul", "_blank", "width=600,height=600"); |
|
29 } |
|
30 |
|
31 function doTest() { |
|
32 scrollbox = win.document.getElementById("page-scrollbox"); |
|
33 sbo = scrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject); |
|
34 content = win.document.getElementById("page-box"); |
|
35 content.style.width = 400 + "px"; |
|
36 |
|
37 win.addEventListener("resize", function() { |
|
38 win.removeEventListener("resize", arguments.callee, false); |
|
39 |
|
40 sbo.scrollBy(200, 0); |
|
41 setTimeout(function() { resize(); }, 0); |
|
42 }, false); |
|
43 |
|
44 oldWidth = win.outerWidth; |
|
45 oldHeight = win.outerHeight; |
|
46 win.resizeTo(200, 400); |
|
47 } |
|
48 |
|
49 function resize() { |
|
50 let x = {}, y = {}; |
|
51 sbo.getPosition(x, y); |
|
52 scrollX = x.value, scrollY = y.value; |
|
53 |
|
54 win.addEventListener("resize", function() { |
|
55 content.style.width = (oldWidth + 400) + "px"; |
|
56 win.removeEventListener("resize", arguments.callee, true); |
|
57 |
|
58 setTimeout(function() { |
|
59 finish(); |
|
60 }, 0); |
|
61 }, true); |
|
62 |
|
63 win.resizeTo(oldWidth, oldHeight); |
|
64 } |
|
65 |
|
66 function finish() { |
|
67 if (win.outerWidth != oldWidth || |
|
68 win.outerHeight != oldHeight) { |
|
69 // We should eventually get back to the original size. |
|
70 setTimeout(finish, 0); |
|
71 return; |
|
72 } |
|
73 sbo.scrollBy(scrollX, scrollY); |
|
74 |
|
75 let x = {}, y = {}; |
|
76 sbo.getPosition(x, y); |
|
77 is(x.value, 200, "Scroll X should have been restored to the value before the resize"); |
|
78 is(y.value, 0, "Scroll Y should have been restored to the value before the resize"); |
|
79 |
|
80 is(win.outerWidth, oldWidth, "Width should be resized"); |
|
81 is(win.outerHeight, oldHeight, "Height should be resized"); |
|
82 win.close(); |
|
83 SimpleTest.finish(); |
|
84 } |
|
85 |
|
86 SimpleTest.waitForExplicitFinish(); |
|
87 ]]></script> |
|
88 |
|
89 </window> |