tor-browser

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

test_media_queries_with_zoom.html (1137B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Media Queries with Zoom</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
      7 </head>
      8 
      9 <body>
     10 
     11 <div>Testing media queries with different zoom levels</div>
     12 
     13 <script type="application/javascript">
     14 
     15 const originalDPR = window.devicePixelRatio;
     16 const originalZoom = SpecialPowers.getFullZoom(window);
     17 
     18 const zoomsToTest = [
     19 300,
     20 240,
     21 200,
     22 170,
     23 150,
     24 133,
     25 120,
     26 110,
     27 100,
     28 90,
     29 80,
     30 67,
     31 50,
     32 30,
     33 ];
     34 
     35 for (let i = 0; i < zoomsToTest.length; ++i) {
     36  let zoomPercent = zoomsToTest[i];
     37 
     38  let relativeZoom = originalZoom * zoomPercent / 100;
     39  SpecialPowers.setFullZoom(window, relativeZoom);
     40  let actualZoom = SpecialPowers.getDeviceFullZoom(window);
     41  let targetDPR = (originalDPR * actualZoom);
     42  let actualDPR = window.devicePixelRatio;
     43  let mql = window.matchMedia(`(resolution: ${targetDPR}dppx)`);
     44  ok(mql.matches, `At ${zoomPercent}% zoom, target ${targetDPR}dppx matches ${actualDPR}dppx.`);
     45 }
     46 
     47 // Reset the zoom when the test is done.
     48 SpecialPowers.setFullZoom(window, originalZoom);
     49 </script>
     50 
     51 </body>
     52 </html>