tor-browser

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

replaced-element-022.html (1036B)


      1 <!DOCTYPE html>
      2 <html>
      3  <title>CSS aspect-ratio: canvas with aspect-ratio, object-fit and object-position</title>
      4  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
      5  <link rel="author" title="Mozilla" href="https://www.mozilla.org/">
      6  <link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio">
      7  <link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
      8  <meta name="assert" content="This test verifies aspect-ratio affects the canvas element's ratio, but not the canvas content's ratio.">
      9 
     10  <style>
     11  canvas {
     12    width: 100px;
     13    aspect-ratio: 1/3;
     14    object-fit: contain;
     15    object-position: top left;
     16  }
     17  </style>
     18 
     19  <script>
     20  window.onload = function() {
     21    const canvas = document.querySelector('canvas');
     22    const ctx = canvas.getContext('2d');
     23    ctx.fillStyle = 'green';
     24    ctx.fillRect(0, 0, 200, 200);
     25  }
     26  </script>
     27 
     28  <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
     29  <canvas width=200 height=200></canvas>
     30 </html>