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.worker.js (1438B)


      1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
      2 // OffscreenCanvas test in a worker:2d.text.measure.text-clusters-exceptions.tentative
      3 // Description:Check that TextMetrics::getTextClusters() throws when using invalid indexes.
      4 // Note:
      5 
      6 importScripts("/resources/testharness.js");
      7 importScripts("/html/canvas/resources/canvas-tests.js");
      8 
      9 var t = async_test("Check that TextMetrics::getTextClusters() throws when using invalid indexes.");
     10 var t_pass = t.done.bind(t);
     11 var t_fail = t.step_func(function(reason) {
     12    throw reason;
     13 });
     14 t.step(function() {
     15 
     16  var canvas = new OffscreenCanvas(100, 50);
     17  var ctx = canvas.getContext('2d');
     18 
     19  const kTexts = [
     20    'UNAVAILABLE',
     21    '🏁🎢🏁',
     22    'οΌ‰οΌˆγ‚οΌ‰οΌˆ',
     23    '-abcd_'
     24  ]
     25 
     26  for (const text of kTexts) {
     27    const tm = ctx.measureText(text);
     28    // Handled by the IDL binding.
     29    assert_throws_js(TypeError, () => tm.getTextClusters(-1, 0) );
     30    assert_throws_js(TypeError, () => tm.getTextClusters(0, -1) );
     31    assert_throws_js(TypeError, () => tm.getTextClusters(-1, -1) );
     32    // Thrown in TextMetrics.
     33    assert_throws_dom("IndexSizeError",
     34            () => tm.getTextClusters(text.length, 0) );
     35    assert_throws_dom("IndexSizeError",
     36            () => tm.getTextClusters(0, text.length + 1) );
     37    assert_throws_dom("IndexSizeError",
     38            () => tm.getTextClusters(text.length, text.length + 1) );
     39  }
     40  t.done();
     41 });
     42 done();