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/element/text/2d.text.measure.text-clusters-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>Canvas test: 2d.text.measure.text-clusters-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.text-clusters-exceptions.tentative</h1>
<p class="desc">Check that TextMetrics::getTextClusters() 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::getTextClusters() throws when using invalid indexes.");
_addTest(function(canvas, ctx) {
const kTexts = [
'UNAVAILABLE',
'ππΆπ',
'οΌοΌγοΌοΌ',
'-abcd_'
]
for (const text of kTexts) {
const tm = ctx.measureText(text);
// Handled by the IDL binding.
assert_throws_js(TypeError, () => tm.getTextClusters(-1, 0) );
assert_throws_js(TypeError, () => tm.getTextClusters(0, -1) );
assert_throws_js(TypeError, () => tm.getTextClusters(-1, -1) );
// Thrown in TextMetrics.
assert_throws_dom("IndexSizeError",
() => tm.getTextClusters(text.length, 0) );
assert_throws_dom("IndexSizeError",
() => tm.getTextClusters(0, text.length + 1) );
assert_throws_dom("IndexSizeError",
() => tm.getTextClusters(text.length, text.length + 1) );
}
});
</script>