Bug 890409 - Re-enable browser_aboutHome.js but ignoring uncaught exceptions.
authorMarco Bonardo <mbonardo@mozilla.com>
Sat, 13 Jul 2013 11:35:49 +0200
changeset 138675 d80c320f522ab756241660665af0f8211e439fe5
parent 138674 4912bbcb549426a73a46ce60a76e3066e45f894f
child 138676 cb79166bb8fafc65fc7841df0d300d03e07f7b51
push id24964
push userryanvm@gmail.com
push dateTue, 16 Jul 2013 20:04:09 +0000
treeherderautoland@fd10ead17ace [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs890409
milestone25.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 890409 - Re-enable browser_aboutHome.js but ignoring uncaught exceptions. r=ttaubert
browser/base/content/test/Makefile.in
browser/base/content/test/browser_aboutHome.js
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -46,17 +46,16 @@ MOCHITEST_FILES += \
         subtst_contextmenu.html \
         test_contextmenu.html \
         $(NULL)
 endif
 
 # The following tests are disabled because they are unreliable:
 #   browser_bug423833.js is bug 428712
 #   browser_sanitize-download-history.js is bug 432425
-#   browser_aboutHome.js is bug 890409
 #
 # browser_sanitizeDialog_treeView.js is disabled until the tree view is added
 # back to the clear recent history dialog (sanitize.xul), if it ever is (bug
 # 480169)
 
 # browser_drag.js is disabled, as it needs to be updated for the new behavior from bug 320638.
 
 # browser_bug321000.js is disabled because newline handling is shaky (bug 592528)
@@ -67,16 +66,17 @@ MOCHITEST_BROWSER_FILES = \
                  app_bug575561.html \
                  app_subframe_bug575561.html \
                  authenticate.sjs \
                  blockNoPlugins.xml \
                  blockPluginHard.xml \
                  blockPluginVulnerableNoUpdate.xml \
                  blockPluginVulnerableUpdatable.xml \
                  browser_aboutHealthReport.js \
+                 browser_aboutHome.js \
                  browser_aboutSyncProgress.js \
                  browser_addKeywordSearch.js \
                  browser_addon_bar_aomlistener.js \
                  browser_addon_bar_close_button.js \
                  browser_addon_bar_shortcut.js \
                  browser_alltabslistener.js \
                  browser_blob-channelname.js \
                  browser_bug304198.js \
--- a/browser/base/content/test/browser_aboutHome.js
+++ b/browser/base/content/test/browser_aboutHome.js
@@ -99,33 +99,33 @@ let gTests = [
     } catch (ex) {
       // Health Report disabled, or no SearchesProvider.
       return Promise.resolve();
     }
 
     let numSearchesBefore = 0;
     let deferred = Promise.defer();
     let doc = gBrowser.contentDocument;
+    let engineName = doc.documentElement.getAttribute("searchEngineName");
 
     // 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) {
-      let engineName = doc.documentElement.getAttribute("searchEngineName");
       is(e.detail, engineName, "Detail is search engine name");
 
       gBrowser.stop();
 
-      getNumberOfSearches().then(num => {
+      getNumberOfSearches(engineName).then(num => {
         is(num, numSearchesBefore + 1, "One more search recorded.");
         deferred.resolve();
       });
     }, true, true);
 
     // Get the current number of recorded searches.
-    getNumberOfSearches().then(num => {
+    getNumberOfSearches(engineName).then(num => {
       numSearchesBefore = num;
 
       info("Perform a search.");
       doc.getElementById("searchText").value = "a search";
       doc.getElementById("searchSubmit").click();
     });
 
     return deferred.promise;
@@ -258,16 +258,17 @@ let gTests = [
 }
 
 ];
 
 function test()
 {
   waitForExplicitFinish();
   requestLongerTimeout(2);
+  ignoreAllUncaughtExceptions();
 
   Task.spawn(function () {
     for (let test of gTests) {
       info(test.desc);
 
       if (test.beforeRun)
         yield test.beforeRun();
 
@@ -389,19 +390,22 @@ function promiseBrowserAttributes(aTab)
   observer.observe(docElt, { attributes: true });
 
   return deferred.promise;
 }
 
 /**
  * Retrieves the number of about:home searches recorded for the current day.
  *
+ * @param aEngineName
+ *        name of the setup search engine.
+ *
  * @return {Promise} Returns a promise resolving to the number of searches.
  */
-function getNumberOfSearches() {
+function getNumberOfSearches(aEngineName) {
   let reporter = Components.classes["@mozilla.org/datareporting/service;1"]
                                    .getService()
                                    .wrappedJSObject
                                    .healthReporter;
   ok(reporter, "Health Reporter instance available.");
 
   return reporter.onInit().then(function onInit() {
     let provider = reporter.getProvider("org.mozilla.searches");
@@ -414,27 +418,25 @@ function getNumberOfSearches() {
       yday.setDate(yday.getDate() - 1);
 
       // Add the number of searches recorded yesterday to the number of searches
       // recorded today. This makes the test not fail intermittently when it is
       // run at midnight and we accidentally compare the number of searches from
       // different days. Tests are always run with an empty profile so there
       // are no searches from yesterday, normally. Should the test happen to run
       // past midnight we make sure to count them in as well.
-      return getNumberOfSearchesByDate(data, now) +
-             getNumberOfSearchesByDate(data, yday);
+      return getNumberOfSearchesByDate(aEngineName, data, now) +
+             getNumberOfSearchesByDate(aEngineName, data, yday);
     });
   });
 }
 
-function getNumberOfSearchesByDate(aData, aDate) {
+function getNumberOfSearchesByDate(aEngineName, aData, aDate) {
   if (aData.days.hasDay(aDate)) {
-    let doc = gBrowser.contentDocument;
-    let engineName = doc.documentElement.getAttribute("searchEngineName");
-    let id = Services.search.getEngineByName(engineName).identifier;
+    let id = Services.search.getEngineByName(aEngineName).identifier;
 
     let day = aData.days.getDay(aDate);
     let field = id + ".abouthome";
 
     if (day.has(field)) {
       return day.get(field) || 0;
     }
   }