| 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; | 9 var alreadySetAutomationId = false; |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, a); | 52 gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, a); |
| 53 | 53 |
| 54 if (!alreadySetAutomationId) | 54 if (!alreadySetAutomationId) |
| 55 window.domAutomationController.setAutomationId(1); | 55 window.domAutomationController.setAutomationId(1); |
| 56 if (a[0] == 0 && a[1] == 0 && a[2] == 255) | 56 if (a[0] == 0 && a[1] == 0 && a[2] == 255) |
| 57 window.domAutomationController.send("SUCCESS"); | 57 window.domAutomationController.send("SUCCESS"); |
| 58 else | 58 else |
| 59 window.domAutomationController.send("FAILED"); | 59 window.domAutomationController.send("FAILED"); |
| 60 } | 60 } |
| 61 | 61 |
| 62 function testQuantityLoss() { |
| 63 var count = 0; |
| 64 var iterations = 128; |
| 65 |
| 66 function createAndDiscardContext() { |
| 67 count++; |
| 68 |
| 69 var c = document.createElement("canvas"); |
| 70 c.width = 1; |
| 71 c.height = 1; |
| 72 |
| 73 var ctx = c.getContext("experimental-webgl"); |
| 74 if (!ctx) { |
| 75 return false; |
| 76 } |
| 77 ctx.clear(gl.COLOR_BUFFER_BIT); |
| 78 |
| 79 if (count < iterations) { |
| 80 window.requestAnimationFrame(createAndDiscardContext); |
| 81 } else { |
| 82 window.domAutomationController.setAutomationId(1); |
| 83 alreadySetAutomationId = true; |
| 84 window.domAutomationController.send("LOADED"); |
| 85 } |
| 86 }; |
| 87 |
| 88 createAndDiscardContext(); |
| 89 } |
| 90 |
| 62 function contextLostTest(kind) | 91 function contextLostTest(kind) |
| 63 { | 92 { |
| 64 switch (kind) { | 93 switch (kind) { |
| 65 case "WEBGL_lose_context": { | 94 case "WEBGL_lose_context": { |
| 66 extension = gl.getExtension("WEBKIT_WEBGL_lose_context") || | 95 extension = gl.getExtension("WEBKIT_WEBGL_lose_context") || |
| 67 gl.getExtension("WEBGL_lose_context"); | 96 gl.getExtension("WEBGL_lose_context"); |
| 68 extension.loseContext(); | 97 extension.loseContext(); |
| 69 break; | 98 break; |
| 70 } | 99 } |
| 71 case "kill": | 100 case "kill": |
| 72 // nothing -- the browser test navigates to about:gpucrash and kills | 101 // nothing -- the browser test navigates to about:gpucrash and kills |
| 73 // the GPU process. | 102 // the GPU process. |
| 74 break; | 103 break; |
| 75 case "kill_after_notification": | 104 case "kill_after_notification": |
| 76 // The browser test waits for notification from the page that it | 105 // The browser test waits for notification from the page that it |
| 77 // has been loaded before navigating to about:gpucrash. | 106 // has been loaded before navigating to about:gpucrash. |
| 78 window.domAutomationController.setAutomationId(1); | 107 window.domAutomationController.setAutomationId(1); |
| 79 alreadySetAutomationId = true; | 108 alreadySetAutomationId = true; |
| 80 window.domAutomationController.send("LOADED"); | 109 window.domAutomationController.send("LOADED"); |
| 81 break; | 110 break; |
| 111 case "forced_quantity_loss": |
| 112 // Test creates many new contexts, forcing the original context to be |
| 113 // lost. Then a garbage collect is triggered and the original context is |
| 114 // watched to ensure it restores properly. |
| 115 testQuantityLoss(); |
| 116 break; |
| 82 } | 117 } |
| 83 } | 118 } |
| 84 | 119 |
| 85 function onLoad() { | 120 function onLoad() { |
| 86 canvas = document.getElementById("canvas1"); | 121 canvas = document.getElementById("canvas1"); |
| 87 w = canvas.width; | 122 w = canvas.width; |
| 88 h = canvas.height; | 123 h = canvas.height; |
| 89 if (!canvas) | 124 if (!canvas) |
| 90 return; | 125 return; |
| 91 canvas.addEventListener("webglcontextlost", testContextLost, false); | 126 canvas.addEventListener("webglcontextlost", testContextLost, false); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 102 if (query) | 137 if (query) |
| 103 contextLostTest(query[1]); | 138 contextLostTest(query[1]); |
| 104 } | 139 } |
| 105 </script> | 140 </script> |
| 106 </head> | 141 </head> |
| 107 <body onload="onLoad()"> | 142 <body onload="onLoad()"> |
| 108 <canvas id="canvas1" width="16px" height="32px"> | 143 <canvas id="canvas1" width="16px" height="32px"> |
| 109 </canvas> | 144 </canvas> |
| 110 </body> | 145 </body> |
| 111 </html> | 146 </html> |
| OLD | NEW |