OLD | NEW |
(Empty) | |
| 1 <img id="png"/> |
| 2 <script id="myWorker" type="text/worker"> |
| 3 self.onmessage = function (e) { |
| 4 var offCanvas = new OffscreenCanvas(50, 50); |
| 5 var gl = offCanvas.getContext('webgl'); |
| 6 gl.clearColor(0, 1, 0, 1); |
| 7 gl.clear(gl.COLOR_BUFFER_BIT); |
| 8 |
| 9 // TODO: Add more image types to this test once the toImageData() for webgl |
| 10 // is completed. See crbug.com/657531. |
| 11 offCanvas.convertToBlob() |
| 12 .then(function(blob) { |
| 13 self.postMessage({version: "png", data:blob}); |
| 14 }); |
| 15 } |
| 16 </script> |
| 17 <script> |
| 18 if (window.testRunner) { |
| 19 testRunner.waitUntilDone(); |
| 20 } |
| 21 |
| 22 var pngImage = document.getElementById('png'); |
| 23 function imageLoaded() { |
| 24 if (window.testRunner) { |
| 25 window.testRunner.notifyDone(); |
| 26 } |
| 27 } |
| 28 pngImage.addEventListener('load', imageLoaded); |
| 29 |
| 30 var workerBlob = new Blob([document.getElementById('myWorker').textContent]); |
| 31 var worker = new Worker(URL.createObjectURL(workerBlob)); |
| 32 worker.addEventListener("message", function(msg) { |
| 33 var blob = msg.data.data; |
| 34 switch (msg.data.version) { |
| 35 case 'png': |
| 36 pngImage.src = URL.createObjectURL(blob); |
| 37 break; |
| 38 } |
| 39 }); |
| 40 worker.postMessage(""); |
| 41 </script> |
| 42 |
OLD | NEW |