OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE> |
| 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script id="myWorker" type="text/worker"> |
| 5 self.onmessage = function(e) { |
| 6 var offscreenCanvas = new OffscreenCanvas(50, 50); |
| 7 var offscreen2d = offscreenCanvas.getContext("2d"); |
| 8 try { |
| 9 offscreen2d.commit(); |
| 10 self.postMessage("NoError"); |
| 11 } catch (ex) { |
| 12 self.postMessage(ex.name); |
| 13 } |
| 14 }; |
| 15 </script> |
| 16 <script> |
| 17 function makeWorker(script) { |
| 18 var blob = new Blob([script]); |
| 19 return new Worker(URL.createObjectURL(blob)); |
| 20 } |
| 21 |
| 22 |
| 23 test(function() { |
| 24 var offscreenCanvas = new OffscreenCanvas(50, 50); |
| 25 var offscreen2d = offscreenCanvas.getContext("2d"); |
| 26 assert_throws("InvalidStateError", function () { |
| 27 offscreen2d.commit(); |
| 28 }); |
| 29 }, "Calling OffscreenCanvas.commit() on main without transferControlToOffscreen
throws exception."); |
| 30 |
| 31 async_test(function() { |
| 32 var worker = makeWorker(document.getElementById("myWorker").textContent); |
| 33 worker.onmessage = this.step_func(function (e) { |
| 34 assert_equals(e.data, "InvalidStateError", "Expected exception on worker
but receives " + e.data); |
| 35 this.done(); |
| 36 }); |
| 37 worker.postMessage(""); |
| 38 }, "Calling OffscreenCanvas.commit() on worker without transferControlToOffscree
n throws exception."); |
| 39 |
| 40 |
| 41 |
| 42 </script> |
OLD | NEW |