tor-browser

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

canvas.2d.offscreen.lang.inherit.html (1965B)


      1 <!doctype HTML>
      2 <html lang="tr" class="reftest-wait">
      3  <meta charset="utf-8">
      4  <title>HTML5 Canvas Test:  The lang attribute is inherited from the document in offscreen canvas</title>
      5  <link rel="match" href="canvas.2d.offscreen.lang-ref.html" />
      6  <link rel="author" href="mailto:schenney@chromium.org"/>
      7  <link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles"/>
      8  <meta name="assert" content="An offscreen canvas inherits the lang from the document." />
      9  <script src="/common/reftest-wait.js"></script>
     10  <style>
     11    #canvas-tr {
     12      position: absolute;
     13      top: 10px;
     14      left: 10px;
     15    }
     16    #canvas-en {
     17      position: absolute;
     18      top: 120px;
     19      left: 10px;
     20    }
     21  </style>
     22  <script type="text/javascript">
     23    function drawText(language) {
     24      var canvas = document.getElementById('canvas-' + language);
     25      var bitmap_ctx = canvas.getContext('bitmaprenderer');
     26 
     27      var offscreen = new OffscreenCanvas(300, 100);
     28      var offscreen_ctx = offscreen.getContext('2d');
     29 
     30      offscreen_ctx.font = '25px Lato-Medium';
     31      offscreen_ctx.fillText('fi', 5, 50);
     32 
     33      const bitmap = offscreen.transferToImageBitmap();
     34      bitmap_ctx.transferFromImageBitmap(bitmap);
     35    }
     36 
     37    function runTest() {
     38      let test_font = new FontFace(
     39        // Lato-Medium is a font with language specific ligatures.
     40        "Lato-Medium",
     41        "url(/fonts/Lato-Medium.ttf)"
     42      );
     43 
     44      test_font.load().then((font) => {
     45        document.fonts.add(font);
     46        drawText('tr');
     47        document.documentElement.setAttribute('lang', 'en');
     48        drawText('en');
     49        takeScreenshot();
     50      });
     51    }
     52  </script>
     53  <body onload="runTest()">
     54    <canvas lang="tr" id="canvas-tr" width="300" height="100">
     55      Browser does not support HTML5 Canvas.
     56    </canvas>
     57    <canvas lang="en" id="canvas-en" width="300" height="100">
     58      Browser does not support HTML5 Canvas.
     59    </canvas>
     60  </body>
     61 </html>