OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <script src="../../resources/js-test.js"></script> |
| 4 <body> |
| 5 <script id="myWorker" type="text/worker"> |
| 6 var setWidth = Math.pow(2, 31); |
| 7 var setHeight = Math.pow(2, 31); |
| 8 |
| 9 self.onmessage = function(e) { |
| 10 var canvas1 = new OffScreenCanvas(setWidth, setHeight); |
| 11 self.postMessage({version:'canvas1', width:canvas1.width, height:canvas1.heigh
t}); |
| 12 |
| 13 var canvas2 = new OffScreenCanvas(null, null); |
| 14 self.postMessage({version:'canvas2', width:canvas2.width, height:canvas2.heigh
t}); |
| 15 }; |
| 16 </script> |
| 17 |
| 18 <script> |
| 19 jsTestIsAsync = true; |
| 20 description("Tests that the OffScreenCanvas can handle invalid arguments on a wo
rker"); |
| 21 |
| 22 var width; |
| 23 var height; |
| 24 var setWidth = Math.pow(2, 31); |
| 25 var setHeight = Math.pow(2, 31); |
| 26 |
| 27 function makeWorker(script) { |
| 28 var blob = new Blob([script]); |
| 29 return new Worker(URL.createObjectURL(blob)); |
| 30 } |
| 31 |
| 32 function handleMessageFromWorker(msg) { |
| 33 width = msg.data.width; |
| 34 height = msg.data.height; |
| 35 switch (msg.data.version) { |
| 36 case 'canvas1': |
| 37 shouldBe('width', 'setWidth-1'); |
| 38 shouldBe('height', 'setHeight-1'); |
| 39 break; |
| 40 case 'canvas2': |
| 41 shouldBe('width', '0'); |
| 42 shouldBe('height', '0'); |
| 43 finishJSTest(); |
| 44 break; |
| 45 default: |
| 46 testFailed("Unexpected failure"); |
| 47 break; |
| 48 } |
| 49 } |
| 50 |
| 51 var worker = makeWorker(document.getElementById('myWorker').textContent); |
| 52 worker.addEventListener('message', handleMessageFromWorker); |
| 53 worker.postMessage(""); |
| 54 </script> |
| 55 |
| 56 </body> |
| 57 </html> |
OLD | NEW |