window.domAutomationController.send("FAILED");
}
+function testQuantityLoss() {
+ var count = 0;
+ var iterations = 128;
+ var garbageCanvases = [];
+
+ function createAndDiscardContext() {
+ count++;
+
+ var c = document.createElement("canvas");
+ c.width = 1;
+ c.height = 1;
+ garbageCanvases.push(c);
+
+ var ctx = c.getContext("experimental-webgl");
+ if (!ctx) {
+ return false;
+ }
+ ctx.clear(gl.COLOR_BUFFER_BIT);
+
+ if (count < iterations) {
+ window.requestAnimationFrame(createAndDiscardContext);
+ } else {
+ // Remove the references to the garbage canvases, then attempt to trigger
+ // a garbage collect.
+ garbageCanvases = null;
+
+ window.domAutomationController.setAutomationId(1);
+ alreadySetAutomationId = true;
+ window.domAutomationController.send("LOADED");
+
+ // Trying to provoke garbage collection through excessive allocations.
+ setInterval(function() {
+ var garbageArray = new Uint8Array(1024 * 1024);
+ garbageArray[0] = 255;
+ }, 10);
+ }
+ };
+
+ createAndDiscardContext();
+}
+
function contextLostTest(kind)
{
switch (kind) {
alreadySetAutomationId = true;
window.domAutomationController.send("LOADED");
break;
+ case "forced_quantity_loss":
+ // Test creates many new contexts, forcing the original context to be
+ // lost. Then a garbage collect is triggered and the original context is
+ // watched to ensure it restores properly.
+ testQuantityLoss();
+ break;
}
}