tor-browser

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

device-pixel-ratio-ref.html (907B)


      1 <!DOCTYPE html>
      2 <html>
      3 <style>
      4 html, body { margin: 0; padding: 0; }
      5 canvas {width: 150px; height: 150px; }
      6 </style>
      7 <body>
      8 <p>This test ensures that the PaintWorkletGlobalScope.devicePixelRatio returns
      9 the correct value, which should be identical as window.devicePixelRatio. To
     10 manually test, open both this file and "device-pixel-ratio-ref.html" with a
     11 browser, and you should see two idential green rectangles.</p>
     12 <canvas id ="canvas" width="100" height="100"></canvas>
     13 <script>
     14 var canvas = document.getElementById('canvas');
     15 canvas.width = 150 * window.devicePixelRatio;
     16 canvas.height = 150 * window.devicePixelRatio;
     17 var context = canvas.getContext("2d");
     18 context.fillStyle = 'green';
     19 var draw_width = Math.floor(canvas.width / window.devicePixelRatio);
     20 var draw_height = Math.floor(canvas.height / window.devicePixelRatio);
     21 context.fillRect(0, 0, draw_width, draw_height);
     22 </script>
     23 </body>
     24 </html>