Bug 899080 - Test fixup part 1 - Always enable test-plugins for reftests. r=jmaher
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 04 Sep 2013 16:05:31 +0200
changeset 145517 46a5c7cf1ec40ee749f2c1c913d3f45902759bd9
parent 145516 0e9fc39801fc88c3d649967320459a2919239f35
child 145518 3bcbfbc9591bda8c4de01d18371bc70cbe9a763f
push id33305
push usergeorg.fritzsche@googlemail.com
push dateWed, 04 Sep 2013 21:10:31 +0000
treeherdermozilla-inbound@1e63861a73d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs899080
milestone26.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 899080 - Test fixup part 1 - Always enable test-plugins for reftests. r=jmaher
layout/tools/reftest/reftest.js
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -104,16 +104,19 @@ var gSlowestTestURL;
 var gDrawWindowFlags;
 
 var gExpectingProcessCrash = false;
 var gExpectedCrashDumpFiles = [];
 var gUnexpectedCrashDumpFiles = { };
 var gCrashDumpDir;
 var gFailedNoPaint = false;
 
+// The enabled-state of the test-plugins, stored so they can be reset later
+var gTestPluginEnabledStates = null;
+
 const TYPE_REFTEST_EQUAL = '==';
 const TYPE_REFTEST_NOTEQUAL = '!=';
 const TYPE_LOAD = 'load';     // test without a reference (just test that it does
                               // not assert, crash, hang, or leak)
 const TYPE_SCRIPT = 'script'; // test contains individual test results
 
 // The order of these constants matters, since when we have a status
 // listed for a *manifest*, we combine the status with the status for
@@ -203,16 +206,30 @@ function IDForEventTarget(event)
 {
     try {
         return "'" + event.target.getAttribute('id') + "'";
     } catch (ex) {
         return "<unknown>";
     }
 }
 
+function getTestPlugin(aName) {
+  var ph = CC["@mozilla.org/plugin/host;1"].getService(CI.nsIPluginHost);
+  var tags = ph.getPluginTags();
+
+  // Find the test plugin
+  for (var i = 0; i < tags.length; i++) {
+    if (tags[i].name == aName)
+      return tags[i];
+  }
+
+  LogWarning("Failed to find the test-plugin.");
+  return null;
+}
+
 this.OnRefTestLoad = function OnRefTestLoad(win)
 {
     gCrashDumpDir = CC[NS_DIRECTORY_SERVICE_CONTRACTID]
                     .getService(CI.nsIProperties)
                     .get("ProfD", CI.nsIFile);
     gCrashDumpDir.append("minidumps");
 
     var env = CC["@mozilla.org/process/environment;1"].
@@ -262,16 +279,27 @@ this.OnRefTestLoad = function OnRefTestL
     while (doc.hasChildNodes()) {
       doc.removeChild(doc.firstChild);
     }
     doc.appendChild(gBrowser);
 #else
     document.getElementById("reftest-window").appendChild(gBrowser);
 #endif
 
+    // reftests should have the test plugins enabled, not click-to-play
+    let plugin1 = getTestPlugin("Test Plug-in");
+    let plugin2 = getTestPlugin("Second Test Plug-in");
+    if (plugin1 && plugin2) {
+      gTestPluginEnabledStates = [plugin1.enabledState, plugin2.enabledState];
+      plugin1.enabledState = CI.nsIPluginTag.STATE_ENABLED;
+      plugin2.enabledState = CI.nsIPluginTag.STATE_ENABLED;
+    } else {
+      LogWarning("Could not get test plugin tags.");
+    }
+
     gBrowserMessageManager = gBrowser.QueryInterface(CI.nsIFrameLoaderOwner)
                                      .frameLoader.messageManager;
     // The content script waits for the initial onload, then notifies
     // us.
     RegisterMessageListenersAndLoadContentScript();
 }
 
 function InitAndStartRefTests()
@@ -493,16 +521,24 @@ function StartTests()
         ++gTestResults.Exception;
         gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + ex + "\n");
         DoneTests();
     }
 }
 
 function OnRefTestUnload()
 {
+  let plugin1 = getTestPlugin("Test Plug-in");
+  let plugin2 = getTestPlugin("Second Test Plug-in");
+  if (plugin1 && plugin2) {
+    plugin1.enabledState = gTestPluginEnabledStates[0];
+    plugin2.enabledState = gTestPluginEnabledStates[1];
+  } else {
+    LogWarning("Failed to get test plugin tags.");
+  }
 }
 
 // Read all available data from an input stream and return it
 // as a string.
 function getStreamContent(inputStream)
 {
     var streamBuf = "";
     var sis = CC["@mozilla.org/scriptableinputstream;1"].