Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<title>Canvas test: 2d.text.measure.selection-rects-exceptions.tentative</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">
<h1>2d.text.measure.selection-rects-exceptions.tentative</h1>
<p class="desc">Check that TextMetrics::getSelectionRects() throws when using invalid indexes.</p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<ul id="d"></ul>
<script>
var t = async_test("Check that TextMetrics::getSelectionRects() throws when using invalid indexes.");
_addTest(function(canvas, ctx) {
const kTexts = [
'UNAVAILABLE',
'🏁🎶🏁',
')(あ)(',
'-abcd_',
'اين المكتبة؟',
'bidiالرياضيات'
]
for (const text of kTexts) {
const tm = ctx.measureText(text);
// Handled by the IDL binding.
assert_throws_js(TypeError, () => tm.getSelectionRects(-1, 0) );
assert_throws_js(TypeError, () => tm.getSelectionRects(0, -1) );
assert_throws_js(TypeError, () => tm.getSelectionRects(-1, -1) );
// Thrown in TextMetrics.
assert_throws_dom("IndexSizeError",
() => tm.getSelectionRects(text.length + 1, 0) );
assert_throws_dom("IndexSizeError",
() => tm.getSelectionRects(0, text.length + 1) );
assert_throws_dom("IndexSizeError",
() => tm.getSelectionRects(text.length + 1, text.length + 1) );
}
});
</script>