--- a/suite/common/places/nsPlacesAutoComplete.js
+++ b/suite/common/places/nsPlacesAutoComplete.js
@@ -7,18 +7,16 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
"resource://gre/modules/TelemetryStopwatch.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Task",
- "resource://gre/modules/Task.jsm");
////////////////////////////////////////////////////////////////////////////////
//// Constants
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
--- a/suite/common/places/tests/autocomplete/head_autocomplete.js
+++ b/suite/common/places/tests/autocomplete/head_autocomplete.js
@@ -193,31 +193,31 @@ var gNextTestSetupTasks = [];
* If true, no visit is added for the URI. If false or undefined, a
* visit is added.
*/
function addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aNoVisit)
{
gNextTestSetupTasks.push([task_addPageBook, arguments]);
}
-function* task_addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aNoVisit)
+async function task_addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aNoVisit)
{
// Add a page entry for the current uri
gPages[aURI] = [aURI, aBook != undefined ? aBook : aTitle, aTags];
let uri = toURI(kURIs[aURI]);
let title = kTitles[aTitle];
let out = [aURI, aTitle, aBook, aTags, aKey];
out.push("\nuri=" + kURIs[aURI]);
out.push("\ntitle=" + title);
// Add the page and a visit if we need to
if (!aNoVisit) {
- yield PlacesTestUtils.addVisits({
+ await PlacesTestUtils.addVisits({
uri: uri,
transition: aTransitionType || TRANSITION_LINK,
visitDate: gDate,
title: title
});
out.push("\nwith visit");
}
@@ -225,17 +225,17 @@ function* task_addPageBook(aURI, aTitle,
if (aBook != undefined) {
let book = kTitles[aBook];
let bmid = bmsvc.insertBookmark(bmsvc.unfiledBookmarksFolder, uri,
bmsvc.DEFAULT_INDEX, book);
out.push("\nbook=" + book);
// Add a keyword to the bookmark if we need to
if (aKey != undefined)
- yield PlacesUtils.keywords.insert({url: uri.spec, keyword: aKey});
+ await PlacesUtils.keywords.insert({url: uri.spec, keyword: aKey});
// Add tags if we need to
if (aTags != undefined && aTags.length > 0) {
// Convert each tag index into the title
let tags = aTags.map(aTag => kTitles[aTag]);
tagsvc.tagURI(uri, tags);
out.push("\ntags=" + tags);
}
@@ -261,31 +261,31 @@ function run_test() {
// By default assume we want to match tags
appendTags = true;
// Do an extra function if necessary
if (func)
func();
- Task.spawn(function* () {
+ (async function() {
// Iterate over all tasks and execute them
for (let [fn, args] of gNextTestSetupTasks) {
- yield fn.apply(this, args);
+ await fn.apply(this, args);
}
// Clean up to allow tests to register more functions.
gNextTestSetupTasks = [];
// 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.
- yield PlacesTestUtils.promiseAsyncUpdates();
+ await PlacesTestUtils.promiseAsyncUpdates();
- }).then(() => ensure_results(search, expected),
+ })().then(() => ensure_results(search, expected),
do_report_unexpected_exception);
}
// Utility function to remove history pages
function removePages(aURIs)
{
gNextTestSetupTasks.push([do_removePages, arguments]);
}
@@ -297,18 +297,18 @@ function do_removePages(aURIs)
}
// Utility function to mark pages as typed
function markTyped(aURIs, aTitle)
{
gNextTestSetupTasks.push([task_markTyped, arguments]);
}
-function* task_markTyped(aURIs, aTitle)
+async function task_markTyped(aURIs, aTitle)
{
for (let uri of aURIs) {
- yield PlacesTestUtils.addVisits({
+ await PlacesTestUtils.addVisits({
uri: toURI(kURIs[uri]),
transition: TRANSITION_TYPED,
title: kTitles[aTitle]
});
}
}
--- a/suite/common/places/tests/autocomplete/test_autocomplete_on_value_removed_479089.js
+++ b/suite/common/places/tests/autocomplete/test_autocomplete_on_value_removed_479089.js
@@ -15,25 +15,25 @@
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
function run_test()
{
run_next_test();
}
-add_task(function* test_autocomplete_on_value_removed()
+add_task(async function test_autocomplete_on_value_removed()
{
// QI to nsIAutoCompleteSimpleResultListener
var listener = Cc["@mozilla.org/autocomplete/search;1?name=history"].
getService(Components.interfaces.nsIAutoCompleteSimpleResultListener);
// add history visit
var testUri = uri("http://foo.mozilla.com/");
- yield PlacesTestUtils.addVisits({
+ await PlacesTestUtils.addVisits({
uri: testUri,
referrer: uri("http://mozilla.com/")
});
// create a query object
var query = histsvc.getNewQuery();
// create the options object we will never use
var options = histsvc.getNewQueryOptions();
// look for this uri only
--- a/suite/common/places/tests/autocomplete/test_enabled.js
+++ b/suite/common/places/tests/autocomplete/test_enabled.js
@@ -27,17 +27,17 @@ var gTests = [
["3: resume normal search",
"url", [0], () => setSearch(1)],
];
function setSearch(aSearch) {
prefs.setBoolPref("browser.urlbar.autocomplete.enabled", !!aSearch);
}
-add_task(function* test_sync_enabled() {
+add_task(async function test_sync_enabled() {
// Initialize autocomplete component.
Cc["@mozilla.org/autocomplete/search;1?name=history"]
.getService(Ci.mozIPlacesAutoComplete);
let types = [ "history", "bookmark", "openpage" ];
// Test the service keeps browser.urlbar.autocomplete.enabled synchronized
// with browser.urlbar.suggest prefs.
--- a/suite/common/places/tests/head_common.js
+++ b/suite/common/places/tests/head_common.js
@@ -28,18 +28,16 @@ Cu.import("resource://gre/modules/XPCOMU
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/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Task",
- "resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkJSONUtils",
"resource://gre/modules/BookmarkJSONUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkHTMLUtils",
"resource://gre/modules/BookmarkHTMLUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesBackups",
"resource://gre/modules/PlacesBackups.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
"resource://testing-common/PlacesTestUtils.jsm");
@@ -853,18 +851,18 @@ function checkBookmarkObject(info) {
Assert.ok(info.lastModified.constructor.name == "Date", "lastModified should be a Date");
Assert.ok(info.lastModified >= info.dateAdded, "lastModified should never be smaller than dateAdded");
Assert.ok(typeof info.type == "number", "type should be a number");
}
/**
* Reads foreign_count value for a given url.
*/
-function* foreign_count(url) {
+async function foreign_count(url) {
if (url instanceof Ci.nsIURI)
url = url.spec;
- let db = yield PlacesUtils.promiseDBConnection();
- let rows = yield db.executeCached(
+ let db = await PlacesUtils.promiseDBConnection();
+ let rows = await db.executeCached(
`SELECT foreign_count FROM moz_places
WHERE url_hash = hash(:url) AND url = :url
`, { url });
return rows.length == 0 ? 0 : rows[0].getResultByName("foreign_count");
}
--- a/suite/common/places/tests/unit/test_clearHistory_shutdown.js
+++ b/suite/common/places/tests/unit/test_clearHistory_shutdown.js
@@ -71,17 +71,17 @@ var notificationsObserver = {
}
var timeInMicroseconds = Date.now() * 1000;
function run_test() {
run_next_test();
}
-add_task(function test_execute() {
+add_task(async function test_execute() {
do_test_pending();
print("Initialize suiteglue before Places");
// Avoid default bookmarks import.
Cc["@mozilla.org/suite/suiteglue;1"].getService(Ci.nsIObserver)
.observe(null, "initial-migration", null);
Services.prefs.setBoolPref("privacy.item.history", true);
@@ -96,17 +96,17 @@ add_task(function test_execute() {
Services.prefs.setBoolPref("privacy.sanitize.sanitizeOnShutdown", true);
// Unlike Firefox, SeaMonkey still supports the confirmation dialog
// which is called from Sanitizer's init method checkSettings().
Services.prefs.setBoolPref("privacy.sanitize.promptOnSanitize", false);
print("Add visits.");
for (let aUrl of URIS) {
- yield promiseAddVisits({uri: uri(aUrl), visitDate: timeInMicroseconds++,
+ await promiseAddVisits({uri: uri(aUrl), visitDate: timeInMicroseconds++,
transition: PlacesUtils.history.TRANSITION_TYPED})
}
print("Add cache.");
storeCache(URL, "testData");
});
function run_test_continue()
{
--- a/suite/common/search/engineManager.js
+++ b/suite/common/search/engineManager.js
@@ -2,18 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Task",
- "resource://gre/modules/Task.jsm");
const Ci = Components.interfaces;
const Cc = Components.classes;
const ENGINE_FLAVOR = "text/x-moz-search-engine";
const BROWSER_SUGGEST_PREF = "browser.search.suggest.enabled";
var gEngineView = null;
@@ -116,24 +114,24 @@ var gEngineManagerDialog = {
if (index == -1)
return;
let tree = document.getElementById("engineList");
let column = tree.columns.getColumnFor(document.getElementById("engineKeyword"));
tree.startEditing(index, column);
},
- editKeyword: Task.async(function* (aEngine, aNewKeyword) {
+ async editKeyword(aEngine, aNewKeyword) {
let keyword = aNewKeyword.trim();
if (keyword) {
let eduplicate = false;
let dupName = "";
// Check for duplicates in Places keywords.
- let bduplicate = !!(yield PlacesUtils.keywords.fetch(keyword));
+ let bduplicate = !!(await PlacesUtils.keywords.fetch(keyword));
// Check for duplicates in changes we haven't committed yet
let engines = gEngineView._engineStore.engines;
for (let engine of engines) {
if (engine.alias == keyword &&
engine.name != aEngine.name) {
eduplicate = true;
dupName = engine.name;
@@ -151,17 +149,17 @@ var gEngineManagerDialog = {
Services.prompt.alert(window, dtitle, eduplicate ? emsg : bmsg);
return false;
}
}
gEngineView._engineStore.changeEngine(aEngine, "alias", keyword);
gEngineView.invalidate();
return true;
- }),
+ },
onSelect: function engineManager_onSelect() {
// Buttons only work if an engine is selected and it's not the last engine,
// the latter is true when the selected is first and last at the same time.
var lastSelected = (gEngineView.selectedIndex == gEngineView.lastIndex);
var firstSelected = (gEngineView.selectedIndex == 0);
var noSelection = (gEngineView.selectedIndex == -1);
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -28,18 +28,16 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/AutoCompletePopup.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkHTMLUtils",
"resource://gre/modules/BookmarkHTMLUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkJSONUtils",
"resource://gre/modules/BookmarkJSONUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Task",
- "resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyGetter(this, "DebuggerServer", () => {
var tmp = {};
Components.utils.import("resource://devtools/shared/Loader.jsm", tmp);
return tmp.require("devtools/server/main").DebuggerServer;
});
// We try to backup bookmarks at idle times, to avoid doing that at shutdown.
@@ -913,21 +911,21 @@ SuiteGlue.prototype = {
* - browser.places.smartBookmarksVersion
* Set during HTML import to indicate that Smart Bookmarks were created.
* Set to -1 to disable Smart Bookmarks creation.
* Set to 0 to restore current Smart Bookmarks.
* - browser.bookmarks.restore_default_bookmarks
* Set to true by safe-mode dialog to indicate we must restore default
* bookmarks.
*/
- _initPlaces: Task.async(function(aInitialMigrationPerformed) {
+ async _initPlaces(aInitialMigrationPerformed) {
// We must instantiate the history service since it will tell us if we
// need to import or restore bookmarks due to first-run, corruption or
// forced migration (due to a major schema change).
- var bookmarksBackupFile = yield PlacesBackups.getMostRecentBackup();
+ var bookmarksBackupFile = await PlacesBackups.getMostRecentBackup();
// If the database is corrupt or has been newly created we should
// import bookmarks. Same if we don't have any JSON backups, which
// probably means that we never have used bookmarks in places yet.
var dbStatus = PlacesUtils.history.databaseStatus;
var importBookmarks = !aInitialMigrationPerformed &&
(dbStatus == PlacesUtils.history.DATABASE_STATUS_CREATE ||
dbStatus == PlacesUtils.history.DATABASE_STATUS_CORRUPT ||
@@ -956,17 +954,17 @@ SuiteGlue.prototype = {
} catch(ex) {}
// If the user did not require to restore default bookmarks, or import
// from bookmarks.html, we will try to restore from JSON.
if (importBookmarks && !restoreDefaultBookmarks && !importBookmarksHTML) {
// Get latest JSON backup.
if (bookmarksBackupFile) {
// Restore from JSON backup.
- yield BookmarkJSONUtils.importFromFile(bookmarksBackupFile, true);
+ await BookmarkJSONUtils.importFromFile(bookmarksBackupFile, true);
importBookmarks = false;
}
else if (dbStatus == PlacesUtils.history.DATABASE_STATUS_OK) {
importBookmarks = false;
}
else {
// We have created a new database but we don't have any backup available.
importBookmarks = true;
@@ -1047,17 +1045,17 @@ SuiteGlue.prototype = {
}
// Initialize bookmark archiving on idle.
// Once a day, either on idle or shutdown, bookmarks are backed up.
if (!this._isIdleObserver) {
this._idleService.addIdleObserver(this, BOOKMARKS_BACKUP_IDLE_TIME);
this._isIdleObserver = true;
}
- }),
+ },
/**
* Places shut-down tasks
* - back up bookmarks if needed.
* - export bookmarks as HTML, if so configured.
* - finalize components depending on Places.
*/
_onPlacesShutdown: function() {
--- a/suite/common/tests/browser/browser_637020.js
+++ b/suite/common/tests/browser/browser_637020.js
@@ -27,38 +27,38 @@ function test() {
* as dirty, otherwise _getCurrentState() might ignore them when collecting
* state for the first time and we'd just save them as empty objects.
*
* The dirty state acts as a cache to not collect data from all windows all the
* time, so at the beginning, each window must be dirty so that we collect
* their state at least once.
*/
-function runTests() {
+async function runTests() {
let win;
// Wait until the new window has been opened.
Services.obs.addObserver(function onOpened(subject) {
Services.obs.removeObserver(onOpened, "domwindowopened");
win = subject;
executeSoon(next);
}, "domwindowopened", false);
// Set the new browser state that will
// restore a window with two slowly loading tabs.
- yield SessionStore.setBrowserState(JSON.stringify(TEST_STATE));
+ await SessionStore.setBrowserState(JSON.stringify(TEST_STATE));
// The window has now been opened. Check the state that is returned,
// this should come from the cache while the window isn't restored, yet.
info("the window has been opened");
checkWindows();
// The history has now been restored and the tabs are loading. The data must
// now come from the window, if it's correctly been marked as dirty before.
- yield whenDelayedStartupFinished(win, next);
+ await whenDelayedStartupFinished(win, next);
info("the delayed startup has finished");
checkWindows();
}
function checkWindows() {
let state = JSON.parse(SessionStore.getBrowserState());
is(state.windows[0].tabs.length, 2, "first window has two tabs");
is(state.windows[1].tabs.length, 2, "second window has two tabs");
--- a/suite/modules/test/unit/test_browser_sanitizer.js
+++ b/suite/modules/test/unit/test_browser_sanitizer.js
@@ -1,52 +1,52 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource:///modules/Sanitizer.jsm", this);
XPCOMUtils.defineLazyModuleGetter(this, "FormHistory",
"resource://gre/modules/FormHistory.jsm");
var sanTests = {
cache: {
desc: "Cache",
- setup: function() {
+ async setup() {
var entry = null;
this.cs = Services.cache.createSession("SanitizerTest", Components.interfaces.nsICache.STORE_ANYWHERE, true);
- entry = yield promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ_WRITE, this.cs);
+ entry = await promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ_WRITE, this.cs);
entry.setMetaDataElement("Foo", "Bar");
entry.markValid();
entry.close();
},
- check: function(aShouldBeCleared) {
+ async check(aShouldBeCleared) {
let entry = null;
- entry = yield promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ, this.cs);
+ entry = await promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ, this.cs);
if (entry) {
entry.close();
}
do_check_eq(!entry, aShouldBeCleared);
}
},
offlineApps: {
desc: "Offline app cache",
- setup: function() {
+ async setup() {
//XXX test offline DOMStorage
var entry = null;
this.cs = Services.cache.createSession("SanitizerTest", Components.interfaces.nsICache.STORE_OFFLINE, true);
- entry = yield promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ_WRITE, this.cs);
+ entry = await promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ_WRITE, this.cs);
entry.setMetaDataElement("Foo", "Bar");
entry.markValid();
entry.close();
},
- check: function(aShouldBeCleared) {
+ async check(aShouldBeCleared) {
var entry = null;
- entry = yield promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ, this.cs);
+ entry = await promiseOpenCacheEntry("http://santizer.test", Components.interfaces.nsICache.ACCESS_READ, this.cs);
if (entry) {
entry.close();
}
do_check_eq(!entry, aShouldBeCleared);
}
},
@@ -67,21 +67,21 @@ var sanTests = {
do_check_neq(this.cs.getCookieString(this.uri, null), "Sanitizer!");
else
do_check_eq(this.cs.getCookieString(this.uri, null), "Sanitizer!");
}
},
history: {
desc: "History",
- setup: function() {
+ async setup() {
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = ios.newURI("http://sanitizer.test/");
- yield promiseAddVisits({
+ await promiseAddVisits({
uri: uri,
title: "Sanitizer!"
});
},
check: function(aShouldBeCleared) {
var rv = false;
var history = Components.classes["@mozilla.org/browser/nav-history-service;1"]
@@ -159,34 +159,34 @@ var sanTests = {
connection.close();
do_check_eq(urlbar, !aShouldBeCleared);
}
},
formdata: {
desc: "Form history",
- setup: function() {
+ async setup() {
// Adds a form entry to history.
function promiseAddFormEntry(aName, aValue) {
return new Promise((resolve, reject) =>
FormHistory.update({ op: "add", fieldname: aName, value: aValue },
{ handleError(error) {
reject();
throw new Error("Error occurred updating form history: " + error);
},
handleCompletion(reason) {
resolve();
}
})
)
}
- yield promiseAddFormEntry("Sanitizer", "Foo");
+ await promiseAddFormEntry("Sanitizer", "Foo");
},
- check: function(aShouldBeCleared) {
+ async check(aShouldBeCleared) {
// Check if a form name exists.
function formNameExists(aName) {
return new Promise((resolve, reject) => {
let count = 0;
FormHistory.count({ fieldname: aName },
{ handleResult: result => count = result,
handleError(error) {
reject(error);
@@ -197,17 +197,17 @@ var sanTests = {
resolve(count);
}
}
});
});
}
// Checking for Sanitizer form history entry creation.
- let exists = yield formNameExists("Sanitizer");
+ let exists = await formNameExists("Sanitizer");
do_check_eq(exists, !aShouldBeCleared);
}
},
downloads: {
desc: "Download",
setup: function() {
var ios = Components.classes["@mozilla.org/network/io-service;1"]
@@ -298,58 +298,58 @@ var sanTests = {
"", domain, user, password);
} catch(ex) {}
do_check_eq(domain.value == "Foo", !aShouldBeCleared);
}
}
}
-function fullSanitize() {
+async function fullSanitize() {
do_print("Now doing a full sanitize run");
var prefs = Services.prefs.getBranch("privacy.item.");
Services.prefs.setBoolPref("privacy.sanitize.promptOnSanitize", false);
for (var testName in sanTests) {
var test = sanTests[testName];
- yield test.setup();
+ await test.setup();
prefs.setBoolPref(testName, true);
}
Sanitizer.sanitize();
for (var testName in sanTests) {
var test = sanTests[testName];
- yield test.check(true);
+ await test.check(true);
do_print(test.desc + " data cleared by full sanitize");
try {
prefs.clearUserPref(testName);
} catch (ex) {}
}
try {
Services.prefs.clearUserPref("privacy.sanitize.promptOnSanitize");
} catch(ex) {}
}
function run_test()
{
run_next_test();
}
-add_task(function test_browser_sanitizer()
+add_task(async function test_browser_sanitizer()
{
for (var testName in sanTests) {
let test = sanTests[testName];
dump("\nExecuting test: " + testName + "\n" + "*** " + test.desc + "\n");
- yield test.setup();
- yield test.check(false);
+ await test.setup();
+ await test.check(false);
do_check_true(Sanitizer.items[testName].canClear);
Sanitizer.items[testName].clear();
do_print(test.desc + " data cleared");
- yield test.check(true);
+ await test.check(true);
}
});
add_task(fullSanitize);