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.html (1819B)


      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.selection-rects-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.selection-rects-exceptions.tentative</h1>
     12 <p class="desc">Check that TextMetrics::getSelectionRects() 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::getSelectionRects() throws when using invalid indexes.");
     21 _addTest(function(canvas, ctx) {
     22 
     23  const kTexts = [
     24    'UNAVAILABLE',
     25    '🏁🎶🏁',
     26    ')(あ)(',
     27    '-abcd_',
     28    'اين المكتبة؟',
     29    'bidiالرياضيات'
     30  ]
     31 
     32  for (const text of kTexts) {
     33    const tm = ctx.measureText(text);
     34    // Handled by the IDL binding.
     35    assert_throws_js(TypeError, () => tm.getSelectionRects(-1, 0) );
     36    assert_throws_js(TypeError, () => tm.getSelectionRects(0, -1) );
     37    assert_throws_js(TypeError, () => tm.getSelectionRects(-1, -1) );
     38    // Thrown in TextMetrics.
     39    assert_throws_dom("IndexSizeError",
     40                      () => tm.getSelectionRects(text.length + 1, 0) );
     41    assert_throws_dom("IndexSizeError",
     42                      () => tm.getSelectionRects(0, text.length + 1) );
     43    assert_throws_dom("IndexSizeError",
     44                      () => tm.getSelectionRects(text.length + 1, text.length + 1) );
     45  }
     46 
     47 });
     48 </script>