Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
// OffscreenCanvas test in a worker:2d.text.shape.selection-rects-exceptions.tentative
// Description:Check that ShapedText::selectionRects() throws when using invalid indexes.
// Note:
importScripts("/resources/testharness.js");
importScripts("/html/canvas/resources/canvas-tests.js");
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();
});
done();