forked from kdashg/gecko-cinn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1859070 [wpt PR 42544] - Throw an exception in transferToImageBit…
…map if canvas layers are opened, a=testonly Automatic update from web-platform-tests Throw an exception in transferToImageBitmap if canvas layers are opened This API is incompatible with how the 2D canvas is rasterized when it contains unclosed layers. Because layers can have filters that get applied on their final content, they can't be presented until they are closed. Instead, we normally keep the layer content alive after a flush, so that it can be presented in a later frame when the layer is finally closed. OffscreenCanvas.transferToImageBitmap however is supposed to release the canvas content, leaving the offscreen canvas empty. We cannot release the recording if layers are incomplete, and if we kept the layer content alive for later, we would not be leaving the canvas empty as the spec requires. This behavior is part of the current 2D Canvas Layer spec draft: Explainer: https://github.com/fserb/canvas2D/blob/master/spec/layers.md Spec draft: whatwg/html#9537 Bug: 1484741 Change-Id: Ic770b51a0343faf0b2c7477624d69f59187ce97f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4939633 Commit-Queue: Jean-Philippe Gravel <[email protected]> Reviewed-by: Fernando Serboncini <[email protected]> Cr-Commit-Position: refs/heads/main@{#1212692} -- wpt-commits: 3375400712353d2c9b011ed3dbb24c8d756b784f wpt-pr: 42544
- Loading branch information
1 parent
e71efec
commit 5031a60
Showing
8 changed files
with
156 additions
and
181 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
...canvas/offscreen/layers/2d.layer.render-opportunities.transferToImageBitmap-expected.html
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...sts/html/canvas/offscreen/layers/2d.layer.render-opportunities.transferToImageBitmap.html
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
...s/html/canvas/offscreen/layers/2d.layer.render-opportunities.transferToImageBitmap.w.html
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
testing/web-platform/tests/html/canvas/offscreen/layers/2d.layer.transferToImageBitmap.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>OffscreenCanvas test: 2d.layer.transferToImageBitmap</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.transferToImageBitmap</h1> | ||
<p class="desc">Check that calling transferToImageBitmap in a layer throws an exception.</p> | ||
|
||
|
||
<script> | ||
var t = async_test("Check that calling transferToImageBitmap in a layer throws an exception."); | ||
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'); | ||
|
||
// `transferToImageBitmap` shouldn't throw on it's own. | ||
canvas.transferToImageBitmap(); | ||
// Make sure the exception isn't caused by calling the function twice. | ||
canvas.transferToImageBitmap(); | ||
// Calling again inside a layer should throw. | ||
ctx.beginLayer(); | ||
assert_throws_dom("InvalidStateError", | ||
() => canvas.transferToImageBitmap()); | ||
t.done(); | ||
|
||
}); | ||
</script> |
29 changes: 29 additions & 0 deletions
29
.../web-platform/tests/html/canvas/offscreen/layers/2d.layer.transferToImageBitmap.worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. | ||
// OffscreenCanvas test in a worker:2d.layer.transferToImageBitmap | ||
// Description:Check that calling transferToImageBitmap in a layer throws an exception. | ||
// Note: | ||
|
||
importScripts("/resources/testharness.js"); | ||
importScripts("/html/canvas/resources/canvas-tests.js"); | ||
|
||
var t = async_test("Check that calling transferToImageBitmap in a layer throws an exception."); | ||
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'); | ||
|
||
// `transferToImageBitmap` shouldn't throw on it's own. | ||
canvas.transferToImageBitmap(); | ||
// Make sure the exception isn't caused by calling the function twice. | ||
canvas.transferToImageBitmap(); | ||
// Calling again inside a layer should throw. | ||
ctx.beginLayer(); | ||
assert_throws_dom("InvalidStateError", | ||
() => canvas.transferToImageBitmap()); | ||
t.done(); | ||
}); | ||
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters