tor-browser

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

2d.text.measure.selection-rects-exceptions.tentative.worker.js (1555B)


      1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
      2 // OffscreenCanvas test in a worker:2d.text.measure.selection-rects-exceptions.tentative
      3 // Description:Check that TextMetrics::getSelectionRects() 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::getSelectionRects() 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    'bidiالرياضيات'
     26  ]
     27 
     28  for (const text of kTexts) {
     29    const tm = ctx.measureText(text);
     30    // Handled by the IDL binding.
     31    assert_throws_js(TypeError, () => tm.getSelectionRects(-1, 0) );
     32    assert_throws_js(TypeError, () => tm.getSelectionRects(0, -1) );
     33    assert_throws_js(TypeError, () => tm.getSelectionRects(-1, -1) );
     34    // Thrown in TextMetrics.
     35    assert_throws_dom("IndexSizeError",
     36                      () => tm.getSelectionRects(text.length + 1, 0) );
     37    assert_throws_dom("IndexSizeError",
     38                      () => tm.getSelectionRects(0, text.length + 1) );
     39    assert_throws_dom("IndexSizeError",
     40                      () => tm.getSelectionRects(text.length + 1, text.length + 1) );
     41  }
     42  t.done();
     43 });
     44 done();