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 (1621B)


      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>OffscreenCanvas 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 
      9 <h1>2d.text.measure.text-clusters-exceptions.tentative</h1>
     10 <p class="desc">Check that TextMetrics::getTextClusters() throws when using invalid indexes.</p>
     11 
     12 
     13 <script>
     14 var t = async_test("Check that TextMetrics::getTextClusters() throws when using invalid indexes.");
     15 var t_pass = t.done.bind(t);
     16 var t_fail = t.step_func(function(reason) {
     17    throw reason;
     18 });
     19 t.step(function() {
     20 
     21  var canvas = new OffscreenCanvas(100, 50);
     22  var ctx = canvas.getContext('2d');
     23 
     24  const kTexts = [
     25    'UNAVAILABLE',
     26    '🏁🎢🏁',
     27    'οΌ‰οΌˆγ‚οΌ‰οΌˆ',
     28    '-abcd_'
     29  ]
     30 
     31  for (const text of kTexts) {
     32    const tm = ctx.measureText(text);
     33    // Handled by the IDL binding.
     34    assert_throws_js(TypeError, () => tm.getTextClusters(-1, 0) );
     35    assert_throws_js(TypeError, () => tm.getTextClusters(0, -1) );
     36    assert_throws_js(TypeError, () => tm.getTextClusters(-1, -1) );
     37    // Thrown in TextMetrics.
     38    assert_throws_dom("IndexSizeError",
     39            () => tm.getTextClusters(text.length, 0) );
     40    assert_throws_dom("IndexSizeError",
     41            () => tm.getTextClusters(0, text.length + 1) );
     42    assert_throws_dom("IndexSizeError",
     43            () => tm.getTextClusters(text.length, text.length + 1) );
     44  }
     45  t.done();
     46 
     47 });
     48 </script>