From 9ae07d3c2f302f5e2809a01e943aefc63980da68 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Sat, 13 Jul 2013 11:35:49 +0200 Subject: [PATCH] Bug 890409 - Re-enable browser_aboutHome.js but ignoring uncaught exceptions. r=ttaubert --- browser/base/content/test/Makefile.in | 2 +- .../base/content/test/browser_aboutHome.js | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index cbed37e69219..1dc05eaed6d6 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -51,7 +51,6 @@ 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 @@ -72,6 +71,7 @@ MOCHITEST_BROWSER_FILES = \ blockPluginVulnerableNoUpdate.xml \ blockPluginVulnerableUpdatable.xml \ browser_aboutHealthReport.js \ + browser_aboutHome.js \ browser_aboutSyncProgress.js \ browser_addKeywordSearch.js \ browser_addon_bar_aomlistener.js \ diff --git a/browser/base/content/test/browser_aboutHome.js b/browser/base/content/test/browser_aboutHome.js index 12c3080a6b33..552aec7e8f3c 100644 --- a/browser/base/content/test/browser_aboutHome.js +++ b/browser/base/content/test/browser_aboutHome.js @@ -104,23 +104,23 @@ let gTests = [ 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."); @@ -263,6 +263,7 @@ function test() { waitForExplicitFinish(); requestLongerTimeout(2); + ignoreAllUncaughtExceptions(); Task.spawn(function () { for (let test of gTests) { @@ -394,9 +395,12 @@ function promiseBrowserAttributes(aTab) /** * 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 @@ -419,17 +423,15 @@ function getNumberOfSearches() { // 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";