Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferable.html |
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferable.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferable.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..65ee12b83f328696d74ecb77dfae754d0aa185e5 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferable.html |
@@ -0,0 +1,53 @@ |
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
+<html> |
+<head> |
+<script src="../../resources/js-test.js"></script> |
+</head> |
+<body> |
+<script> |
+ |
+description("Test OffscreenCanvas transferable."); |
+window.jsTestIsAsync = true; |
+ |
+var worker = new Worker('./resources/OffscreenCanvas-transferable.js'); |
+ |
+var width = 50; |
+var height = 50; |
+var canvas = document.createElement("canvas"); |
+canvas.width = width; |
+canvas.height = height; |
+var newOffscreenCanvas; |
+ |
+var offscreenCanvas = canvas.transferControlToOffscreen(); |
+shouldBe("offscreenCanvas.width", "width"); |
+shouldBe("offscreenCanvas.height", "height"); |
+ |
+worker.postMessage({data: offscreenCanvas}, [offscreenCanvas]); |
+shouldBe("offscreenCanvas.width", "0"); |
+shouldBe("offscreenCanvas.height", "0"); |
+ |
+try { |
+ worker.postMessage({data: offscreenCanvas}, [offscreenCanvas]); |
+ testFailed("Transfer a neutered offscreenCanvas succeed, expected to fail"); |
+} catch(e) { |
+ testPassed("Transfer a neutered offscreenCanvas should throw an exception: " + e); |
+} |
+ |
+worker.onmessage = function(e) { |
+ newOffscreenCanvas = e.data.data; |
+ shouldBe("newOffscreenCanvas.width", "width"); |
+ shouldBe("newOffscreenCanvas.height", "height"); |
+ var ctx; |
+ shouldNotThrow("ctx = newOffscreenCanvas.getContext('2d')"); |
+ shouldBeType("ctx", "OffscreenCanvasRenderingContext2D"); |
+ try { |
+ worker.postMessage({data: newOffscreenCanvas}, [newOffscreenCanvas]); |
Justin Novosad
2016/04/12 18:10:23
This test nested in a test is hard to follow. I d
xidachen
2016/04/12 19:35:14
Good point. The postMessage is not appropriate her
|
+ testFailed("Transfer an offscreenCanvas with a context succeed, expected to fail"); |
+ } catch(e) { |
+ testPassed("Transfer an offscreenCanvas with a context should throw an exception: " + e); |
+ } |
+ finishJSTest(); |
+} |
+</script> |
+</body> |
+</html> |