layout/style/test/test_moz_device_pixel_ratio.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial