tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug602962.xhtml (2460B)


      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 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"><![CDATA[
     20 /** Test for Bug 602962 */
     21 var scrollbox, 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.xhtml", "_blank", "width=600,height=600");
     29 }
     30 
     31 function doTest() {
     32  scrollbox = win.document.getElementById("page-scrollbox");
     33  content = win.document.getElementById("page-box");
     34  content.style.width = 400 + "px";
     35 
     36  win.addEventListener("resize", function() {
     37    setTimeout(function(){
     38      scrollbox.scrollBy(200,0);
     39      resize();
     40    },0);
     41  }, { once: true });
     42 
     43  oldWidth = win.outerWidth;
     44  oldHeight = win.outerHeight;
     45  win.resizeTo(200, 400);
     46 }
     47 
     48 function resize() {
     49 scrollX = scrollbox.scrollLeft;
     50 scrollY = scrollbox.scrollTop;
     51 
     52  win.addEventListener("resize", function() {
     53    content.style.width = (oldWidth + 400) + "px";
     54    win.removeEventListener("resize", arguments.callee, true);
     55 
     56    setTimeout(function() {
     57      finish();
     58    }, 0);
     59  }, true);
     60 
     61  win.resizeTo(oldWidth, oldHeight);
     62 }
     63 
     64 function finish() {
     65  if (win.outerWidth != oldWidth ||
     66      win.outerHeight != oldHeight) {
     67    // We should eventually get back to the original size.
     68    setTimeout(finish, 0);
     69    return;
     70  }
     71  scrollbox.scrollBy(scrollX, scrollY);
     72 
     73  is(scrollbox.scrollLeft, 200, "Scroll Left should have been restored to the value before the resize");
     74  is(scrollbox.scrollTop, 0, "Scroll Top should have been restored to the value before the resize");
     75 
     76  is(win.outerWidth, oldWidth, "Width should be resized");
     77  is(win.outerHeight, oldHeight, "Height should be resized");
     78  win.close();
     79  SimpleTest.finish();
     80 }
     81 
     82 SimpleTest.waitForExplicitFinish();
     83 ]]></script>
     84 
     85 </window>