Bug 745681: Prepare the reftest harness for Bug 695480. r=dbaron a=test-only
authorKyle Huey <khuey@kylehuey.com>
Mon, 23 Apr 2012 13:36:50 -0700
changeset 92114 b9936b8bcccf
parent 92113 937cdb639def
child 92115 142fe408f5b4
push id22514
push userkhuey@mozilla.com
push date2012-04-23 20:39 +0000
treeherdermozilla-central@b9936b8bcccf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, test-only
bugs745681, 695480
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 745681: Prepare the reftest harness for Bug 695480. r=dbaron a=test-only
layout/tools/reftest/reftest-content.js
--- a/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -506,21 +506,26 @@ function OnDocumentLoad(event)
 
     if (currentDoc.location.href != gCurrentURL) {
         LogInfo("OnDocumentLoad fired for previous document");
         // Ignore load events for previous documents.
         return;
     }
 
     var contentRootElement = currentDoc ? currentDoc.documentElement : null;
+    currentDoc = null;
     setupZoom(contentRootElement);
     setupDisplayport(contentRootElement);
     var inPrintMode = false;
 
     function AfterOnLoadScripts() {
+        // Regrab the root element, because the document may have changed.
+        var contentRootElement =
+          content.document ? content.document.documentElement : null;
+
         // Take a snapshot now. We need to do this before we check whether
         // we should wait, since this might trigger dispatching of
         // MozPaintWait events and make shouldWaitForExplicitPaintWaiters() true
         // below.
         var painted = SendInitCanvasWithSnapshot();
 
         if (shouldWaitForExplicitPaintWaiters() ||
             (!inPrintMode && doPrintMode(contentRootElement)) ||
@@ -666,34 +671,31 @@ function LogWarning(str)
 
 function LogInfo(str)
 {
     sendAsyncMessage("reftest:Log", { type: "info", msg: str });
 }
 
 const SYNC_DEFAULT = 0x0;
 const SYNC_ALLOW_DISABLE = 0x1;
-var gDummyCanvas = null;
 function SynchronizeForSnapshot(flags)
 {
     if (flags & SYNC_ALLOW_DISABLE) {
         var docElt = content.document.documentElement;
         if (docElt && docElt.hasAttribute("reftest-no-sync-layers")) {
             LogInfo("Test file chose to skip SynchronizeForSnapshot");
             return;
         }
     }
 
-    if (gDummyCanvas == null) {
-        gDummyCanvas = content.document.createElementNS(XHTML_NS, "canvas");
-        gDummyCanvas.setAttribute("width", 1);
-        gDummyCanvas.setAttribute("height", 1);
-    }
+    var dummyCanvas = content.document.createElementNS(XHTML_NS, "canvas");
+    dummyCanvas.setAttribute("width", 1);
+    dummyCanvas.setAttribute("height", 1);
 
-    var ctx = gDummyCanvas.getContext("2d");
+    var ctx = dummyCanvas.getContext("2d");
     var flags = ctx.DRAWWINDOW_DRAW_CARET | ctx.DRAWWINDOW_DRAW_VIEW | ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
     ctx.drawWindow(content, 0, 0, 1, 1, "rgb(255,255,255)", flags);
 }
 
 function RegisterMessageListeners()
 {
     addMessageListener(
         "reftest:Clear",