Bug 890409 - Re-enable browser_aboutHome.js but ignoring uncaught exceptions.

r=ttaubert
This commit is contained in:
Marco Bonardo 2013-07-13 11:35:49 +02:00
Родитель 225c6feacc
Коммит 9ae07d3c2f
2 изменённых файлов: 13 добавлений и 11 удалений

Просмотреть файл

@ -51,7 +51,6 @@ endif
# The following tests are disabled because they are unreliable: # The following tests are disabled because they are unreliable:
# browser_bug423833.js is bug 428712 # browser_bug423833.js is bug 428712
# browser_sanitize-download-history.js is bug 432425 # 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 # 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 # back to the clear recent history dialog (sanitize.xul), if it ever is (bug
@ -72,6 +71,7 @@ MOCHITEST_BROWSER_FILES = \
blockPluginVulnerableNoUpdate.xml \ blockPluginVulnerableNoUpdate.xml \
blockPluginVulnerableUpdatable.xml \ blockPluginVulnerableUpdatable.xml \
browser_aboutHealthReport.js \ browser_aboutHealthReport.js \
browser_aboutHome.js \
browser_aboutSyncProgress.js \ browser_aboutSyncProgress.js \
browser_addKeywordSearch.js \ browser_addKeywordSearch.js \
browser_addon_bar_aomlistener.js \ browser_addon_bar_aomlistener.js \

Просмотреть файл

@ -104,23 +104,23 @@ let gTests = [
let numSearchesBefore = 0; let numSearchesBefore = 0;
let deferred = Promise.defer(); let deferred = Promise.defer();
let doc = gBrowser.contentDocument; let doc = gBrowser.contentDocument;
let engineName = doc.documentElement.getAttribute("searchEngineName");
// We rely on the listener in browser.js being installed and fired before // 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. // this one. If this ever changes, we should add an executeSoon() or similar.
doc.addEventListener("AboutHomeSearchEvent", function onSearch(e) { doc.addEventListener("AboutHomeSearchEvent", function onSearch(e) {
let engineName = doc.documentElement.getAttribute("searchEngineName");
is(e.detail, engineName, "Detail is search engine name"); is(e.detail, engineName, "Detail is search engine name");
gBrowser.stop(); gBrowser.stop();
getNumberOfSearches().then(num => { getNumberOfSearches(engineName).then(num => {
is(num, numSearchesBefore + 1, "One more search recorded."); is(num, numSearchesBefore + 1, "One more search recorded.");
deferred.resolve(); deferred.resolve();
}); });
}, true, true); }, true, true);
// Get the current number of recorded searches. // Get the current number of recorded searches.
getNumberOfSearches().then(num => { getNumberOfSearches(engineName).then(num => {
numSearchesBefore = num; numSearchesBefore = num;
info("Perform a search."); info("Perform a search.");
@ -263,6 +263,7 @@ function test()
{ {
waitForExplicitFinish(); waitForExplicitFinish();
requestLongerTimeout(2); requestLongerTimeout(2);
ignoreAllUncaughtExceptions();
Task.spawn(function () { Task.spawn(function () {
for (let test of gTests) { for (let test of gTests) {
@ -394,9 +395,12 @@ function promiseBrowserAttributes(aTab)
/** /**
* Retrieves the number of about:home searches recorded for the current day. * 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. * @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"] let reporter = Components.classes["@mozilla.org/datareporting/service;1"]
.getService() .getService()
.wrappedJSObject .wrappedJSObject
@ -419,17 +423,15 @@ function getNumberOfSearches() {
// different days. Tests are always run with an empty profile so there // different days. Tests are always run with an empty profile so there
// are no searches from yesterday, normally. Should the test happen to run // are no searches from yesterday, normally. Should the test happen to run
// past midnight we make sure to count them in as well. // past midnight we make sure to count them in as well.
return getNumberOfSearchesByDate(data, now) + return getNumberOfSearchesByDate(aEngineName, data, now) +
getNumberOfSearchesByDate(data, yday); getNumberOfSearchesByDate(aEngineName, data, yday);
}); });
}); });
} }
function getNumberOfSearchesByDate(aData, aDate) { function getNumberOfSearchesByDate(aEngineName, aData, aDate) {
if (aData.days.hasDay(aDate)) { if (aData.days.hasDay(aDate)) {
let doc = gBrowser.contentDocument; let id = Services.search.getEngineByName(aEngineName).identifier;
let engineName = doc.documentElement.getAttribute("searchEngineName");
let id = Services.search.getEngineByName(engineName).identifier;
let day = aData.days.getDay(aDate); let day = aData.days.getDay(aDate);
let field = id + ".abouthome"; let field = id + ".abouthome";