Bug 843980 - Switch tests to check for category entries, not service existence. r=mconnor, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Fri, 22 Feb 2013 10:31:05 -0500
changeset 132212 f969044f823db7320c8f3c5934899a7516fea939
parent 132211 ce2c2ccdb6402edd91b3b3f79806f25c78902b21
child 132213 193bdc595cd14b3c0bf391a907fadfd5886b0fd6
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconnor, bajaj
bugs843980
milestone21.0a2
Bug 843980 - Switch tests to check for category entries, not service existence. r=mconnor, a=bajaj
browser/base/content/test/browser_aboutHome.js
browser/base/content/test/browser_contextSearchTabPosition.js
browser/base/content/test/browser_urlbar_search_healthreport.js
browser/components/search/test/browser_healthreport.js
--- a/browser/base/content/test/browser_aboutHome.js
+++ b/browser/base/content/test/browser_aboutHome.js
@@ -105,22 +105,25 @@ let gTests = [
     doc.getElementById("searchText").value = "it works";
     doc.getElementById("searchSubmit").click();
   },
 },
 {
   desc: "Check that performing a search records to Firefox Health Report.",
   setup: function () { },
   run: function () {
-    if (!("@mozilla.org/datareporting/service;1" in Components.classes)) {
+    try {
+      let cm = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
+      cm.getCategoryEntry("healthreport-js-provider", "SearchesProvider");
+    } catch (ex) {
+      // Health Report disabled, or no SearchesProvider.
       runNextTest();
       return;
     }
 
-
     let doc = gBrowser.contentDocument;
 
     // We rely on the listener in browser.js being installed and fired before
     // this one. If this ever changes, we should add an executeSoon() or similar.
     doc.addEventListener("AboutHomeSearchEvent", function onSearch(e) {
       executeSoon(gBrowser.stop.bind(gBrowser));
       let reporter = Components.classes["@mozilla.org/datareporting/service;1"]
                                        .getService()
--- a/browser/base/content/test/browser_contextSearchTabPosition.js
+++ b/browser/base/content/test/browser_contextSearchTabPosition.js
@@ -21,17 +21,22 @@ function test() {
 
   is(tabs[0], gBrowser.tabs[3], "blank tab has been pushed to the end");
   is(tabs[1], gBrowser.tabs[1], "first search tab opens next to the current tab");
   is(tabs[2], gBrowser.tabs[2], "second search tab opens next to the first search tab");
 
   container.removeEventListener("TabOpen", tabAdded, false);
   tabs.forEach(gBrowser.removeTab, gBrowser);
 
-  if (!"@mozilla.org/datareporting/service;1" in Components.classes) {
+  try {
+    let cm = Components.classes["@mozilla.org/categorymanager;1"]
+                       .getService(Components.interfaces.nsICategoryManager);
+    cm.getCategoryEntry("healthreport-js-provider", "SearchesProvider");
+  } catch (ex) {
+    // Health Report disabled, or no SearchesProvider.
     finish();
     return;
   }
 
   let reporter = Components.classes["@mozilla.org/datareporting/service;1"]
                                    .getService()
                                    .wrappedJSObject
                                    .healthReporter;
--- a/browser/base/content/test/browser_urlbar_search_healthreport.js
+++ b/browser/base/content/test/browser_urlbar_search_healthreport.js
@@ -1,17 +1,20 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 function test() {
   waitForExplicitFinish();
-
-  if (!("@mozilla.org/datareporting/service;1" in Cc)) {
+  try {
+    let cm = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
+    cm.getCategoryEntry("healthreport-js-provider", "SearchesProvider");
+  } catch (ex) {
+    // Health Report disabled, or no SearchesProvider.
     ok(true, "Firefox Health Report is not enabled.");
     finish();
     return;
   }
 
   let reporter = Cc["@mozilla.org/datareporting/service;1"]
                    .getService()
                    .wrappedJSObject
--- a/browser/components/search/test/browser_healthreport.js
+++ b/browser/components/search/test/browser_healthreport.js
@@ -1,17 +1,22 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 function test() {
   waitForExplicitFinish();
 
-  if (!("@mozilla.org/datareporting/service;1" in Components.classes)) {
+  try {
+    let cm = Components.classes["@mozilla.org/categorymanager;1"]
+                       .getService(Components.interfaces.nsICategoryManager);
+    cm.getCategoryEntry("healthreport-js-provider", "SearchesProvider");
+  } catch (ex) {
+    // Health Report disabled, or no SearchesProvider.
     // We need a test or else we'll be marked as failure.
     ok(true, "Firefox Health Report is not enabled.");
     finish();
     return;
   }
 
   function testFHR() {
     let reporter = Components.classes["@mozilla.org/datareporting/service;1"]