1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug602962.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 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" type="text/css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=602962 1.9 +--> 1.10 +<window title="Mozilla Bug 602962" onload="openWindow()" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.14 + 1.15 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.16 + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602962">Mozilla Bug 602962</a> 1.17 + <p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 +</div> 1.20 +</body> 1.21 + 1.22 +<script class="testbody" type="application/javascript;version=1.8"><![CDATA[ 1.23 +/** Test for Bug 602962 **/ 1.24 +var scrollbox, sbo, content; 1.25 +var scrollX = 0, scrollY = 0; 1.26 + 1.27 +var oldWidth = 0, oldHeight = 0; 1.28 +var win = null; 1.29 + 1.30 +function openWindow() { 1.31 + win = window.open("chrome://mochitests/content/chrome/dom/events/test/bug602962.xul", "_blank", "width=600,height=600"); 1.32 +} 1.33 + 1.34 +function doTest() { 1.35 + scrollbox = win.document.getElementById("page-scrollbox"); 1.36 + sbo = scrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject); 1.37 + content = win.document.getElementById("page-box"); 1.38 + content.style.width = 400 + "px"; 1.39 + 1.40 + win.addEventListener("resize", function() { 1.41 + win.removeEventListener("resize", arguments.callee, false); 1.42 + 1.43 + sbo.scrollBy(200, 0); 1.44 + setTimeout(function() { resize(); }, 0); 1.45 + }, false); 1.46 + 1.47 + oldWidth = win.outerWidth; 1.48 + oldHeight = win.outerHeight; 1.49 + win.resizeTo(200, 400); 1.50 +} 1.51 + 1.52 +function resize() { 1.53 + let x = {}, y = {}; 1.54 + sbo.getPosition(x, y); 1.55 + scrollX = x.value, scrollY = y.value; 1.56 + 1.57 + win.addEventListener("resize", function() { 1.58 + content.style.width = (oldWidth + 400) + "px"; 1.59 + win.removeEventListener("resize", arguments.callee, true); 1.60 + 1.61 + setTimeout(function() { 1.62 + finish(); 1.63 + }, 0); 1.64 + }, true); 1.65 + 1.66 + win.resizeTo(oldWidth, oldHeight); 1.67 +} 1.68 + 1.69 +function finish() { 1.70 + if (win.outerWidth != oldWidth || 1.71 + win.outerHeight != oldHeight) { 1.72 + // We should eventually get back to the original size. 1.73 + setTimeout(finish, 0); 1.74 + return; 1.75 + } 1.76 + sbo.scrollBy(scrollX, scrollY); 1.77 + 1.78 + let x = {}, y = {}; 1.79 + sbo.getPosition(x, y); 1.80 + is(x.value, 200, "Scroll X should have been restored to the value before the resize"); 1.81 + is(y.value, 0, "Scroll Y should have been restored to the value before the resize"); 1.82 + 1.83 + is(win.outerWidth, oldWidth, "Width should be resized"); 1.84 + is(win.outerHeight, oldHeight, "Height should be resized"); 1.85 + win.close(); 1.86 + SimpleTest.finish(); 1.87 +} 1.88 + 1.89 +SimpleTest.waitForExplicitFinish(); 1.90 +]]></script> 1.91 + 1.92 +</window>