tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_meta_viewport7.html (2655B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>meta viewport test</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      8  <meta name="viewport" content="width=320">
      9  <script src="viewport_helpers.js"></script>
     10 </head>
     11 <body>
     12  <p>Dynamic viewport updates</p>
     13  <script type="application/javascript">
     14    "use strict";
     15 
     16    add_task(async function test1() {
     17      await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
     18 
     19      updateViewport("width=device-width");
     20      let info = getViewportInfo(800, 480);
     21      is(info.defaultZoom, 1,    "initial zoom is 100%");
     22      is(info.width,       800,  "width is the same as the displayWidth");
     23      is(info.height,      480,  "height is the same as the displayHeight");
     24      is(info.autoSize,    true, "width=device-width enables autoSize");
     25      is(info.allowZoom,   true, "zooming is enabled by default");
     26 
     27      info = getViewportInfo(900, 600);
     28      is(info.width,       900,  "changing the displayWidth changes the width");
     29      is(info.height,      600,  "changing the displayHeight changes the height");
     30    });
     31 
     32    add_task(async function test2() {
     33      await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
     34 
     35      updateViewport("width=320");
     36      let info = getViewportInfo(800, 80);
     37      is(info.defaultZoom, 2.5,   "initial zoom fits the displayWidth");
     38      is(info.width,       320,   "width is set explicitly");
     39      is(info.height,      40,   "height is at the absolute minimum");
     40      is(info.autoSize,    false, "width=device-width enables autoSize");
     41      is(info.allowZoom,   true,  "zooming is enabled by default");
     42 
     43      info = getViewportInfo(480, 800);
     44      is(info.defaultZoom, 1.5,   "initial zoom fits the new displayWidth");
     45      is(info.width,       320,   "explicit width is unchanged");
     46      is(info.height,      533,   "height changes proportional to displayHeight");
     47    });
     48 
     49    add_task(async function test3() {
     50      await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
     51 
     52      updateViewport("user-scalable=no");
     53      let info = getViewportInfo(800, 480);
     54      is(info.allowZoom,   false, "zooming is explicitly disabled");
     55    });
     56 
     57    add_task(async function test4() {
     58      await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
     59 
     60      updateViewport("user-scalable=yes");
     61      let info = getViewportInfo(800, 480);
     62      is(info.allowZoom,   true,  "zooming is explicitly allowed");
     63    });
     64 
     65    function updateViewport(content) {
     66      let meta = document.querySelector("meta[name=viewport]");
     67      meta.content = content;
     68    }
     69  </script>
     70 </body>
     71 </html>