--- 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();