Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-MessageChannel-transfer.html

Issue 2572793002: Test OffscreenCanvas transfer via MessageChannel (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-MessageChannel-transfer.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-MessageChannel-transfer.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-MessageChannel-transfer.html
new file mode 100644
index 0000000000000000000000000000000000000000..6e321e012a3e457effebd91bddbebc11edaf3941
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-MessageChannel-transfer.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ var channel = new MessageChannel();
+ var canvas = document.createElement('canvas');
+ canvas.width = canvas.height = 10;
+ var offscreen = canvas.transferControlToOffscreen();
+ channel.port2.onmessage = function(message) {
+ var ctx = message.data.getContext('2d');
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 10, 10);
+ ctx.commit();
+ setTimeout(function() { // synchronization barrier to allow commit to propagate
+ var canvas2 = document.createElement('canvas');
+ canvas2.width = canvas2.height = 10;
+ var ctx2 = canvas2.getContext('2d');
+ ctx2.drawImage(canvas, 0, 0);
+ var pixel = ctx2.getImageData(0, 0, 1, 1).data;
+ t.step(function() {
+ assert_array_equals(pixel, [0, 255, 0, 255]);
+ });
+ t.done();
+ }, 0);
+ }
+ channel.port1.postMessage(offscreen, [offscreen]);
+}, "Verify that posting an OffscreenCanvas through a MessageChannel works as intended.");
+
+test(function() {
+ var channel = new MessageChannel();
+ var canvas = document.createElement('canvas');
+ canvas.width = canvas.height = 10;
+ var offscreen = canvas.transferControlToOffscreen();
+ channel.port2.onmessage = function() {};
+ assert_throws("DataCloneError", function() {channel.port1.postMessage(offscreen)});
+}, "Verify that cloning an OffscreenCanvas through a MessageChannel throws an exception")
+
+</script>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698