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