Bug 883364 - WebGL reftests should fail gracefully, not time out. - r=dzbarsky
☠☠ backed out by 23a13efe29be ☠ ☠
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 18 Jul 2013 15:48:06 -0700
changeset 139180 0ad31c2bda31cc84c8209963868490153a9002eb
parent 139179 8cc680bb6ba2f3e7c69dcb096f15ee2232a092b0
child 139181 9fd04fd70fc2275f657b244df6c80044f6c87c6f
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdzbarsky
bugs883364
milestone25.0a1
Bug 883364 - WebGL reftests should fail gracefully, not time out. - r=dzbarsky
content/canvas/test/reftest/webgl-clear-test.html
content/canvas/test/reftest/webgl-color-alpha-test.html
content/canvas/test/reftest/webgl-color-test.html
content/canvas/test/reftest/webgl-hanging-fb-test.html
content/canvas/test/reftest/webgl-hanging-scissor-test.html
content/canvas/test/reftest/webgl-orientation-test.html
--- a/content/canvas/test/reftest/webgl-clear-test.html
+++ b/content/canvas/test/reftest/webgl-clear-test.html
@@ -13,31 +13,38 @@
 "use strict";
 
 function renderGL(gl) {
   gl.clearColor(0.0, 1.0, 0.0, 1.0);
   gl.clear(gl.COLOR_BUFFER_BIT);
   gl.finish();
 }
 
+function renderFailure(canvas) {
+  // This will also trigger RAF for us.
+  var context = canvas.getContext("2d");
+  context.fillText('WebGL failed.', 64, 64);
+}
+
 function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
-    document.write("Failed to get WebGL context.");
+    renderFailure(canvas);
 
   rAF(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
+
 </script>
 </head>
 
 <body onload="rAF(runTest);">
   <canvas id="canvas" width="256" height="256"></canvas>
 </body>
 
 </html>
--- a/content/canvas/test/reftest/webgl-color-alpha-test.html
+++ b/content/canvas/test/reftest/webgl-color-alpha-test.html
@@ -42,27 +42,33 @@ function renderGL(gl, value, alpha) {
 
   gl.scissor(128, 0, 128, 128);
   gl.clearColor(value, value, value, alpha);
   gl.clear(gl.COLOR_BUFFER_BIT);
 
   gl.finish();
 }
 
+function renderFailure(canvas) {
+  // This will also trigger RAF for us.
+  var context = canvas.getContext("2d");
+  context.fillText('WebGL failed.', 64, 64);
+}
+
 function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   var value = arg("colorVal");
   var alpha = arg("alphaVal");
 
   if (gl)
     renderGL(gl, value, alpha);
   else
-    document.write("Failed to get WebGL context.");
+    renderFailure(canvas);
 
   rAF(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
--- a/content/canvas/test/reftest/webgl-color-test.html
+++ b/content/canvas/test/reftest/webgl-color-test.html
@@ -40,24 +40,30 @@ function renderGL(gl) {
 
   gl.scissor(128, 0, 128, 128);
   gl.clearColor(1.0, 1.0, 1.0, 1.0);
   gl.clear(gl.COLOR_BUFFER_BIT);
 
   gl.finish();
 }
 
+function renderFailure(canvas) {
+  // This will also trigger RAF for us.
+  var context = canvas.getContext("2d");
+  context.fillText('WebGL failed.', 64, 64);
+}
+
 function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
-    document.write("Failed to get WebGL context.");
+    renderFailure(canvas);
 
   rAF(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
--- a/content/canvas/test/reftest/webgl-hanging-fb-test.html
+++ b/content/canvas/test/reftest/webgl-hanging-fb-test.html
@@ -22,24 +22,30 @@ function renderGL(gl) {
   gl.clear(gl.COLOR_BUFFER_BIT);
 
   var fb = gl.createFramebuffer();
   gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
 
   gl.finish();
 }
 
+function renderFailure(canvas) {
+  // This will also trigger RAF for us.
+  var context = canvas.getContext("2d");
+  context.fillText('WebGL failed.', 64, 64);
+}
+
 function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
-    document.write("Failed to get WebGL context.");
+    renderFailure(canvas);
 
   rAF(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
--- a/content/canvas/test/reftest/webgl-hanging-scissor-test.html
+++ b/content/canvas/test/reftest/webgl-hanging-scissor-test.html
@@ -21,24 +21,30 @@ function renderGL(gl) {
   gl.clear(gl.COLOR_BUFFER_BIT);
 
   gl.enable(gl.SCISSOR_TEST);
   gl.scissor(0, 128, 128, 128);
 
   gl.finish();
 }
 
+function renderFailure(canvas) {
+  // This will also trigger RAF for us.
+  var context = canvas.getContext("2d");
+  context.fillText('WebGL failed.', 64, 64);
+}
+
 function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
-    document.write("Failed to get WebGL context.");
+    renderFailure(canvas);
 
   rAF(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
--- a/content/canvas/test/reftest/webgl-orientation-test.html
+++ b/content/canvas/test/reftest/webgl-orientation-test.html
@@ -21,24 +21,30 @@ function renderGL(gl) {
   gl.enable(gl.SCISSOR_TEST);
   gl.scissor(0, 128, 128, 128);
   gl.clearColor(1.0, 1.0, 1.0, 1.0);
   gl.clear(gl.COLOR_BUFFER_BIT);
 
   gl.finish();
 }
 
+function renderFailure(canvas) {
+  // This will also trigger RAF for us.
+  var context = canvas.getContext("2d");
+  context.fillText('WebGL failed.', 64, 64);
+}
+
 function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
-    document.write("Failed to get WebGL context.");
+    renderFailure(canvas);
 
   rAF(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>