tor-browser

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

2d.text.measure.text-clusters-exceptions.tentative.html (1700B)


      1 <!DOCTYPE html>
      2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
      3 <meta charset="UTF-8">
      4 <title>Canvas test: 2d.text.measure.text-clusters-exceptions.tentative</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/html/canvas/resources/canvas-tests.js"></script>
      8 <link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
      9 <body class="show_output">
     10 
     11 <h1>2d.text.measure.text-clusters-exceptions.tentative</h1>
     12 <p class="desc">Check that TextMetrics::getTextClusters() throws when using invalid indexes.</p>
     13 
     14 
     15 <p class="output">Actual output:</p>
     16 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
     17 
     18 <ul id="d"></ul>
     19 <script>
     20 var t = async_test("Check that TextMetrics::getTextClusters() throws when using invalid indexes.");
     21 _addTest(function(canvas, ctx) {
     22 
     23  const kTexts = [
     24    'UNAVAILABLE',
     25    '🏁🎢🏁',
     26    'οΌ‰οΌˆγ‚οΌ‰οΌˆ',
     27    '-abcd_'
     28  ]
     29 
     30  for (const text of kTexts) {
     31    const tm = ctx.measureText(text);
     32    // Handled by the IDL binding.
     33    assert_throws_js(TypeError, () => tm.getTextClusters(-1, 0) );
     34    assert_throws_js(TypeError, () => tm.getTextClusters(0, -1) );
     35    assert_throws_js(TypeError, () => tm.getTextClusters(-1, -1) );
     36    // Thrown in TextMetrics.
     37    assert_throws_dom("IndexSizeError",
     38            () => tm.getTextClusters(text.length, 0) );
     39    assert_throws_dom("IndexSizeError",
     40            () => tm.getTextClusters(0, text.length + 1) );
     41    assert_throws_dom("IndexSizeError",
     42            () => tm.getTextClusters(text.length, text.length + 1) );
     43  }
     44 
     45 });
     46 </script>