Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | |
| 8 | |
| 9 description("Test OffscreenCanvas transferable."); | |
| 10 window.jsTestIsAsync = true; | |
| 11 | |
| 12 var worker = new Worker('./resources/OffscreenCanvas-transferable.js'); | |
| 13 | |
| 14 var width = 50; | |
| 15 var height = 50; | |
| 16 var canvas = document.createElement("canvas"); | |
| 17 canvas.width = width; | |
| 18 canvas.height = height; | |
| 19 var newOffscreenCanvas; | |
| 20 | |
| 21 var offscreenCanvas = canvas.transferControlToOffscreen(); | |
| 22 shouldBe("offscreenCanvas.width", "width"); | |
| 23 shouldBe("offscreenCanvas.height", "height"); | |
| 24 | |
| 25 worker.postMessage({data: offscreenCanvas}, [offscreenCanvas]); | |
| 26 shouldBe("offscreenCanvas.width", "0"); | |
| 27 shouldBe("offscreenCanvas.height", "0"); | |
| 28 | |
| 29 try { | |
| 30 worker.postMessage({data: offscreenCanvas}, [offscreenCanvas]); | |
| 31 testFailed("Transfer a neutered offscreenCanvas succeed, expected to fail"); | |
| 32 } catch(e) { | |
| 33 testPassed("Transfer a neutered offscreenCanvas should throw an exception: " + e); | |
| 34 } | |
| 35 | |
| 36 worker.onmessage = function(e) { | |
| 37 newOffscreenCanvas = e.data.data; | |
| 38 shouldBe("newOffscreenCanvas.width", "width"); | |
| 39 shouldBe("newOffscreenCanvas.height", "height"); | |
| 40 var ctx; | |
| 41 shouldNotThrow("ctx = newOffscreenCanvas.getContext('2d')"); | |
| 42 shouldBeType("ctx", "OffscreenCanvasRenderingContext2D"); | |
| 43 try { | |
| 44 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
| |
| 45 testFailed("Transfer an offscreenCanvas with a context succeed, expected to fail"); | |
| 46 } catch(e) { | |
| 47 testPassed("Transfer an offscreenCanvas with a context should throw an e xception: " + e); | |
| 48 } | |
| 49 finishJSTest(); | |
| 50 } | |
| 51 </script> | |
| 52 </body> | |
| 53 </html> | |
| OLD | NEW |