| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML> | |
| 2 | |
| 3 <!-- READ BEFORE UPDATING: | |
| 4 If this test is updated make sure to increment the "revision" value of the | |
| 5 associated test in content/test/gpu/page_sets/pixel_tests.py. This will ensure | |
| 6 that the baseline images are regenerated on the next run. | |
| 7 --> | |
| 8 | |
| 9 <html> | |
| 10 <head> | |
| 11 <title>OffscreenCanvas 2d commit flow on worker thread: blue square on white bac
kground.</title> | |
| 12 <style type="text/css"> | |
| 13 .nomargin { | |
| 14 margin: 0px auto; | |
| 15 } | |
| 16 </style> | |
| 17 <script id="myWorker" type="text/worker"> | |
| 18 self.onmessage = function(e) { | |
| 19 var transferredCanvas = e.data; | |
| 20 var offscreen2d = transferredCanvas.getContext("2d"); | |
| 21 offscreen2d.fillStyle = "blue"; | |
| 22 offscreen2d.fillRect(0, 0, transferredCanvas.width, transferredCanvas.height
); | |
| 23 offscreen2d.commit(); | |
| 24 self.postMessage(""); | |
| 25 }; | |
| 26 </script> | |
| 27 <script> | |
| 28 var g_swapsBeforeAck = 15; | |
| 29 | |
| 30 function makeWorker(script) | |
| 31 { | |
| 32 var blob = new Blob([script]); | |
| 33 return new Worker(URL.createObjectURL(blob)); | |
| 34 } | |
| 35 | |
| 36 function waitForFinish() | |
| 37 { | |
| 38 if (g_swapsBeforeAck == 0) { | |
| 39 domAutomationController.setAutomationId(1); | |
| 40 domAutomationController.send("SUCCESS"); | |
| 41 } else { | |
| 42 g_swapsBeforeAck--; | |
| 43 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; | |
| 44 window.webkitRequestAnimationFrame(waitForFinish); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 function main() | |
| 49 { | |
| 50 var canvas2D = document.getElementById("c"); | |
| 51 var offscreenCanvas = canvas2D.transferControlToOffscreen(); | |
| 52 var worker = makeWorker(document.getElementById("myWorker").textContent); | |
| 53 worker.postMessage(offscreenCanvas, [offscreenCanvas]); | |
| 54 worker.onmessage = function (e) { | |
| 55 waitForFinish(); | |
| 56 }; | |
| 57 } | |
| 58 </script> | |
| 59 </head> | |
| 60 <body onload="main()"> | |
| 61 <div style="position:relative; width:350px; height:350px; background-color:white
"> | |
| 62 </div> | |
| 63 <div id="container" style="position:absolute; top:0px; left:0px"> | |
| 64 <canvas id="c" width="320" height="320" class="nomargin"></canvas> | |
| 65 </div> | |
| 66 </body> | |
| 67 </html> | |
| OLD | NEW |