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=474356 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 474356</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | <style>.zoom-test { visibility: hidden; }</style> |
michael@0 | 11 | <style><!-- placeholder for dynamic additions --></style> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body onload="run()"> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=474356">Mozilla Bug 474356</a> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | |
michael@0 | 17 | </div> |
michael@0 | 18 | <script type="text/javascript"> |
michael@0 | 19 | </script> |
michael@0 | 20 | <pre id="test"> |
michael@0 | 21 | <div id="zoom1" class="zoom-test"></div> |
michael@0 | 22 | <div id="zoom2" class="zoom-test"></div> |
michael@0 | 23 | <div id="zoom3" class="zoom-test"></div> |
michael@0 | 24 | <script class="testbody" type="application/javascript"> |
michael@0 | 25 | |
michael@0 | 26 | /** Test for Bug 474356 **/ |
michael@0 | 27 | |
michael@0 | 28 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 29 | |
michael@0 | 30 | function run() { |
michael@0 | 31 | function zoom(factor) { |
michael@0 | 32 | var previous = SpecialPowers.getFullZoom(window); |
michael@0 | 33 | SpecialPowers.setFullZoom(window, factor); |
michael@0 | 34 | return previous; |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function isVisible(divName) { |
michael@0 | 38 | return window.getComputedStyle(document.getElementById(divName), null).visibility == "visible"; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function getScreenPixelsPerCSSPixel() { |
michael@0 | 42 | return SpecialPowers.DOMWindowUtils.screenPixelsPerCSSPixel; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | var screenPixelsPerCSSPixel = getScreenPixelsPerCSSPixel(); |
michael@0 | 46 | var baseRatio = 1.0 * screenPixelsPerCSSPixel; |
michael@0 | 47 | var doubleRatio = 2.0 * screenPixelsPerCSSPixel; |
michael@0 | 48 | var halfRatio = 0.5 * screenPixelsPerCSSPixel; |
michael@0 | 49 | var styleElem = document.getElementsByTagName("style")[1]; |
michael@0 | 50 | styleElem.textContent = |
michael@0 | 51 | ["@media all and (-moz-device-pixel-ratio: " + baseRatio + ") {", |
michael@0 | 52 | "#zoom1 { visibility: visible; }", |
michael@0 | 53 | "}", |
michael@0 | 54 | "@media all and (-moz-device-pixel-ratio: " + doubleRatio + ") {", |
michael@0 | 55 | "#zoom2 { visibility: visible; }", |
michael@0 | 56 | "}", |
michael@0 | 57 | "@media all and (-moz-device-pixel-ratio: " + halfRatio + ") {", |
michael@0 | 58 | "#zoom3 { visibility: visible; }", |
michael@0 | 59 | "}" |
michael@0 | 60 | ].join("\n"); |
michael@0 | 61 | |
michael@0 | 62 | ok(isVisible("zoom1"), "Base ratio rule should apply at base zoom level"); |
michael@0 | 63 | ok(!isVisible("zoom2") && !isVisible("zoom3"), "no other rules should apply"); |
michael@0 | 64 | var origZoom = zoom(2); |
michael@0 | 65 | ok(isVisible("zoom2"), "Double ratio rule should apply at double zoom level"); |
michael@0 | 66 | ok(!isVisible("zoom1") && !isVisible("zoom3"), "no other rules should apply"); |
michael@0 | 67 | zoom(0.5); |
michael@0 | 68 | ok(isVisible("zoom3"), "Half ratio rule should apply at half zoom level"); |
michael@0 | 69 | ok(!isVisible("zoom1") && !isVisible("zoom2"), "no other rules should apply"); |
michael@0 | 70 | zoom(origZoom); |
michael@0 | 71 | |
michael@0 | 72 | SimpleTest.finish(); |
michael@0 | 73 | } |
michael@0 | 74 | </script> |
michael@0 | 75 | </pre> |
michael@0 | 76 | </body> |
michael@0 | 77 | </html> |