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.measure.getActualBoundingBox-exceptions.tentative.worker.html - WPT Dashboard Interop Dashboard
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
// OffscreenCanvas test in a worker:2d.text.measure.getActualBoundingBox-exceptions.tentative
// Description:Check that TextMetrics::getActualBoundingBox() throws when using invalid indexes.
// Note:
importScripts("/resources/testharness.js");
importScripts("/html/canvas/resources/canvas-tests.js");
var t = async_test("Check that TextMetrics::getActualBoundingBox() 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 tm = ctx.measureText(text);
// Handled by the IDL binding.
assert_throws_js(TypeError, () => tm.getActualBoundingBox(-1, 0) );
assert_throws_js(TypeError, () => tm.getActualBoundingBox(0, -1) );
assert_throws_js(TypeError, () => tm.getActualBoundingBox(-1, -1) );
// Thrown in TextMetrics.
assert_throws_dom("IndexSizeError",
() => tm.getActualBoundingBox(text.length, 0) );
assert_throws_dom("IndexSizeError",
() => tm.getActualBoundingBox(0, text.length + 1) );
assert_throws_dom("IndexSizeError",
() => tm.getActualBoundingBox(text.length, text.length + 1) );
}
t.done();
});
done();