content/base/test/test_meta_viewport6.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.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <meta charset="utf-8">
     5   <title>meta viewport test</title>
     6   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     8   <meta name="viewport" content="width=2000, minimum-scale=0.75">
     9   <script src="viewport_helpers.js"></script>
    10 </head>
    11 <body>
    12   <p>width=2000, minimum-scale=0.75</p>
    13   <script type="application/javascript;version=1.7">
    14     "use strict";
    16     SimpleTest.waitForExplicitFinish();
    18     let tests = [];
    20     tests.push(function test1() {
    21       SpecialPowers.pushPrefEnv(scaleRatio(1.0),
    22         function() {
    23           let info = getViewportInfo(800, 480);
    24           is(info.minZoom,     0.75,    "minumum scale is set explicitly");
    25           is(info.defaultZoom, 0.75,    "initial scale is bounded by the minimum scale");
    26           is(info.maxZoom,     10,      "maximum scale defaults to the absolute maximum");
    27           is(info.width,       2000,    "width is set explicitly");
    28           is(info.height,      1200,    "height is proportional to displayHeight");
    29           is(info.autoSize,    false,   "autoSize is disabled by default");
    30           is(info.allowZoom,   true,    "zooming is enabled by default");
    32           info = getViewportInfo(2000, 1000);
    33           is(info.minZoom,     0.75,    "minumum scale is still set explicitly");
    34           is(info.defaultZoom, 1,       "initial scale fits the width");
    35           is(info.width,       2000,    "width is set explicitly");
    36           is(info.height,      1000,    "height is proportional to the new displayHeight");
    38           nextTest();
    39         });
    40     });
    42     tests.push(function test2() {
    43       SpecialPowers.pushPrefEnv(scaleRatio(1.5),
    44         function() {
    45           let info = getViewportInfo(800, 480);
    46           is(info.minZoom,     1.125,   "minumum scale is converted to device pixel scale");
    47           is(info.defaultZoom, 1.125,   "initial scale is bounded by the minimum scale");
    48           is(info.maxZoom,     15,      "maximum scale defaults to the absolute maximum");
    49           is(info.width,       2000,    "width is still set explicitly");
    50           is(info.height,      1200,    "height is still proportional to displayHeight");
    52           nextTest();
    53         });
    54     });
    56     function getViewportInfo(aDisplayWidth, aDisplayHeight) {
    57       let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
    58           width = {}, height = {}, autoSize = {};
    60       let cwu = SpecialPowers.getDOMWindowUtils(window);
    61       cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
    62                           minZoom, maxZoom, width, height, autoSize);
    63       return {
    64         defaultZoom: defaultZoom.value,
    65         minZoom: minZoom.value,
    66         maxZoom: maxZoom.value,
    67         width: width.value,
    68         height: height.value,
    69         autoSize: autoSize.value,
    70         allowZoom: allowZoom.value
    71       };
    72     }
    74     function nextTest() {
    75       if (tests.length)
    76         (tests.shift())();
    77       else
    78         SimpleTest.finish();
    79     }
    80     addEventListener("load", nextTest);
    81   </script>
    82 </body>
    83 </html>

mercurial