Bug 734423 - refactor the gc() helper used by WebGL conformance tests - no review, will upstream - NPOTB

This commit is contained in:
Benoit Jacob 2012-03-26 15:20:34 -04:00
parent b646a4cffc
commit 408619d76d
4 changed files with 182 additions and 56 deletions

View File

@ -342,32 +342,11 @@ function runOutputTests() {
} }
function attemptToForceGC()
{
var holderArray = [];
var tempArray;
window.tempArray = holderArray;
for (var i = 0; i < 12; ++i) {
tempArray = [];
for (var j = 0; j < 1024 * 1024; ++j) {
tempArray.push(0);
}
holderArray.push(tempArray);
}
window.tempArray = null;
}
function runUniqueObjectTest() function runUniqueObjectTest()
{ {
debug("Testing that getExtension() returns the same object each time"); debug("Testing that getExtension() returns the same object each time");
gl.getExtension("OES_standard_derivatives").myProperty = 2; gl.getExtension("OES_standard_derivatives").myProperty = 2;
if (window.GCController) { gc();
window.GCController.collect();
} else if (window.opera && window.opera.collect) {
window.opera.collect();
} else {
attemptToForceGC();
}
shouldBe('gl.getExtension("OES_standard_derivatives").myProperty', '2'); shouldBe('gl.getExtension("OES_standard_derivatives").myProperty', '2');
} }

View File

@ -183,32 +183,11 @@ function runRenderTargetTest(testProgram)
checkRenderingResults(); checkRenderingResults();
} }
function attemptToForceGC()
{
var holderArray = [];
var tempArray;
window.tempArray = holderArray;
for (var i = 0; i < 12; ++i) {
tempArray = [];
for (var j = 0; j < 1024 * 1024; ++j) {
tempArray.push(0);
}
holderArray.push(tempArray);
}
window.tempArray = null;
}
function runUniqueObjectTest() function runUniqueObjectTest()
{ {
debug("Testing that getExtension() returns the same object each time"); debug("Testing that getExtension() returns the same object each time");
gl.getExtension("OES_texture_float").myProperty = 2; gl.getExtension("OES_texture_float").myProperty = 2;
if (window.GCController) { gc();
window.GCController.collect();
} else if (window.opera && window.opera.collect) {
window.opera.collect();
} else {
attemptToForceGC();
}
shouldBe('gl.getExtension("OES_texture_float").myProperty', '2'); shouldBe('gl.getExtension("OES_texture_float").myProperty', '2');
} }

View File

@ -0,0 +1,155 @@
# HG changeset patch
# Parent f9585cefcf568dbc2a6ce81f16a2048365af7ed2
diff --git a/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html b/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html
--- a/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html
+++ b/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html
@@ -337,42 +337,21 @@ function runOutputTests() {
setupBuffers(1.0, 0.5, 0.5, 0.0);
wtu.drawQuad(gl);
expectResult([3, 3, 5, 255],
"Draw 4 (variation in x & y) returned the correct data",
"Draw 4 (variation in x & y) returned incorrect data");
}
-function attemptToForceGC()
-{
- var holderArray = [];
- var tempArray;
- window.tempArray = holderArray;
- for (var i = 0; i < 12; ++i) {
- tempArray = [];
- for (var j = 0; j < 1024 * 1024; ++j) {
- tempArray.push(0);
- }
- holderArray.push(tempArray);
- }
- window.tempArray = null;
-}
-
function runUniqueObjectTest()
{
debug("Testing that getExtension() returns the same object each time");
gl.getExtension("OES_standard_derivatives").myProperty = 2;
- if (window.GCController) {
- window.GCController.collect();
- } else if (window.opera && window.opera.collect) {
- window.opera.collect();
- } else {
- attemptToForceGC();
- }
+ gc();
shouldBe('gl.getExtension("OES_standard_derivatives").myProperty', '2');
}
function runReferenceCycleTest()
{
// create some reference cycles. The goal is to see if they cause leaks. The point is that
// some browser test runners have instrumentation to detect leaked refcounted objects.
diff --git a/content/canvas/test/webgl/conformance/extensions/oes-texture-float.html b/content/canvas/test/webgl/conformance/extensions/oes-texture-float.html
--- a/content/canvas/test/webgl/conformance/extensions/oes-texture-float.html
+++ b/content/canvas/test/webgl/conformance/extensions/oes-texture-float.html
@@ -178,42 +178,21 @@ function runRenderTargetTest(testProgram
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.useProgram(testProgram);
gl.uniform1i(gl.getUniformLocation(testProgram, "tex"), 0);
wtu.drawQuad(gl);
glErrorShouldBe(gl, gl.NO_ERROR, "rendering from floating-point texture should succeed");
checkRenderingResults();
}
-function attemptToForceGC()
-{
- var holderArray = [];
- var tempArray;
- window.tempArray = holderArray;
- for (var i = 0; i < 12; ++i) {
- tempArray = [];
- for (var j = 0; j < 1024 * 1024; ++j) {
- tempArray.push(0);
- }
- holderArray.push(tempArray);
- }
- window.tempArray = null;
-}
-
function runUniqueObjectTest()
{
debug("Testing that getExtension() returns the same object each time");
gl.getExtension("OES_texture_float").myProperty = 2;
- if (window.GCController) {
- window.GCController.collect();
- } else if (window.opera && window.opera.collect) {
- window.opera.collect();
- } else {
- attemptToForceGC();
- }
+ gc();
shouldBe('gl.getExtension("OES_texture_float").myProperty', '2');
}
function runReferenceCycleTest()
{
// create some reference cycles. The goal is to see if they cause leaks. The point is that
// some browser test runners have instrumentation to detect leaked refcounted objects.
diff --git a/content/canvas/test/webgl/resources/js-test-pre.js b/content/canvas/test/webgl/resources/js-test-pre.js
--- a/content/canvas/test/webgl/resources/js-test-pre.js
+++ b/content/canvas/test/webgl/resources/js-test-pre.js
@@ -435,29 +435,42 @@ function assertMsg(assertion, msg) {
if (assertion) {
testPassed(msg);
} else {
testFailed(msg);
}
}
function gc() {
- if (typeof GCController !== "undefined")
- GCController.collect();
- else {
- function gcRec(n) {
- if (n < 1)
- return {};
- var temp = {i: "ab" + i + (i / 100000)};
- temp += "foo";
- gcRec(n-1);
- }
- for (var i = 0; i < 1000; i++)
- gcRec(10)
+ if (window.GCController) {
+ window.GCController.collect();
+ return;
}
+
+ if (window.opera && window.opera.collect) {
+ window.opera.collect();
+ return;
+ }
+
+ try {
+ window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindowUtils)
+ .garbageCollect();
+ return;
+ } catch(e) {}
+
+ function gcRec(n) {
+ if (n < 1)
+ return {};
+ var temp = {i: "ab" + i + (i / 100000)};
+ temp += "foo";
+ gcRec(n-1);
+ }
+ for (var i = 0; i < 1000; i++)
+ gcRec(10);
}
function finishTest() {
successfullyParsed = true;
var epilogue = document.createElement("script");
epilogue.onload = function() {
if (window.nonKhronosFrameworkNotifyDone) {
window.nonKhronosFrameworkNotifyDone();

View File

@ -440,19 +440,32 @@ function assertMsg(assertion, msg) {
} }
function gc() { function gc() {
if (typeof GCController !== "undefined") if (window.GCController) {
GCController.collect(); window.GCController.collect();
else { return;
function gcRec(n) {
if (n < 1)
return {};
var temp = {i: "ab" + i + (i / 100000)};
temp += "foo";
gcRec(n-1);
}
for (var i = 0; i < 1000; i++)
gcRec(10)
} }
if (window.opera && window.opera.collect) {
window.opera.collect();
return;
}
try {
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.garbageCollect();
return;
} catch(e) {}
function gcRec(n) {
if (n < 1)
return {};
var temp = {i: "ab" + i + (i / 100000)};
temp += "foo";
gcRec(n-1);
}
for (var i = 0; i < 1000; i++)
gcRec(10);
} }
function finishTest() { function finishTest() {