Wed, 31 Dec 2014 06:09:35 +0100
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 | <head> |
michael@0 | 4 | <title>Scrolling by pages with fixed-pos headers and footers</title> |
michael@0 | 5 | <style> |
michael@0 | 6 | .fp { position:fixed; left:0; width:100%; } |
michael@0 | 7 | .fp2 { position:fixed; left:0; width:100%; } |
michael@0 | 8 | </style> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body onscroll="didScroll()" onload="test()"> |
michael@0 | 11 | <div class="fp" id="top" style="top:0; height:10px; background:yellow;"></div> |
michael@0 | 12 | <div class="fp2" id="top2" style="top:10px; height:11px; background:blue;"></div> |
michael@0 | 13 | <div class="fp" style="top:50%; height:7px; background:cyan;"></div> |
michael@0 | 14 | <div class="fp2" id="bottom2" style="bottom:9px; height:12px; background:red;"></div> |
michael@0 | 15 | <div class="fp" id="bottom" style="bottom:0; height:13px; background:yellow;"></div> |
michael@0 | 16 | <p id="target">Something to click on to get focus |
michael@0 | 17 | <div style="height:3000px;"></div> |
michael@0 | 18 | <pre id="test"> |
michael@0 | 19 | <script class="testbody"> |
michael@0 | 20 | var SimpleTest = window.opener.SimpleTest; |
michael@0 | 21 | var SpecialPowers = window.opener.SpecialPowers; |
michael@0 | 22 | var is = window.opener.is; |
michael@0 | 23 | |
michael@0 | 24 | function showElements(show, classname) { |
michael@0 | 25 | var elements = document.getElementsByClassName(classname); |
michael@0 | 26 | for (var i = 0; i < elements.length; ++i) { |
michael@0 | 27 | elements[i].style.display = show ? '' : 'none'; |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | function showFixedPosElements(show) { |
michael@0 | 31 | showElements(show, "fp"); |
michael@0 | 32 | } |
michael@0 | 33 | function showFixedPosElements2(show) { |
michael@0 | 34 | showElements(show, "fp2"); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | var nextCont; |
michael@0 | 38 | function didScroll() { |
michael@0 | 39 | var c = nextCont; |
michael@0 | 40 | nextCont = null; |
michael@0 | 41 | if (c) { |
michael@0 | 42 | c(); |
michael@0 | 43 | } |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function scrollDownOnePageWithContinuation(cont) { |
michael@0 | 47 | document.documentElement.scrollTop = 0; |
michael@0 | 48 | nextCont = cont; |
michael@0 | 49 | window.scrollByPages(1); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function test() { |
michael@0 | 53 | var smoothScrollPref = "general.smoothScroll"; |
michael@0 | 54 | SpecialPowers.setBoolPref(smoothScrollPref, false); |
michael@0 | 55 | |
michael@0 | 56 | showFixedPosElements(false); |
michael@0 | 57 | showFixedPosElements2(false); |
michael@0 | 58 | scrollDownOnePageWithContinuation(function() { |
michael@0 | 59 | var fullPageScrollDown = document.documentElement.scrollTop; |
michael@0 | 60 | |
michael@0 | 61 | showFixedPosElements(true); |
michael@0 | 62 | scrollDownOnePageWithContinuation(function() { |
michael@0 | 63 | var fullPageScrollDownWithHeaderAndFooter = document.documentElement.scrollTop; |
michael@0 | 64 | is(fullPageScrollDownWithHeaderAndFooter, fullPageScrollDown - (10 + 13), |
michael@0 | 65 | "Reduce scroll distance by size of small header and footer"); |
michael@0 | 66 | |
michael@0 | 67 | document.getElementById("bottom").style.height = (window.innerHeight - 20) + "px"; |
michael@0 | 68 | scrollDownOnePageWithContinuation(function() { |
michael@0 | 69 | is(document.documentElement.scrollTop, fullPageScrollDown - 10, |
michael@0 | 70 | "Ignore really big elements when reducing scroll size"); |
michael@0 | 71 | document.getElementById("bottom").style.height = "13px"; |
michael@0 | 72 | |
michael@0 | 73 | document.getElementById("top").style.width = "100px"; |
michael@0 | 74 | scrollDownOnePageWithContinuation(function() { |
michael@0 | 75 | is(document.documentElement.scrollTop, fullPageScrollDown - 13, |
michael@0 | 76 | "Ignore elements that don't span the entire viewport side"); |
michael@0 | 77 | document.getElementById("top").style.width = "100%"; |
michael@0 | 78 | |
michael@0 | 79 | showFixedPosElements2(true); |
michael@0 | 80 | scrollDownOnePageWithContinuation(function() { |
michael@0 | 81 | is(document.documentElement.scrollTop, fullPageScrollDown - (10 + 11 + 9 + 12), |
michael@0 | 82 | "Combine multiple overlapping elements"); |
michael@0 | 83 | |
michael@0 | 84 | // Scroll back up so test results are visible |
michael@0 | 85 | document.documentElement.scrollTop = 0; |
michael@0 | 86 | SpecialPowers.clearUserPref(smoothScrollPref); |
michael@0 | 87 | SimpleTest.finish(); |
michael@0 | 88 | window.close(); |
michael@0 | 89 | }); |
michael@0 | 90 | }); |
michael@0 | 91 | }); |
michael@0 | 92 | }); |
michael@0 | 93 | }); |
michael@0 | 94 | } |
michael@0 | 95 | </script> |
michael@0 | 96 | </pre> |
michael@0 | 97 | </body> |
michael@0 | 98 | </html> |