| Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D-in-worker.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-constructor-in-worker.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D-in-worker.html
|
| similarity index 39%
|
| copy from third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-constructor-in-worker.html
|
| copy to third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D-in-worker.html
|
| index b87006d34ee0a8a45aa463d32a94ce20edd079f5..e555fa97de262f9322e8950a943ddb5a3c41e0bf 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-constructor-in-worker.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D-in-worker.html
|
| @@ -4,44 +4,37 @@
|
| <body>
|
| <script id="myWorker" type="text/worker">
|
| self.onmessage = function(e) {
|
| - var aCanvas = new OffscreenCanvas(50, 50);
|
| - self.postMessage({version:'first', width:aCanvas.width, height:aCanvas.height});
|
| -
|
| - aCanvas.width = 100;
|
| - aCanvas.height = 100;
|
| - self.postMessage({version:'second', width:aCanvas.width, height:aCanvas.height});
|
| + var aCanvas = new OffscreenCanvas(50, 50);
|
| + try {
|
| + var ctx = aCanvas.getContext('2d');
|
| + if (toString.call(ctx) != '[object OffscreenCanvasRenderingContext2D]') {
|
| + self.postMessage("aCanvas.getContext('2d') does not return [object OffscreenCanvasRenderingContext2D]");
|
| + } else {
|
| + self.postMessage("success");
|
| + }
|
| + } catch (e) {
|
| + self.postMessage(e);
|
| + }
|
| };
|
| </script>
|
|
|
| <script>
|
| jsTestIsAsync = true;
|
| -description("Tests that the OffscreenCanvas can be constructed on a worker thread.");
|
| -
|
| -var width;
|
| -var height;
|
| +description("Tests that the 2D context of OffscreenCanvas can be constructed on a worker thread.");
|
|
|
| function makeWorker(script) {
|
| var blob = new Blob([script]);
|
| return new Worker(URL.createObjectURL(blob));
|
| }
|
|
|
| -function handleMessageFromWorker(msg) {
|
| - width = msg.data.width;
|
| - height = msg.data.height;
|
| - switch (msg.data.version) {
|
| - case 'first':
|
| - shouldBe('width', '50');
|
| - shouldBe('height', '50');
|
| - break;
|
| - case 'second':
|
| - shouldBe('width', '100');
|
| - shouldBe('height', '100');
|
| - finishJSTest();
|
| - break;
|
| - default:
|
| - testFailed("Unexpected failure");
|
| - break;
|
| - }
|
| +function handleMessageFromWorker(msg)
|
| +{
|
| + if (msg.data == "success") {
|
| + testPassed("getContext('2d') correctly returns [object OffscreenCanvasRenderingContext2D].");
|
| + } else {
|
| + testFailed(msg.data);
|
| + }
|
| + finishJSTest();
|
| }
|
|
|
| var worker = makeWorker(document.getElementById('myWorker').textContent);
|
|
|