Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: content/test/data/gpu/webgl.html

Issue 263523002: Added test to ensure context restoration due to GC doesn't crash (Take 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/test/gpu/gpu_tests/context_lost.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/gpu/webgl.html
diff --git a/content/test/data/gpu/webgl.html b/content/test/data/gpu/webgl.html
index 001c569a0f457b979187f97d3bfab811261d58d1..faa445d422e2b71122362b37633e6a68d348212f 100644
--- a/content/test/data/gpu/webgl.html
+++ b/content/test/data/gpu/webgl.html
@@ -59,6 +59,47 @@ function testContextRestored() {
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) {
@@ -79,6 +120,12 @@ function contextLostTest(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;
}
}
« no previous file with comments | « no previous file | content/test/gpu/gpu_tests/context_lost.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698