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.

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

mercurial