Bug 892990 - Cap waiting time for wait-for-composite in WebGL reftests. r=bjacob, a=test-only
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 14 Apr 2014 15:43:57 -0700
changeset 183763 a27d9f49afac
parent 183762 7938ad1529f9
child 183764 843dc71f729b
push id3476
push userryanvm@gmail.com
push date2014-04-15 17:26 +0000
treeherdermozilla-beta@c8f1a4f5ca4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob, test-only
bugs892990
milestone29.0
Bug 892990 - Cap waiting time for wait-for-composite in WebGL reftests. r=bjacob, a=test-only
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-disable-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
content/canvas/test/reftest/webgl-resize-test.html
content/canvas/test/reftest/webgl-utils.js
--- a/content/canvas/test/reftest/webgl-clear-test.html
+++ b/content/canvas/test/reftest/webgl-clear-test.html
@@ -28,17 +28,17 @@ function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
     renderFailure(canvas);
 
-  rAF(testComplete);
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 
 </script>
 </head>
--- a/content/canvas/test/reftest/webgl-color-alpha-test.html
+++ b/content/canvas/test/reftest/webgl-color-alpha-test.html
@@ -60,17 +60,17 @@ function runTest() {
   var value = arg("colorVal");
   var alpha = arg("alphaVal");
 
   if (gl)
     renderGL(gl, value, alpha);
   else
     renderFailure(canvas);
 
-  rAF(testComplete);
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
 </head>
 
--- a/content/canvas/test/reftest/webgl-color-test.html
+++ b/content/canvas/test/reftest/webgl-color-test.html
@@ -55,17 +55,17 @@ function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
     renderFailure(canvas);
 
-  rAF(testComplete);
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
 </head>
 
--- a/content/canvas/test/reftest/webgl-disable-test.html
+++ b/content/canvas/test/reftest/webgl-disable-test.html
@@ -39,17 +39,17 @@ function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
     renderBackup(canvas);
 
-  rAF(testComplete);
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
 </head>
 
--- a/content/canvas/test/reftest/webgl-hanging-fb-test.html
+++ b/content/canvas/test/reftest/webgl-hanging-fb-test.html
@@ -37,17 +37,17 @@ function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
     renderFailure(canvas);
 
-  rAF(testComplete);
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
 </head>
 
--- a/content/canvas/test/reftest/webgl-hanging-scissor-test.html
+++ b/content/canvas/test/reftest/webgl-hanging-scissor-test.html
@@ -36,17 +36,17 @@ function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
     renderFailure(canvas);
 
-  rAF(testComplete);
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
 </head>
 
--- a/content/canvas/test/reftest/webgl-orientation-test.html
+++ b/content/canvas/test/reftest/webgl-orientation-test.html
@@ -36,17 +36,17 @@ function runTest() {
   var canvas = document.getElementById("canvas");
   var gl = initGL(canvas);
 
   if (gl)
     renderGL(gl);
   else
     renderFailure(canvas);
 
-  rAF(testComplete);
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
 </head>
 
--- a/content/canvas/test/reftest/webgl-resize-test.html
+++ b/content/canvas/test/reftest/webgl-resize-test.html
@@ -37,17 +37,17 @@ function runTest() {
   var canvas = document.getElementById("canvas");
 
   var gl = initGL(canvas);
   if (gl)
     render(gl);
   else
     renderFailure(canvas);
 
-  testComplete();
+  waitForComposite(testComplete);
 }
 
 function testComplete() {
   document.documentElement.removeAttribute("class");
 }
 </script>
 </head>
 
--- a/content/canvas/test/reftest/webgl-utils.js
+++ b/content/canvas/test/reftest/webgl-utils.js
@@ -61,8 +61,23 @@ function initGL(canvas) {
 
   return gl;
 }
 
 function rAF(func) {
   var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame;
   raf(func);
 }
+
+var MAX_WAIT_FOR_COMPOSITE_DELAY_MS = 500;
+
+function waitForComposite(func) {
+  var isDone = false;
+  var doneFunc = function () {
+    if (isDone)
+      return;
+    isDone = true;
+    func();
+  };
+
+  rAF(doneFunc);
+  setTimeout(doneFunc, MAX_WAIT_FOR_COMPOSITE_DELAY_MS);
+}