| OLD | NEW |
| 1 <!DOCTYPE> | 1 <!DOCTYPE> |
| 2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script id="myWorker" type="text/worker"> | 4 <script id="myWorker" type="text/worker"> |
| 5 self.onmessage = function(e) { | 5 self.onmessage = function(e) { |
| 6 var offscreenCanvas = new OffscreenCanvas(50, 50); | 6 var offscreenCanvas = new OffscreenCanvas(50, 50); |
| 7 var offscreen2d = offscreenCanvas.getContext("2d"); | 7 var offscreen2d = offscreenCanvas.getContext("2d"); |
| 8 try { | 8 offscreen2d.commit().then(function() { |
| 9 offscreen2d.commit(); | 9 self.postMessage("NoError"); |
| 10 self.postMessage("NoError"); | 10 }, ex => { |
| 11 } catch (ex) { | |
| 12 self.postMessage(ex.name); | 11 self.postMessage(ex.name); |
| 13 } | 12 }); |
| 14 }; | 13 }; |
| 15 </script> | 14 </script> |
| 16 <script> | 15 <script> |
| 17 function makeWorker(script) { | 16 function makeWorker(script) { |
| 18 var blob = new Blob([script]); | 17 var blob = new Blob([script]); |
| 19 return new Worker(URL.createObjectURL(blob)); | 18 return new Worker(URL.createObjectURL(blob)); |
| 20 } | 19 } |
| 21 | 20 |
| 22 test(function() { | 21 promise_test(t => { |
| 23 var offscreenCanvas = new OffscreenCanvas(50, 50); | 22 var offscreenCanvas = new OffscreenCanvas(50, 50); |
| 24 var offscreen2d = offscreenCanvas.getContext("2d"); | 23 var offscreen2d = offscreenCanvas.getContext("2d"); |
| 25 assert_throws("InvalidStateError", function () { | 24 return promise_rejects(t, new DOMException("", "InvalidStateError"), offscre
en2d.commit()); |
| 26 offscreen2d.commit(); | 25 }, "Calling OffscreenCanvas.commit() on main without transferControlToOffscreen
rejects promise with an exception."); |
| 27 }); | |
| 28 }, "Calling OffscreenCanvas.commit() on main without transferControlToOffscreen
throws exception."); | |
| 29 | 26 |
| 30 test(function() { | 27 promise_test(t => { |
| 31 var offscreenCanvas = new OffscreenCanvas(50, 50); | 28 var offscreenCanvas = new OffscreenCanvas(50, 50); |
| 32 var gl = offscreenCanvas.getContext("webgl"); | 29 var gl = offscreenCanvas.getContext("webgl"); |
| 33 gl.clearColor(1.0, 0.0, 0.0, 1.0); | 30 gl.clearColor(1.0, 0.0, 0.0, 1.0); |
| 34 gl.clear(gl.COLOR_BUFFER_BIT); | 31 gl.clear(gl.COLOR_BUFFER_BIT); |
| 35 assert_throws("InvalidStateError", function() { | 32 return promise_rejects(t, new DOMException("", "InvalidStateError"), gl.comm
it()); |
| 36 gl.commit(); | 33 }, "Calling WebGL's commit() on main without transferControlToOffscreen rejects
promise with an exception."); |
| 37 }); | |
| 38 }, "Calling WebGL's commit() on main without transferControlToOffscreen throws e
xception."); | |
| 39 | 34 |
| 40 test(function() { | 35 promise_test(t => { |
| 41 var canvas = document.createElement('canvas'); | 36 var canvas = document.createElement('canvas'); |
| 42 canvas.width = 50; | 37 canvas.width = 50; |
| 43 canvas.height = 50; | 38 canvas.height = 50; |
| 44 var gl = canvas.getContext("webgl"); | 39 var gl = canvas.getContext("webgl"); |
| 45 gl.clearColor(1.0, 0.0, 0.0, 1.0); | 40 gl.clearColor(1.0, 0.0, 0.0, 1.0); |
| 46 gl.clear(gl.COLOR_BUFFER_BIT); | 41 gl.clear(gl.COLOR_BUFFER_BIT); |
| 47 assert_throws("InvalidStateError", function() { | 42 return promise_rejects(t, new DOMException("", "InvalidStateError"), gl.comm
it()); |
| 48 gl.commit(); | 43 }, "Calling WebGL's commit() on main without an OffscreenCanvas rejects promise
with an exception."); |
| 49 }); | |
| 50 }, "Calling WebGL's commit() on main without a OffscreenCanvas throws exception.
"); | |
| 51 | 44 |
| 52 async_test(function() { | 45 async_test(function() { |
| 53 var worker = makeWorker(document.getElementById("myWorker").textContent); | 46 var worker = makeWorker(document.getElementById("myWorker").textContent); |
| 54 worker.onmessage = this.step_func(function (e) { | 47 worker.onmessage = this.step_func(function (e) { |
| 55 assert_equals(e.data, "InvalidStateError", "Expected exception on worker
but receives " + e.data); | 48 assert_equals(e.data, "InvalidStateError", "Expected exception on worker
but receives " + e.data); |
| 56 this.done(); | 49 this.done(); |
| 57 }); | 50 }); |
| 58 worker.postMessage(""); | 51 worker.postMessage(""); |
| 59 }, "Calling OffscreenCanvas.commit() on worker without transferControlToOffscree
n throws exception."); | 52 }, "Calling OffscreenCanvas.commit() on worker without transferControlToOffscree
n rejects promise with an exception."); |
| 60 | 53 |
| 61 | 54 |
| 62 | 55 |
| 63 </script> | 56 </script> |
| OLD | NEW |