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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=886646 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 9 | <style type="text/css"> |
michael@0 | 10 | #scroller { |
michael@0 | 11 | width: 100px; |
michael@0 | 12 | height: 100px; |
michael@0 | 13 | padding: 10px; |
michael@0 | 14 | border: 10px solid black; |
michael@0 | 15 | margin: 10px; |
michael@0 | 16 | overflow: hidden; |
michael@0 | 17 | } |
michael@0 | 18 | #container { |
michael@0 | 19 | width: 50px; |
michael@0 | 20 | height: 50px; |
michael@0 | 21 | } |
michael@0 | 22 | #sticky { |
michael@0 | 23 | position: sticky; |
michael@0 | 24 | width: 10px; |
michael@0 | 25 | height: 10px; |
michael@0 | 26 | overflow: hidden; |
michael@0 | 27 | } |
michael@0 | 28 | </style> |
michael@0 | 29 | </head> |
michael@0 | 30 | <body> |
michael@0 | 31 | <div id="display"> |
michael@0 | 32 | <div id="scroller"> |
michael@0 | 33 | <div id="container"> |
michael@0 | 34 | <div id="sticky"></div> |
michael@0 | 35 | </div> |
michael@0 | 36 | </div> |
michael@0 | 37 | </div> |
michael@0 | 38 | <pre id="test"> |
michael@0 | 39 | <script type="application/javascript"> |
michael@0 | 40 | |
michael@0 | 41 | /** Test for Bug 886646 - sticky positioning offsets **/ |
michael@0 | 42 | |
michael@0 | 43 | // Use "is()", "ok()", and "todo()" from parent document. |
michael@0 | 44 | var is = parent.is; |
michael@0 | 45 | var ok = parent.ok; |
michael@0 | 46 | var todo = parent.todo; |
michael@0 | 47 | |
michael@0 | 48 | // Test that percentage sticky offsets are computed in terms of the |
michael@0 | 49 | // scroll container's content box |
michael@0 | 50 | var offsets = { |
michael@0 | 51 | "top": 10, |
michael@0 | 52 | "left": 20, |
michael@0 | 53 | "bottom": 30, |
michael@0 | 54 | "right": 40, |
michael@0 | 55 | }; |
michael@0 | 56 | var scroller = document.getElementById("scroller"); |
michael@0 | 57 | var container = document.getElementById("container"); |
michael@0 | 58 | var sticky = document.getElementById("sticky"); |
michael@0 | 59 | var cs = getComputedStyle(sticky, ""); |
michael@0 | 60 | |
michael@0 | 61 | for (var prop in offsets) { |
michael@0 | 62 | sticky.style[prop] = offsets[prop] + "%"; |
michael@0 | 63 | is(cs[prop], offsets[prop] + "px"); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | // ... even in the presence of scrollbars |
michael@0 | 67 | scroller.style.overflow = "scroll"; |
michael@0 | 68 | container.style.width = "100%"; |
michael@0 | 69 | container.style.height = "100%"; |
michael@0 | 70 | |
michael@0 | 71 | var ccs = getComputedStyle(container, ""); |
michael@0 | 72 | |
michael@0 | 73 | function isApproximatelyEqual(a, b) { |
michael@0 | 74 | return Math.abs(a - b) < 0.001; |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | for (var prop in offsets) { |
michael@0 | 78 | sticky.style[prop] = offsets[prop] + "%"; |
michael@0 | 79 | var basis = parseFloat(ccs[prop == "left" || prop == "right" ? |
michael@0 | 80 | "width" : "height"]) / 100; |
michael@0 | 81 | ok(isApproximatelyEqual(parseFloat(cs[prop]), offsets[prop] * basis)); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | parent.finish(); |
michael@0 | 85 | </script> |
michael@0 | 86 | </pre> |
michael@0 | 87 | </body> |
michael@0 | 88 | </html> |