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 95427 b9936b8bcccfa0c3f7e8590127554e1bb19b9d97
parent 95426 937cdb639def297cdc98730022a9244e7fb8d955
child 95428 142fe408f5b4a805ca76406b62b2a2163ddeed2c
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [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",