Bug 1846833 [wpt PR 41296] - Make beginLayer a no-op if the filter parsing throws an exception., a=testonly

Automatic update from web-platform-tests
Make beginLayer a no-op if the filter parsing throws an exception.

Bug: 1396372
Change-Id: I55cdddb7227a136428fe859ec8bfa25821d6f2cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4743183
Commit-Queue: Jean-Philippe Gravel <[email protected]>
Reviewed-by: Justin Novosad <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1179614}

--

wpt-commits: 3d80f7e87928e2d0da25d1c60a13dab001332139
wpt-pr: 41296
This commit is contained in:
Jean-Philippe Gravel authored and moz-wptsync-bot committed 2023-08-17 21:34:21 +00:00
1 parent f617b4e26a
commit 2045083b0e
4 files changed
+100

No files matched your search

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.layer.exceptions-are-no-op</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.layer.exceptions-are-no-op</h1>
<p class="desc">Checks that the context state is left unchanged if beginLayer throws.</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("Checks that the context state is left unchanged if beginLayer throws.");
_addTest(function(canvas, ctx) {
// Get `beginLayer` to throw while parsing the filter.
assert_throws_js(TypeError,
() => ctx.beginLayer({filter: {name: 'colorMatrix',
values: 'foo'}}));
// `beginLayer` shouldn't have opened the layer, so `endLayer` should throw.
assert_throws_dom("InvalidStateError", () => ctx.endLayer());
});
</script>
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>OffscreenCanvas test: 2d.layer.exceptions-are-no-op</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<h1>2d.layer.exceptions-are-no-op</h1>
<p class="desc">Checks that the context state is left unchanged if beginLayer throws.</p>
<script>
var t = async_test("Checks that the context state is left unchanged if beginLayer throws.");
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');
// Get `beginLayer` to throw while parsing the filter.
assert_throws_js(TypeError,
() => ctx.beginLayer({filter: {name: 'colorMatrix',
values: 'foo'}}));
// `beginLayer` shouldn't have opened the layer, so `endLayer` should throw.
assert_throws_dom("InvalidStateError", () => ctx.endLayer());
t.done();
});
</script>
@@ -0,0 +1,27 @@
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
// OffscreenCanvas test in a worker:2d.layer.exceptions-are-no-op
// Description:Checks that the context state is left unchanged if beginLayer throws.
// Note:
importScripts("/resources/testharness.js");
importScripts("/html/canvas/resources/canvas-tests.js");
var t = async_test("Checks that the context state is left unchanged if beginLayer throws.");
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');
// Get `beginLayer` to throw while parsing the filter.
assert_throws_js(TypeError,
() => ctx.beginLayer({filter: {name: 'colorMatrix',
values: 'foo'}}));
// `beginLayer` shouldn't have opened the layer, so `endLayer` should throw.
assert_throws_dom("InvalidStateError", () => ctx.endLayer());
t.done();
});
done();
@@ -573,6 +573,16 @@
ctx.reset();
ctx.endLayer();
- name: 2d.layer.exceptions-are-no-op
desc: Checks that the context state is left unchanged if beginLayer throws.
code: |
// Get `beginLayer` to throw while parsing the filter.
assert_throws_js(TypeError,
() => ctx.beginLayer({filter: {name: 'colorMatrix',
values: 'foo'}}));
// `beginLayer` shouldn't have opened the layer, so `endLayer` should throw.
assert_throws_dom("InvalidStateError", () => ctx.endLayer());
- name: 2d.layer.cross-layer-paths
desc: Checks that path defined in a layer is usable outside.
code: |