| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script type="text/javascript"> | 3 <script type="text/javascript"> |
| 4 var canvas; | 4 var canvas; |
| 5 var w, h; | 5 var w, h; |
| 6 var gl; | 6 var gl; |
| 7 var extension; | 7 var extension; |
| 8 | 8 |
| 9 var alreadySetAutomationId = false; | |
| 10 | |
| 11 function testHorizontalBands() { | 9 function testHorizontalBands() { |
| 12 gl.enable(gl.SCISSOR_TEST); | 10 gl.enable(gl.SCISSOR_TEST); |
| 13 | 11 |
| 14 gl.clearColor(1, 0, 0, 1); | 12 gl.clearColor(1, 0, 0, 1); |
| 15 gl.scissor(0, 0, w, h/2); | 13 gl.scissor(0, 0, w, h/2); |
| 16 gl.clear(gl.COLOR_BUFFER_BIT); | 14 gl.clear(gl.COLOR_BUFFER_BIT); |
| 17 | 15 |
| 18 gl.clearColor(0, 1, 0, 1); | 16 gl.clearColor(0, 1, 0, 1); |
| 19 gl.scissor(0, h/2, w, h/2); | 17 gl.scissor(0, h/2, w, h/2); |
| 20 gl.clear(gl.COLOR_BUFFER_BIT); | 18 gl.clear(gl.COLOR_BUFFER_BIT); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 44 if (!gl || gl.isContextLost()) { | 42 if (!gl || gl.isContextLost()) { |
| 45 // Might just be blocked because of infobar. | 43 // Might just be blocked because of infobar. |
| 46 return; | 44 return; |
| 47 } | 45 } |
| 48 gl.clearColor(0, 0, 1, 1); | 46 gl.clearColor(0, 0, 1, 1); |
| 49 gl.clear(gl.COLOR_BUFFER_BIT); | 47 gl.clear(gl.COLOR_BUFFER_BIT); |
| 50 | 48 |
| 51 var a = new Uint8Array(w * h * 4); | 49 var a = new Uint8Array(w * h * 4); |
| 52 gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, a); | 50 gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, a); |
| 53 | 51 |
| 54 if (!alreadySetAutomationId) | |
| 55 window.domAutomationController.setAutomationId(1); | |
| 56 if (a[0] == 0 && a[1] == 0 && a[2] == 255) | 52 if (a[0] == 0 && a[1] == 0 && a[2] == 255) |
| 57 window.domAutomationController.send("SUCCESS"); | 53 window.domAutomationController.send("SUCCESS"); |
| 58 else | 54 else |
| 59 window.domAutomationController.send("FAILED"); | 55 window.domAutomationController.send("FAILED"); |
| 60 } | 56 } |
| 61 | 57 |
| 62 function testQuantityLoss() { | 58 function testQuantityLoss() { |
| 63 var count = 0; | 59 var count = 0; |
| 64 var iterations = 128; | 60 var iterations = 128; |
| 65 var garbageCanvases = []; | 61 var garbageCanvases = []; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 81 } | 77 } |
| 82 ctx.clear(gl.COLOR_BUFFER_BIT); | 78 ctx.clear(gl.COLOR_BUFFER_BIT); |
| 83 | 79 |
| 84 if (count < iterations) { | 80 if (count < iterations) { |
| 85 window.requestAnimationFrame(createAndDiscardContext); | 81 window.requestAnimationFrame(createAndDiscardContext); |
| 86 } else { | 82 } else { |
| 87 // Remove the references to the garbage canvases, then attempt to trigger | 83 // Remove the references to the garbage canvases, then attempt to trigger |
| 88 // a garbage collect. | 84 // a garbage collect. |
| 89 garbageCanvases = null; | 85 garbageCanvases = null; |
| 90 | 86 |
| 91 window.domAutomationController.setAutomationId(1); | |
| 92 alreadySetAutomationId = true; | |
| 93 window.domAutomationController.send("LOADED"); | 87 window.domAutomationController.send("LOADED"); |
| 94 | 88 |
| 95 // Trying to provoke garbage collection through excessive allocations. | 89 // Trying to provoke garbage collection through excessive allocations. |
| 96 setInterval(function() { | 90 setInterval(function() { |
| 97 var garbageArray = new Uint8Array(1024 * 1024); | 91 var garbageArray = new Uint8Array(1024 * 1024); |
| 98 garbageArray[0] = 255; | 92 garbageArray[0] = 255; |
| 99 }, 10); | 93 }, 10); |
| 100 } | 94 } |
| 101 }; | 95 }; |
| 102 | 96 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 127 extension.loseContext(); | 121 extension.loseContext(); |
| 128 break; | 122 break; |
| 129 } | 123 } |
| 130 case "kill": | 124 case "kill": |
| 131 // nothing -- the browser test navigates to about:gpucrash and kills | 125 // nothing -- the browser test navigates to about:gpucrash and kills |
| 132 // the GPU process. | 126 // the GPU process. |
| 133 break; | 127 break; |
| 134 case "kill_after_notification": | 128 case "kill_after_notification": |
| 135 // The browser test waits for notification from the page that it | 129 // The browser test waits for notification from the page that it |
| 136 // has been loaded before navigating to about:gpucrash. | 130 // has been loaded before navigating to about:gpucrash. |
| 137 window.domAutomationController.setAutomationId(1); | |
| 138 alreadySetAutomationId = true; | |
| 139 window.domAutomationController.send("LOADED"); | 131 window.domAutomationController.send("LOADED"); |
| 140 break; | 132 break; |
| 141 case "forced_quantity_loss": | 133 case "forced_quantity_loss": |
| 142 // Test creates many new contexts, forcing the original context to be | 134 // Test creates many new contexts, forcing the original context to be |
| 143 // lost. Then a garbage collect is triggered and the original context is | 135 // lost. Then a garbage collect is triggered and the original context is |
| 144 // watched to ensure it restores properly. | 136 // watched to ensure it restores properly. |
| 145 testQuantityLoss(); | 137 testQuantityLoss(); |
| 146 break; | 138 break; |
| 147 } | 139 } |
| 148 } | 140 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 167 if (query) | 159 if (query) |
| 168 contextLostTest(query[1]); | 160 contextLostTest(query[1]); |
| 169 } | 161 } |
| 170 </script> | 162 </script> |
| 171 </head> | 163 </head> |
| 172 <body onload="onLoad()"> | 164 <body onload="onLoad()"> |
| 173 <canvas id="canvas1" width="16px" height="32px"> | 165 <canvas id="canvas1" width="16px" height="32px"> |
| 174 </canvas> | 166 </canvas> |
| 175 </body> | 167 </body> |
| 176 </html> | 168 </html> |
| OLD | NEW |