Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/offscreen/text/2d.text.shape.selection-rects-exceptions.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<title>OffscreenCanvas test: 2d.text.shape.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>
<h1>2d.text.shape.selection-rects-exceptions.tentative</h1>
<p class="desc">Check that ShapedText::selectionRects() throws when using invalid indexes.</p>
<script>
var t = async_test("Check that ShapedText::selectionRects() throws when using invalid indexes.");
var t_pass = t.done.bind(t);
var t_fail = t.step_func(function(reason) {
throw reason;
});
t.step(function() {
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');
const kTexts = [
'UNAVAILABLE',
'🏁🎶🏁',
')(あ)(',
'-abcd_',
'اين المكتبة؟',
'bidiالرياضيات'
]
for (const text of kTexts) {
const st = ctx.shapeText(text);
// Handled by the IDL binding.
assert_throws_js(TypeError, () => st.selectionRects(-1, 0) );
assert_throws_js(TypeError, () => st.selectionRects(0, -1) );
assert_throws_js(TypeError, () => st.selectionRects(-1, -1) );
// Thrown in ShapedText.
assert_throws_dom("IndexSizeError",
() => st.selectionRects(text.length + 1, 0) );
assert_throws_dom("IndexSizeError",
() => st.selectionRects(0, text.length + 1) );
assert_throws_dom("IndexSizeError",
() => st.selectionRects(text.length + 1, text.length + 1) );
}
t.done();
});
</script>