docshell/test/navigation/test_bug430723.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=430723
     5 -->
     6 <head>
     7   <title>Test for Bug 430723</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=430723">Mozilla Bug 430723</a>
    14 <p id="display"></p>
    15 <div id="content" style="display: none">
    17 </div>
    18 <pre id="test">
    19 <script class="testbody" type="text/javascript">
    20 //<![CDATA[
    22 /** Test for Bug 430723 **/
    24 var gTallRedBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOnJlZCI%2BPHA%2BVGhpcyBpcyBhIHZlcnkgdGFsbCByZWQgYm94LjwvcD48L2Rpdj48L2JvZHk%2BPC9odG1sPg%3D%3D";
    25 // <html><head>
    26 // < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script > 
    27 // </head><body>
    28 // <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:red">
    29 // <p>This is a very tall red box.</p>
    30 // </div></body></html>
    32 var gTallBlueBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOmJsdWUiPjxwPlRoaXMgaXMgYSB2ZXJ5IHRhbGwgYmx1ZSBib3guPC9wPjwvZGl2PjwvYm9keT48L2h0bWw%2B";
    33 // <html><head>
    34 // < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script > 
    35 // </head><body>
    36 // <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:blue">
    37 // <p>This is a very tall blue box.</p>
    38 // </div></body></html>
    41 window.onload = runTest;
    43 var testWindow;
    44 var testNum = 0;
    46 var smoothScrollPref = "general.smoothScroll";
    47 function runTest() {
    48   SpecialPowers.setBoolPref(smoothScrollPref, false);
    49   testWindow = window.open(gTallRedBoxURI, "testWindow", "width=300,height=300,location=yes,scrollbars=yes");
    50 }
    52 var nextTest =function() {
    53   testNum++;
    54   switch (testNum) {
    55     case 1: setTimeout(step1, 0); break;
    56     case 2: setTimeout(step2, 0); break;
    57     case 3: setTimeout(step3, 0); break;
    58   };
    59 }
    61 var step1 =function() {
    62   window.is(testWindow.location, gTallRedBoxURI, "Ensure red page loaded.");
    64   // Navigate down and up.
    65   is(testWindow.document.body.scrollTop, 0,
    66      "Page1: Ensure the scrollpane is at the top before we start scrolling.");
    67   testWindow.addEventListener("scroll", function () {
    68     testWindow.removeEventListener("scroll", arguments.callee, true);
    69     isnot(testWindow.document.body.scrollTop, 0,
    70           "Page1: Ensure we can scroll down.");
    71     SimpleTest.executeSoon(step1_2);
    72   }, true);
    73   sendKey('DOWN', testWindow);
    75   function step1_2() {
    76     testWindow.addEventListener("scroll", function () {
    77       testWindow.removeEventListener("scroll", arguments.callee, true);
    78       is(testWindow.document.body.scrollTop, 0,
    79          "Page1: Ensure we can scroll up, back to the top.");  
    81       // Nav to blue box page. This should fire step2.
    82       testWindow.location = gTallBlueBoxURI;
    83     }, true);
    84     sendKey('UP', testWindow);
    85   }
    86 }
    89 var step2 =function() {    
    90   window.is(testWindow.location, gTallBlueBoxURI, "Ensure blue page loaded.");
    92   // Scroll around a bit.
    93   is(testWindow.document.body.scrollTop, 0,
    94      "Page2: Ensure the scrollpane is at the top before we start scrolling.");
    96   var count = 0;
    97   testWindow.addEventListener("scroll", function () {
    98     if (++count < 2) {
    99       SimpleTest.executeSoon(function () { sendKey('DOWN', testWindow); });
   100     } else {
   101       testWindow.removeEventListener("scroll", arguments.callee, true);
   103       isnot(testWindow.document.body.scrollTop, 0,
   104             "Page2: Ensure we could scroll.");
   106       // Navigate backwards. This should fire step3.
   107       testWindow.history.back();
   108     }
   109   }, true);
   110   sendKey('DOWN', testWindow);
   111 }
   113 var step3 =function() {
   114   window.is(testWindow.location, gTallRedBoxURI,
   115             "Ensure red page restored from history.");
   117   // Check we can still scroll with the keys.
   118   is(testWindow.document.body.scrollTop, 0,
   119      "Page1Again: Ensure scroll pane at top before we scroll.");  
   120   testWindow.addEventListener("scroll", function () {
   121     testWindow.removeEventListener("scroll", arguments.callee, true);
   123     isnot(testWindow.document.body.scrollTop, 0,
   124           "Page2Again: Ensure we can still scroll.");  
   126     testWindow.close();
   127     SpecialPowers.clearUserPref(smoothScrollPref);
   128     window.SimpleTest.finish();
   129   }, true);
   130   sendKey('DOWN', testWindow);
   131 }
   133 SimpleTest.waitForExplicitFinish();
   135 //]]>
   136 </script>
   137 </pre>
   138 </body>
   139 </html>

mercurial