Bug 775495 - Replace waitForClearHistory and waitForAsyncUpdates with versions that return promises, and remove waitForFrecency. r=mak

This commit is contained in:
Paolo Amadini 2012-11-11 14:01:49 +01:00
parent 91c64afae4
commit 6dc2df3e0e
45 changed files with 260 additions and 279 deletions

View File

@ -22,7 +22,7 @@ function waitForImportAndSmartBookmarks(aCallback) {
Services.obs.removeObserver(waitImport, "bookmarks-restore-success");
// Delay to test eventual smart bookmarks creation.
do_execute_soon(function () {
waitForAsyncUpdates(aCallback);
promiseAsyncUpdates().then(aCallback);
});
}, "bookmarks-restore-success", false);
}

View File

@ -340,7 +340,7 @@ function waitForImportAndSmartBookmarks(aCallback) {
Services.obs.removeObserver(waitImport, "bookmarks-restore-success");
// Delay to test eventual smart bookmarks creation.
do_execute_soon(function () {
waitForAsyncUpdates(aCallback);
promiseAsyncUpdates().then(aCallback);
});
}, "bookmarks-restore-success", false);
}

View File

@ -257,7 +257,7 @@ function run_test() {
// At this point frecency could still be updating due to latest pages updates.
// This is not a problem in real life, but autocomplete tests should return
// reliable resultsets, thus we have to wait.
waitForAsyncUpdates(ensure_results, this, [search, expected]);
promiseAsyncUpdates().then(function () ensure_results(search, expected));
}
// Utility function to remove history pages

View File

@ -69,7 +69,7 @@ add_test(function test_addBookmarkWithKeyword()
check_bookmark_keyword(itemId, "keyword");
check_uri_keyword(URIS[0], "keyword");
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
check_orphans();
run_next_test();
});
@ -86,7 +86,7 @@ add_test(function test_addBookmarkToURIHavingKeyword()
check_bookmark_keyword(itemId, null);
check_uri_keyword(URIS[0], "keyword");
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
check_orphans();
run_next_test();
});
@ -112,7 +112,7 @@ add_test(function test_addSameKeywordToOtherURI()
check_uri_keyword(URIS[1], "keyword");
check_uri_keyword(URIS[0], "keyword");
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
check_orphans();
run_next_test();
});
@ -135,7 +135,7 @@ add_test(function test_removeBookmarkWithKeyword()
check_uri_keyword(URIS[1], "keyword");
check_uri_keyword(URIS[0], "keyword");
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
check_orphans();
run_next_test();
});
@ -149,7 +149,7 @@ add_test(function test_removeFolderWithKeywordedBookmarks()
check_uri_keyword(URIS[1], null);
check_uri_keyword(URIS[0], null);
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
check_orphans();
run_next_test();
});

View File

@ -48,7 +48,7 @@ function test() {
is(historyObserver.visitCount[aURI], 1,
"onVisit has been received right number of times for " + aURI);
}
waitForClearHistory(finish);
promiseClearHistory().then(finish);
}
var loadCount = 0;

View File

@ -55,7 +55,7 @@ function errorListener() {
"Docshell URI is the original URI.");
// Global history does not record URI of a failed request.
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
gAsyncHistory.isURIVisited(kUniqueURI, errorAsyncListener);
});
}
@ -91,14 +91,14 @@ function reloadListener() {
"Document URI is not the offline-error page, but the original URI.");
// Check if global history remembers the successfully-requested URI.
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
gAsyncHistory.isURIVisited(kUniqueURI, reloadAsyncListener);
});
}
function reloadAsyncListener(aURI, aIsVisited) {
ok(kUniqueURI.equals(aURI) && aIsVisited, "We have visited the URI.");
waitForClearHistory(finish);
promiseClearHistory().then(finish);
}
registerCleanupFunction(function() {

View File

@ -21,7 +21,7 @@ function test() {
is(aFrecency, 0, "Frecency should be 0");
fieldForUrl(aURI, "hidden", function (aHidden) {
is(aHidden, 0, "Page should not be hidden");
waitForClearHistory(finish);
promiseClearHistory().then(finish);
});
});
},

View File

@ -35,7 +35,7 @@ function test() {
fieldForUrl(TARGET_URI, "hidden", function (aHidden) {
is(aHidden, 0, "The target page should not be hidden");
waitForClearHistory(finish);
promiseClearHistory().then(finish);
});
});
});

View File

@ -8,7 +8,7 @@ gBrowser.selectedTab = gBrowser.addTab();
function finishAndCleanUp()
{
gBrowser.removeCurrentTab();
waitForClearHistory(finish);
promiseClearHistory().then(finish);
}
/**

View File

@ -8,7 +8,7 @@ gBrowser.selectedTab = gBrowser.addTab();
function finishAndCleanUp()
{
gBrowser.removeCurrentTab();
waitForClearHistory(finish);
promiseClearHistory().then(finish);
}
/**

View File

@ -50,7 +50,7 @@ function test()
if (uri.spec != FINAL_URL)
return;
gBrowser.removeCurrentTab();
waitForClearHistory(finish);
promiseClearHistory().then(finish);
});
Services.prefs.setBoolPref("places.history.enabled", false);

View File

@ -60,7 +60,7 @@ function test()
if (uri.spec != FINAL_URL)
return;
gBrowser.removeCurrentTab();
waitForClearHistory(finish);
promiseClearHistory().then(finish);
});
content.location.href = INITIAL_URL;

View File

@ -3,31 +3,51 @@
Components.utils.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/commonjs/promise/core.js");
/**
* Waits for completion of a clear history operation, before
* proceeding with aCallback.
* Allows waiting for an observer notification once.
*
* @param aCallback
* Function to be called when done.
* @param aTopic
* Notification topic to observe.
*
* @return {Promise}
* @resolves The array [aSubject, aData] from the observed notification.
* @rejects Never.
*/
function waitForClearHistory(aCallback) {
Services.obs.addObserver(function observeCH(aSubject, aTopic, aData) {
Services.obs.removeObserver(observeCH, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
aCallback();
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
PlacesUtils.bhistory.removeAllPages();
function promiseTopicObserved(aTopic)
{
let deferred = Promise.defer();
Services.obs.addObserver(
function PTO_observe(aSubject, aTopic, aData) {
Services.obs.removeObserver(PTO_observe, aTopic);
deferred.resolve([aSubject, aData]);
}, aTopic, false);
return deferred.promise;
}
/**
* Waits for all pending async statements on the default connection, before
* proceeding with aCallback.
* Clears history asynchronously.
*
* @param aCallback
* Function to be called when done.
* @param aScope
* Scope for the callback.
* @param aArguments
* Arguments array for the callback.
* @return {Promise}
* @resolves When history has been cleared.
* @rejects Never.
*/
function promiseClearHistory() {
let promise = promiseTopicObserved(PlacesUtils.TOPIC_EXPIRATION_FINISHED);
PlacesUtils.bhistory.removeAllPages();
return promise;
}
/**
* Waits for all pending async statements on the default connection.
*
* @return {Promise}
* @resolves When all pending async statements finished.
* @rejects Never.
*
* @note The result is achieved by asynchronously executing a query requiring
* a write lock. Since all statements on the same connection are
@ -35,10 +55,10 @@ function waitForClearHistory(aCallback) {
* complete. Note that WAL makes so that writers don't block readers, but
* this is a problem only across different connections.
*/
function waitForAsyncUpdates(aCallback, aScope, aArguments)
function promiseAsyncUpdates()
{
let scope = aScope || this;
let args = aArguments || [];
let deferred = Promise.defer();
let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection;
let begin = db.createAsyncStatement("BEGIN EXCLUSIVE");
@ -51,10 +71,12 @@ function waitForAsyncUpdates(aCallback, aScope, aArguments)
handleError: function() {},
handleCompletion: function(aReason)
{
aCallback.apply(scope, args);
deferred.resolve();
}
});
commit.finalize();
return deferred.promise;
}
/**
@ -90,25 +112,3 @@ function fieldForUrl(aURI, aFieldName, aCallback)
});
stmt.finalize();
}
function waitForAsyncUpdates(aCallback, aScope, aArguments)
{
let scope = aScope || this;
let args = aArguments || [];
let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection;
let begin = db.createAsyncStatement("BEGIN EXCLUSIVE");
begin.executeAsync();
begin.finalize();
let commit = db.createAsyncStatement("COMMIT");
commit.executeAsync({
handleResult: function() {},
handleError: function() {},
handleCompletion: function(aReason)
{
aCallback.apply(scope, args);
}
});
commit.finalize();
}

View File

@ -36,7 +36,7 @@ add_test(function test_expire_orphans()
do_check_false(page_in_database("http://page3.mozilla.org/"));
// Clean up.
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
// Expire now.
@ -69,7 +69,7 @@ add_test(function test_expire_orphans_optionalarg()
do_check_false(page_in_database("http://page3.mozilla.org/"));
// Clean up.
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
// Expire now.
@ -96,7 +96,7 @@ add_test(function test_expire_limited()
do_check_eq(visits_in_database("http://page2.mozilla.org/"), 1);
// Clean up.
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
// Expire now.
@ -123,7 +123,7 @@ add_test(function test_expire_unlimited()
do_check_false(page_in_database("http://page2.mozilla.org/"));
// Clean up.
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
// Expire now.

View File

@ -120,7 +120,7 @@ function run_next_test() {
else {
clearMaxPages();
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
waitForClearHistory(do_test_finished);
promiseClearHistory().then(do_test_finished);
}
}
@ -131,5 +131,5 @@ function check_result() {
// Clean up.
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}

View File

@ -142,7 +142,7 @@ function run_next_test() {
else {
clearMaxPages();
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
waitForClearHistory(do_test_finished);
promiseClearHistory().then(do_test_finished);
}
}
@ -153,5 +153,5 @@ function check_result() {
// Clean up.
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}

View File

@ -131,7 +131,7 @@ function run_next_test() {
}
else {
clearMaxPages();
waitForClearHistory(do_test_finished);
promiseClearHistory().then(do_test_finished);
}
}
@ -141,5 +141,5 @@ function check_result() {
gCurrentTest.expectedNotifications);
// Clean up.
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}

View File

@ -69,7 +69,7 @@ add_test(function test_query_result_favicon_changed_on_child()
// operation, and then for the main thread to process any pending
// notifications that came from the asynchronous thread, before we can be
// sure that nodeIconChanged was not invoked in the meantime.
waitForAsyncUpdates(function QRFCOC_asyncUpdates() {
promiseAsyncUpdates().then(function QRFCOC_asyncUpdates() {
do_execute_soon(function QRFCOC_soon() {
result.removeObserver(resultObserver);

View File

@ -87,7 +87,7 @@ add_test(function test_replaceFaviconData_validHistoryURI() {
pageURI, favicon.mimetype, favicon.data,
function test_replaceFaviconData_validHistoryURI_callback() {
favicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -114,7 +114,7 @@ add_test(function test_replaceFaviconData_overrideDefaultFavicon() {
function test_replaceFaviconData_overrideDefaultFavicon_callback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -139,13 +139,13 @@ add_test(function test_replaceFaviconData_replaceExisting() {
iconsvc.replaceFaviconData(
firstFavicon.uri, secondFavicon.data, secondFavicon.data.length,
secondFavicon.mimetype);
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
checkFaviconDataForPage(
pageURI, secondFavicon.mimetype, secondFavicon.data,
function test_replaceFaviconData_overrideDefaultFavicon_secondCallback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -174,7 +174,7 @@ add_test(function test_replaceFaviconData_unrelatedReplace() {
function test_replaceFaviconData_unrelatedReplace_callback() {
favicon.file.remove(false);
unrelatedFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -215,7 +215,7 @@ add_test(function test_replaceFaviconData_badInputs() {
}
favicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
add_test(function test_replaceFaviconData_twiceReplace() {
@ -244,7 +244,7 @@ add_test(function test_replaceFaviconData_twiceReplace() {
function test_replaceFaviconData_twiceReplace_callback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});

View File

@ -89,7 +89,7 @@ add_test(function test_replaceFaviconDataFromDataURL_validHistoryURI() {
pageURI, favicon.mimetype, favicon.data,
function test_replaceFaviconDataFromDataURL_validHistoryURI_callback() {
favicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -114,7 +114,7 @@ add_test(function test_replaceFaviconDataFromDataURL_overrideDefaultFavicon() {
function test_replaceFaviconDataFromDataURL_overrideDefaultFavicon_callback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -142,7 +142,7 @@ add_test(function test_replaceFaviconDataFromDataURL_replaceExisting() {
function test_replaceFaviconDataFromDataURL_replaceExisting_secondCallback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -168,7 +168,7 @@ add_test(function test_replaceFaviconDataFromDataURL_unrelatedReplace() {
function test_replaceFaviconDataFromDataURL_unrelatedReplace_callback() {
favicon.file.remove(false);
unrelatedFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -197,7 +197,7 @@ add_test(function test_replaceFaviconDataFromDataURL_badInputs() {
}
favicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
add_test(function test_replaceFaviconDataFromDataURL_twiceReplace() {
@ -222,7 +222,7 @@ add_test(function test_replaceFaviconDataFromDataURL_twiceReplace() {
function test_replaceFaviconDataFromDataURL_twiceReplace_callback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -251,7 +251,7 @@ add_test(function test_replaceFaviconDataFromDataURL_afterRegularAssign() {
function test_replaceFaviconDataFromDataURL_afterRegularAssign_callback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -280,7 +280,7 @@ add_test(function test_replaceFaviconDataFromDataURL_beforeRegularAssign() {
function test_replaceFaviconDataFromDataURL_beforeRegularAssign_callback() {
firstFavicon.file.remove(false);
secondFavicon.file.remove(false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});

View File

@ -23,22 +23,18 @@ const TITLE_LENGTH_MAX = 4096;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "Services", function() {
Cu.import("resource://gre/modules/Services.jsm");
return Services;
});
XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
Cu.import("resource://gre/modules/NetUtil.jsm");
return NetUtil;
});
XPCOMUtils.defineLazyGetter(this, "FileUtils", function() {
Cu.import("resource://gre/modules/FileUtils.jsm");
return FileUtils;
});
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/commonjs/promise/core.js");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
// This imports various other objects in addition to PlacesUtils.
Cu.import("resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "SMALLPNG_DATA_URI", function() {
return NetUtil.newURI(
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAA" +
@ -375,23 +371,40 @@ function setPageTitle(aURI, aTitle) {
PlacesUtils.history.setPageTitle(aURI, aTitle);
}
/**
* Allows waiting for an observer notification once.
*
* @param aTopic
* Notification topic to observe.
*
* @return {Promise}
* @resolves The array [aSubject, aData] from the observed notification.
* @rejects Never.
*/
function promiseTopicObserved(aTopic)
{
let deferred = Promise.defer();
Services.obs.addObserver(
function PTO_observe(aSubject, aTopic, aData) {
Services.obs.removeObserver(PTO_observe, aTopic);
deferred.resolve([aSubject, aData]);
}, aTopic, false);
return deferred.promise;
}
/**
* Clears history invoking callback when done.
* Clears history asynchronously.
*
* @param aCallback
* Callback function to be called once clear history has finished.
* @return {Promise}
* @resolves When history has been cleared.
* @rejects Never.
*/
function waitForClearHistory(aCallback) {
let observer = {
observe: function(aSubject, aTopic, aData) {
Services.obs.removeObserver(this, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
aCallback();
}
};
Services.obs.addObserver(observer, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
function promiseClearHistory() {
let promise = promiseTopicObserved(PlacesUtils.TOPIC_EXPIRATION_FINISHED);
PlacesUtils.bhistory.removeAllPages();
return promise;
}
@ -516,37 +529,6 @@ function check_JSON_backup() {
return profileBookmarksJSONFile;
}
/**
* Waits for a frecency update then calls back.
*
* @param aURI
* URI or spec of the page we are waiting frecency for.
* @param aValidator
* Validator function for the current frecency. If it returns true we
* have the expected frecency, otherwise we wait for next update.
* @param aCallback
* function invoked when frecency update finishes.
* @param aCbScope
* "this" scope for the callback
* @param aCbArguments
* array of arguments to be passed to the callback
*
* @note since frecency is something that can be changed by a bunch of stuff
* like adding and removing visits, bookmarks we use a polling strategy.
*/
function waitForFrecency(aURI, aValidator, aCallback, aCbScope, aCbArguments) {
Services.obs.addObserver(function (aSubject, aTopic, aData) {
let frecency = frecencyForUrl(aURI);
if (!aValidator(frecency)) {
print("Has to wait for frecency...");
return;
}
Services.obs.removeObserver(arguments.callee, aTopic);
aCallback.apply(aCbScope, aCbArguments);
}, "places-frecency-updated", false);
}
/**
* Returns the frecency of a url.
*
@ -561,12 +543,14 @@ function frecencyForUrl(aURI)
"SELECT frecency FROM moz_places WHERE url = ?1"
);
stmt.bindByIndex(0, url);
if (!stmt.executeStep())
throw new Error("No result for frecency.");
let frecency = stmt.getInt32(0);
stmt.finalize();
return frecency;
try {
if (!stmt.executeStep()) {
throw new Error("No result for frecency.");
}
return stmt.getInt32(0);
} finally {
stmt.finalize();
}
}
/**
@ -611,15 +595,11 @@ function is_time_ordered(before, after) {
}
/**
* Waits for all pending async statements on the default connection, before
* proceeding with aCallback.
* Waits for all pending async statements on the default connection.
*
* @param aCallback
* Function to be called when done.
* @param aScope
* Scope for the callback.
* @param aArguments
* Arguments array for the callback.
* @return {Promise}
* @resolves When all pending async statements finished.
* @rejects Never.
*
* @note The result is achieved by asynchronously executing a query requiring
* a write lock. Since all statements on the same connection are
@ -627,10 +607,10 @@ function is_time_ordered(before, after) {
* complete. Note that WAL makes so that writers don't block readers, but
* this is a problem only across different connections.
*/
function waitForAsyncUpdates(aCallback, aScope, aArguments)
function promiseAsyncUpdates()
{
let scope = aScope || this;
let args = aArguments || [];
let deferred = Promise.defer();
let db = DBConn();
let begin = db.createAsyncStatement("BEGIN EXCLUSIVE");
begin.executeAsync();
@ -638,14 +618,16 @@ function waitForAsyncUpdates(aCallback, aScope, aArguments)
let commit = db.createAsyncStatement("COMMIT");
commit.executeAsync({
handleResult: function() {},
handleError: function() {},
handleResult: function () {},
handleError: function () {},
handleCompletion: function(aReason)
{
aCallback.apply(scope, args);
deferred.resolve();
}
});
commit.finalize();
return deferred.promise;
}
/**

View File

@ -166,7 +166,8 @@ function run_test() {
// updates.
// This is not a problem in real life, but autocomplete tests should
// return reliable resultsets, thus we have to wait.
waitForAsyncUpdates(ensure_results, this, [searchString, expectedValue]);
promiseAsyncUpdates().then(function () ensure_results(searchString,
expectedValue));
})
}, this);
@ -180,7 +181,7 @@ function add_autocomplete_test(aTestData) {
function waitForCleanup(aCallback) {
remove_all_bookmarks();
waitForClearHistory(aCallback);
promiseClearHistory().then(aCallback);
}
function addBookmark(aBookmarkObj) {

View File

@ -282,7 +282,7 @@ function run_test() {
add_visits_to_database();
// Frecency and hidden are updated asynchronously, wait for them.
waitForAsyncUpdates(continue_test);
promiseAsyncUpdates().then(continue_test);
}
function continue_test() {
@ -300,5 +300,5 @@ function run_test() {
check_results_callback);
remove_all_bookmarks();
waitForClearHistory(do_test_finished);
promiseClearHistory().then(do_test_finished);
}

View File

@ -1272,13 +1272,13 @@ function runNextTest() {
if (tests.length) {
let test = tests.shift();
test.setup();
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
test.check();
// sorting reversed, usually SORT_BY have ASC and DESC
test.check_reverse();
// Execute cleanup tasks
remove_all_bookmarks();
waitForClearHistory(runNextTest);
promiseClearHistory().then(runNextTest);
});
}
else {

View File

@ -602,7 +602,7 @@ function addVisit(aURI) {
*/
function cleanDatabase(aCallback) {
remove_all_bookmarks();
waitForClearHistory(aCallback);
promiseClearHistory().then(aCallback);
}
/**

View File

@ -209,7 +209,7 @@ AutoCompleteInput.prototype = {
function run_test() {
do_test_pending();
waitForAsyncUpdates(continue_test);
promiseAsyncUpdates().then(continue_test);
}
function continue_test() {

View File

@ -55,7 +55,7 @@ function run_test() {
// get charset from bookmarked page
do_check_eq(histsvc.getCharsetForURI(TEST_BOOKMARKED_URI), charset);
waitForClearHistory(continue_test);
promiseClearHistory().then(continue_test);
do_test_pending();
}

View File

@ -60,7 +60,7 @@ function run_test() {
// 2. run the test-suite
validate();
waitForAsyncUpdates(function testJsonExport() {
promiseAsyncUpdates().then(function testJsonExport() {
// Test exporting a Places canonical json file.
// 1. export to bookmarks.exported.json
try {
@ -79,7 +79,7 @@ function run_test() {
validate();
LOG("validated import");
waitForAsyncUpdates(do_test_finished);
promiseAsyncUpdates().then(do_test_finished);
});
}
}

View File

@ -21,20 +21,20 @@ add_test(function changeuri_unvisited_bookmark()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
PlacesUtils.bookmarks.changeBookmarkURI(id, uri("http://example.com/2"));
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Unvisited URI no longer bookmarked => frecency should = 0");
do_check_eq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -48,23 +48,23 @@ add_test(function changeuri_visited_bookmark()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
visit(TEST_URI);
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
PlacesUtils.bookmarks.changeBookmarkURI(id, uri("http://example.com/2"));
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("*Visited* URI no longer bookmarked => frecency should != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -84,19 +84,19 @@ add_test(function changeuri_bookmark_still_bookmarked()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark 2 title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
PlacesUtils.bookmarks.changeBookmarkURI(id1, uri("http://example.com/2"));
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("URI still bookmarked => frecency should != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -130,7 +130,7 @@ add_test(function changeuri_nonexistent_bookmark()
tryChange(id);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
///////////////////////////////////////////////////////////////////////////////

View File

@ -40,7 +40,7 @@ add_test(function test_keywordRemovedOnUniqueItemRemoval() {
// remove bookmark
bmsvc.removeItem(bookmarkId);
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
// Check that keyword has been removed from the database.
// The removal is asynchronous.
var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1";
@ -77,7 +77,7 @@ add_test(function test_keywordNotRemovedOnNonUniqueItemRemoval() {
// remove first bookmark
bmsvc.removeItem(bookmarkId1);
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
// check that keyword is still there
var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1";
var stmt = mDBConn.createStatement(sql);

View File

@ -363,7 +363,7 @@ function next_test() {
observer.runCount = -1;
let test = tests.shift();
waitForClearHistory(test);
promiseClearHistory().then(test);
}
else {
Services.obs.removeObserver(observer, PlacesUtils.TOPIC_FEEDBACK_UPDATED);

View File

@ -95,7 +95,7 @@ function run_next_test() {
}
let test = tests.shift();
waitForClearHistory(function() {
promiseClearHistory().then(function() {
remove_all_bookmarks();
do_execute_soon(test);
});

View File

@ -438,7 +438,7 @@ function test_non_addable_uri_errors()
// If we have had all of our callbacks, continue running tests.
if (++callbackCount == places.length) {
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}
}));
}
@ -471,7 +471,7 @@ function test_duplicate_guid_errors()
do_check_eq(aResultCode, Cr.NS_ERROR_STORAGE_CONSTRAINT);
do_check_false(gGlobalHistory.isVisited(badPlace.uri));
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}));
}
@ -507,7 +507,7 @@ function test_invalid_referrerURI_ignored()
do_check_eq(stmt.row.from_visit, 0);
stmt.finalize();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}
@ -538,7 +538,7 @@ function test_nonnsIURI_referrerURI_ignored()
do_check_eq(stmt.row.from_visit, 0);
stmt.finalize();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}
@ -573,7 +573,7 @@ function test_invalid_sessionId_ignored()
do_check_neq(stmt.row.session, place.visits[0].sessionId);
stmt.finalize();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}
@ -621,7 +621,7 @@ function test_unstored_sessionId_ignored()
do_check_eq(maxSessionId + 1, newMaxSessionId);
stmt.finalize();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}
@ -675,7 +675,7 @@ function test_old_referrer_ignored()
do_check_eq(stmt.row.count, 1);
stmt.finalize();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}));
}
@ -710,7 +710,7 @@ function test_place_id_ignored()
do_check_neq(aPlaceInfo.placeId, placeId);
do_check_true(gGlobalHistory.isVisited(badPlace.uri));
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
},
handleError: function handleError(aResultCode) {
do_throw("Unexpected error: " + aResultCode);
@ -758,7 +758,7 @@ function test_handleCompletion_called_when_complete()
handleCompletion: function handleCompletion() {
do_check_eq(callbackCountSuccess, EXPECTED_COUNT_SUCCESS);
do_check_eq(callbackCountFailure, EXPECTED_COUNT_FAILURE);
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
},
});
}
@ -820,7 +820,7 @@ function test_add_visit()
// If we have had all of our callbacks, continue running tests.
if (++callbackCount == place.visits.length) {
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}
}));
}
@ -915,7 +915,7 @@ function test_properties_saved()
// If we have had all of our callbacks, continue running tests.
if (++callbackCount == places.length) {
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}
}));
}
@ -937,7 +937,7 @@ function test_guid_saved()
do_check_true(gGlobalHistory.isVisited(uri));
do_check_eq(aPlaceInfo.guid, place.guid);
do_check_guid_for_uri(uri, place.guid);
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}
@ -991,7 +991,7 @@ function test_referrer_saved()
do_check_eq(stmt.row.count, 1);
stmt.finalize();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}
@ -1025,7 +1025,7 @@ function test_sessionId_saved()
do_check_eq(stmt.row.count, 1);
stmt.finalize();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}
@ -1048,7 +1048,7 @@ function test_guid_change_saved()
gHistory.updatePlaces(place, expectHandleResult(function(aPlaceInfo) {
do_check_guid_for_uri(place.uri, place.guid);
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}));
}
@ -1085,7 +1085,7 @@ function test_title_change_saved()
gHistory.updatePlaces(place, expectHandleResult(function(aPlaceInfo) {
do_check_title_for_uri(place.uri, place.title);
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}));
}));
@ -1112,7 +1112,7 @@ function test_no_title_does_not_clear_title()
gHistory.updatePlaces(place, expectHandleResult(function(aPlaceInfo) {
do_check_title_for_uri(place.uri, TITLE);
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}));
}
@ -1155,7 +1155,7 @@ function test_title_change_notifies()
case 2:
PlacesUtils.history.removeObserver(silentObserver);
PlacesUtils.history.removeObserver(observer);
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
};
});
PlacesUtils.history.addObserver(observer, false);
@ -1178,7 +1178,7 @@ function test_visit_notifies()
let callbackCount = 0;
let finisher = function() {
if (++callbackCount == 2) {
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}
}
let visitObserver = new VisitObserver(place.uri, place.guid,
@ -1238,7 +1238,7 @@ function test_referrer_sessionId_persists()
do_check_eq(aPlaceInfo.visits[0].sessionId, sessionId);
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}));
}));
}
@ -1271,7 +1271,7 @@ function test_callbacks_not_supplied()
});
gHistory.updatePlaces(places, {});
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
}
////////////////////////////////////////////////////////////////////////////////
@ -1286,8 +1286,8 @@ function test_callbacks_not_supplied()
test_add_visit_no_date_throws,
test_add_visit_no_transitionType_throws,
test_add_visit_invalid_transitionType_throws,
// Note: all asynchronous tests (every test below this point) should
// waitForAsyncUpdates before calling run_next_test.
// Note: all asynchronous tests (every test below this point) should wait for
// async updates before calling run_next_test.
test_non_addable_uri_errors,
test_duplicate_guid_errors,
test_invalid_referrerURI_ignored,

View File

@ -108,7 +108,7 @@ add_test(function setup() {
try {
BookmarkHTMLUtils.importFromFile(gBookmarksFileOld, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
testImportedBookmarks();
// Prepare for next tests.
@ -116,7 +116,7 @@ add_test(function setup() {
exporter.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
remove_all_bookmarks();
run_next_test();
});
@ -137,10 +137,10 @@ add_test(function test_import_new()
try {
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
testImportedBookmarks();
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
remove_all_bookmarks();
run_next_test();
});
@ -184,7 +184,7 @@ add_test(function test_emptytitle_export()
try {
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
testImportedBookmarks();
// Cleanup.
@ -195,7 +195,7 @@ add_test(function test_emptytitle_export()
exporter.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
remove_all_bookmarks();
run_next_test();
});
@ -268,7 +268,7 @@ add_test(function test_import_chromefavicon()
if (!success) {
do_throw("couldn't import the exported file.");
}
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
testImportedBookmarks();
// Cleanup.
@ -279,7 +279,7 @@ add_test(function test_import_chromefavicon()
exporter.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
remove_all_bookmarks();
run_next_test();
});
@ -312,10 +312,10 @@ add_test(function test_import_ontop()
try {
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
testImportedBookmarks();
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
remove_all_bookmarks();
run_next_test();
});

View File

@ -62,7 +62,7 @@ add_test(function test_removePages()
// Cleanup.
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});

View File

@ -76,7 +76,7 @@ add_test(function test_dh_is_from_places()
// Test that this nsIDownloadHistory is the one places implements.
do_check_true(gDownloadHistory instanceof Ci.mozIAsyncHistory);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
add_test(function test_dh_addDownload()
@ -87,7 +87,7 @@ add_test(function test_dh_addDownload()
// Verify that the URI is already available in results at this time.
uri_in_db(DOWNLOAD_URI, true);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
gDownloadHistory.addDownload(DOWNLOAD_URI, null, Date.now() * 1000);
@ -107,7 +107,7 @@ add_test(function test_dh_addDownload_referrer()
// Verify that the URI is already available in results at this time.
uri_in_db(DOWNLOAD_URI, true);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
gDownloadHistory.addDownload(DOWNLOAD_URI, REFERRER_URI, Date.now() * 1000);
@ -142,7 +142,7 @@ add_test(function test_dh_addDownload_privateBrowsing()
uri_in_db(DOWNLOAD_URI, true);
uri_in_db(PRIVATE_URI, false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
let pb = Cc["@mozilla.org/privatebrowsing;1"]
@ -171,7 +171,7 @@ add_test(function test_dh_addDownload_disabledHistory()
uri_in_db(DOWNLOAD_URI, true);
uri_in_db(PRIVATE_URI, false);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
Services.prefs.setBoolPref("places.history.enabled", false);
@ -207,7 +207,7 @@ add_test(function test_dh_details()
PlacesUtils.annotations.removeObserver(annoObserver);
PlacesUtils.history.removeObserver(historyObserver);
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
}
};

View File

@ -73,7 +73,8 @@ AutoCompleteInput.prototype = {
function ensure_results(uris, searchTerm)
{
waitForAsyncUpdates(ensure_results_internal, this, arguments);
promiseAsyncUpdates().then(function () ensure_results_internal(uris,
searchTerm));
}
function ensure_results_internal(uris, searchTerm)
@ -277,7 +278,7 @@ function next_test() {
if (tests.length) {
remove_all_bookmarks();
let test = tests.shift();
waitForClearHistory(test);
promiseClearHistory().then(test);
}
else
do_test_finished();

View File

@ -26,7 +26,7 @@ let historyObserver = {
{
Services.obs.removeObserver(observeExpiration, aTopic, false);
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
// Check that frecency for not cleared items (bookmarks) has been converted
// to -MAX(visit_count, 1), so we will be able to recalculate frecency
// starting from most frecent bookmarks.
@ -160,8 +160,5 @@ function continue_test() {
PlacesUtils.history.addVisit(uri("http://frecency.mozilla.org/"), Date.now(),
null, Ci.nsINavHistoryService.TRANSITION_LINK,
false, 0);
waitForFrecency("http://frecency.mozilla.org/", function (aFrecency) aFrecency > 0,
function () {
PlacesUtils.bhistory.removeAllPages();
}, this, []);
promiseAsyncUpdates().then(function () PlacesUtils.bhistory.removeAllPages());
}

View File

@ -110,7 +110,7 @@ function test_remove_places()
PlacesUtils.history.removePage(urls[idx].uri);
}
waitForClearHistory(function (){
promiseClearHistory().then(function (){
for (let idx in urls) {
do_check_false(isHostInMozHosts(urls[idx].uri, urls[idx].typed, urls[idx].prefix));
}
@ -132,7 +132,7 @@ function test_bookmark_changes()
// Change the hostname
PlacesUtils.bookmarks.changeBookmarkURI(itemId, NetUtil.newURI(NEW_URL));
waitForClearHistory(function (){
promiseClearHistory().then(function (){
let newUri = NetUtil.newURI(NEW_URL);
do_check_true(isHostInMozPlaces(newUri));
do_check_true(isHostInMozHosts(newUri, false, null));
@ -147,7 +147,7 @@ function test_bookmark_removal()
PlacesUtils.bookmarks.DEFAULT_INDEX);
let newUri = NetUtil.newURI(NEW_URL);
PlacesUtils.bookmarks.removeItem(itemId);
waitForClearHistory(function (){
promiseClearHistory().then(function (){
do_check_false(isHostInMozHosts(newUri, false, null));
run_next_test();
});
@ -198,7 +198,7 @@ function test_moz_hosts_www_remove()
PlacesUtils.history.removePage(aURIToRemove);
let prefix = /www/.test(aURIToKeep.spec) ? "www." : null;
do_check_true(isHostInMozHosts(aURIToKeep, false, prefix));
waitForClearHistory(aCallback);
promiseClearHistory().then(aCallback);
}
});
}
@ -207,7 +207,7 @@ function test_moz_hosts_www_remove()
const TEST_WWW_URI = NetUtil.newURI("http://www.rem.mozilla.com");
test_removal(TEST_URI, TEST_WWW_URI, function() {
test_removal(TEST_WWW_URI, TEST_URI, function() {
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
}

View File

@ -70,7 +70,7 @@ function step()
let checker = SCHEMES[scheme] ? do_check_true : do_check_false;
checker(aIsVisited);
waitForClearHistory(function () {
promiseClearHistory().then(function () {
history.isURIVisited(uri, function(aURI, aIsVisited) {
do_check_true(uri.equals(aURI));
do_check_false(aIsVisited);

View File

@ -173,7 +173,7 @@ add_test(function check_history_query() {
do_check_eq(resultObserver.closedContainer, resultObserver.openedContainer);
result.removeObserver(resultObserver);
resultObserver.reset();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
});
});
@ -243,7 +243,7 @@ add_test(function check_bookmarks_query() {
do_check_eq(resultObserver.closedContainer, resultObserver.openedContainer);
result.removeObserver(resultObserver);
resultObserver.reset();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
});
add_test(function check_mixed_query() {
@ -278,5 +278,5 @@ add_test(function check_mixed_query() {
do_check_eq(resultObserver.closedContainer, resultObserver.openedContainer);
result.removeObserver(resultObserver);
resultObserver.reset();
waitForAsyncUpdates(run_next_test);
promiseAsyncUpdates().then(run_next_test);
});

View File

@ -26,7 +26,7 @@ var gTests = [
false,
0);
}
waitForAsyncUpdates(this.continue_run, this);
promiseAsyncUpdates().then(this.continue_run, this);
},
continue_run: function () {
print("Remove visits using timerange outside the URI's visits.");
@ -54,7 +54,7 @@ var gTests = [
do_check_true(histsvc.QueryInterface(Ci.nsIGlobalHistory2).
isVisited(TEST_URI));
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
print("Frecency should be positive.")
do_check_true(frecencyForUrl(TEST_URI) > 0);
run_next_test();
@ -81,7 +81,7 @@ var gTests = [
bmsvc.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(this.continue_run, this);
promiseAsyncUpdates().then(this.continue_run.bind(this));
},
continue_run: function () {
print("Remove visits using timerange outside the URI's visits.");
@ -109,7 +109,7 @@ var gTests = [
do_check_true(histsvc.QueryInterface(Ci.nsIGlobalHistory2).
isVisited(TEST_URI));
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
print("Frecency should be positive.")
do_check_true(frecencyForUrl(TEST_URI) > 0);
run_next_test();
@ -129,7 +129,7 @@ var gTests = [
false,
0);
}
waitForAsyncUpdates(this.continue_run, this);
promiseAsyncUpdates().then(this.continue_run.bind(this));
},
continue_run: function () {
print("Remove the 5 most recent visits.");
@ -158,7 +158,7 @@ var gTests = [
do_check_true(histsvc.QueryInterface(Ci.nsIGlobalHistory2).
isVisited(TEST_URI));
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
print("Frecency should be positive.")
do_check_true(frecencyForUrl(TEST_URI) > 0);
run_next_test();
@ -184,7 +184,7 @@ var gTests = [
TEST_URI,
bmsvc.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(this.continue_run, this);
promiseAsyncUpdates().then(this.continue_run.bind(this));
},
continue_run: function () {
print("Remove the 5 most recent visits.");
@ -213,7 +213,7 @@ var gTests = [
do_check_true(histsvc.QueryInterface(Ci.nsIGlobalHistory2).
isVisited(TEST_URI));
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
print("Frecency should be positive.")
do_check_true(frecencyForUrl(TEST_URI) > 0);
run_next_test();
@ -233,7 +233,7 @@ var gTests = [
false,
0);
}
waitForAsyncUpdates(this.continue_run, this);
promiseAsyncUpdates().then(this.continue_run.bind(this));
},
continue_run: function () {
print("Remove all visits.");
@ -272,7 +272,7 @@ var gTests = [
false,
0);
}
waitForAsyncUpdates(this.continue_run, this);
promiseAsyncUpdates().then(this.continue_run.bind(this));
},
continue_run: function () {
print("Remove all visits.");
@ -296,7 +296,7 @@ var gTests = [
do_check_false(histsvc.QueryInterface(Ci.nsIGlobalHistory2).
isVisited(PLACE_URI));
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
print("Frecency should be zero.")
do_check_eq(frecencyForUrl(PLACE_URL), 0);
run_next_test();
@ -322,7 +322,7 @@ var gTests = [
TEST_URI,
bmsvc.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(this.continue_run, this);
promiseAsyncUpdates().then(this.continue_run.bind(this));
},
continue_run: function () {
print("Remove all visits.");
@ -349,7 +349,7 @@ var gTests = [
print("nsINavBookmarksService.isBookmarked should return true.");
do_check_true(bmsvc.isBookmarked(TEST_URI));
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
print("Frecency should be negative.")
do_check_true(frecencyForUrl(TEST_URI) < 0);
run_next_test();
@ -372,7 +372,7 @@ var gTests = [
histsvc.QueryInterface(Ci.nsIBrowserHistory).
removeVisitsByTimeframe(NOW - 10, NOW);
waitForAsyncUpdates(function() {
promiseAsyncUpdates().then(function() {
do_log_info("URI should still exist in moz_places.");
do_check_true(page_in_database(TEST_URL));
do_log_info("Frecency should be zero.")
@ -395,7 +395,7 @@ function run_next_test() {
if (gTests.length) {
let test = gTests.shift();
print("\n ***Test: " + test.desc);
waitForClearHistory(function() {
promiseClearHistory().then(function() {
remove_all_bookmarks();
DBConn().executeSimpleSQL("DELETE FROM moz_places");
test.run.call(test);

View File

@ -121,7 +121,7 @@ function run_test() {
// Add a visit, then check frecency ordering.
add_visit(NetUtil.newURI("http://foo.tld/b"));
waitForAsyncUpdates(function () {
promiseAsyncUpdates().then(function () {
result.sortingMode = NHQO.SORT_BY_FRECENCY_DESCENDING;
checkOrder(id2, id3, id1);
result.sortingMode = NHQO.SORT_BY_FRECENCY_ASCENDING;

View File

@ -60,7 +60,7 @@ function run_test() {
.getService(Ci.nsIObserver)
.observe(null, "gather-telemetry", null);
waitForAsyncUpdates(continue_test);
promiseAsyncUpdates().then(continue_test);
}
function continue_test() {

View File

@ -21,20 +21,20 @@ add_test(function removed_bookmark()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
PlacesUtils.bookmarks.removeItem(id);
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Unvisited URI no longer bookmarked => frecency should = 0");
do_check_eq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -48,7 +48,7 @@ add_test(function removed_but_visited_bookmark()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
@ -56,13 +56,13 @@ add_test(function removed_but_visited_bookmark()
visit(TEST_URI);
PlacesUtils.bookmarks.removeItem(id);
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("*Visited* URI no longer bookmarked => frecency should != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -80,20 +80,20 @@ add_test(function remove_bookmark_still_bookmarked()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark 2 title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
PlacesUtils.bookmarks.removeItem(id1);
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("URI still bookmarked => frecency should != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -107,7 +107,7 @@ add_test(function cleared_parent_of_visited_bookmark()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
@ -115,13 +115,13 @@ add_test(function cleared_parent_of_visited_bookmark()
visit(TEST_URI);
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("*Visited* URI no longer bookmarked => frecency should != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});
@ -141,20 +141,20 @@ add_test(function cleared_parent_of_bookmark_still_bookmarked()
TEST_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"bookmark 2 title");
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
do_log_info("Bookmarked => frecency of URI should be != 0");
do_check_neq(frecencyForUrl(TEST_URI), 0);
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
waitForAsyncUpdates(function ()
promiseAsyncUpdates().then(function ()
{
// URI still bookmarked => frecency should != 0.
do_check_neq(frecencyForUrl(TEST_URI), 0);
remove_all_bookmarks();
waitForClearHistory(run_next_test);
promiseClearHistory().then(run_next_test);
});
});
});