Bug 1392143 - P3. Retry the readback after relocating the window to (0,0). r?mattwoodrow draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 06 Sep 2017 18:59:07 +0200
changeset 660411 cf46f868733c9e1e31b30f1399fe78451640317e
parent 660410 7a5a63ff39d6762a177a93493cba7238f388ffa4
child 730226 6cd91ef377a0ee2802f1422f1ec82993b731202b
push id78391
push userbmo:jyavenard@mozilla.com
push dateWed, 06 Sep 2017 23:07:16 +0000
reviewersmattwoodrow
bugs1392143, 1397253
milestone57.0a1
Bug 1392143 - P3. Retry the readback after relocating the window to (0,0). r?mattwoodrow This is a workaround until bug 1397253 is resolved. MozReview-Commit-ID: I3jLkbPRNE4
toolkit/components/gfx/SanityTest.js
--- a/toolkit/components/gfx/SanityTest.js
+++ b/toolkit/components/gfx/SanityTest.js
@@ -121,44 +121,52 @@ function verifyVideoRendering(ctx) {
 
 // Verify that the middle of the layers test is the color we expect.
 // It's a red 64x64 square, test a pixel deep into the 64x64 square
 // to prevent fuzzing.
 function verifyLayersRendering(ctx) {
   return testPixel(ctx, 18, 18, 255, 0, 0, 255, 64);
 }
 
-function testCompositor(test, win, ctx) {
+function testCompositor(test, win, ctx, firstRun) {
   takeWindowSnapshot(win, ctx);
   var testPassed = true;
 
   if (!verifyVideoRendering(ctx)) {
-    reportResult(TEST_FAILED_VIDEO);
-    Services.prefs.setBoolPref(DISABLE_VIDEO_PREF, true);
+    if (!firstRun) {
+      reportResult(TEST_FAILED_VIDEO);
+      Services.prefs.setBoolPref(DISABLE_VIDEO_PREF, true);
+    }
     testPassed = false;
   }
 
   if (!verifyLayersRendering(ctx)) {
-    // Try disabling advanced layers if it was enabled. Also trgiger
-    // a device reset so the screen redraws.
-    if (Services.prefs.getBoolPref(AL_ENABLED_PREF, false)) {
-      Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, true);
-      test.utils.triggerDeviceReset();
+    if (!firstRun) {
+      // Try disabling advanced layers if it was enabled. Also trigger
+      // a device reset so the screen redraws.
+      if (Services.prefs.getBoolPref(AL_ENABLED_PREF, false)) {
+        Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, true);
+         test.utils.triggerDeviceReset();
+      }
+      reportResult(TEST_FAILED_RENDER);
     }
-    reportResult(TEST_FAILED_RENDER);
     testPassed = false;
   } else {
     Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, false);
   }
 
   if (testPassed) {
     reportResult(TEST_PASSED);
+    return true;
   }
 
-  return testPassed;
+  // The reads failed, move the window to 0,0 and attempt the test again.
+  // See bug 1397253.
+  win.moveTo(0, 0);
+  return testCompositor(test, win, ctx, false /* first run */);
 }
 
 var listener = {
   win: null,
   utils: null,
   canvas: null,
   ctx: null,
   mm: null,
@@ -183,17 +191,17 @@ var listener = {
   runSanityTest() {
     this.canvas = this.win.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
     this.canvas.setAttribute("width", PAGE_WIDTH);
     this.canvas.setAttribute("height", PAGE_HEIGHT);
     this.ctx = this.canvas.getContext("2d");
 
     // Perform the compositor backbuffer test, which currently we use for
     // actually deciding whether to enable hardware media decoding.
-    testCompositor(this, this.win, this.ctx);
+    testCompositor(this, this.win, this.ctx, true /* first run */);
 
     this.endTest();
   },
 
   receiveMessage(message) {
     switch (message.name) {
       case "gfxSanity:ContentLoaded":
         this.runSanityTest();