author | Neil Deakin <neil@mozilla.com> |
Wed, 20 Jan 2016 08:45:58 -0500 | |
changeset 280784 | 7fb5dbb033ea9f599e6c625cde297401cf3d5d33 |
parent 280783 | 2b1a1c9bdea3ee9ecfb24f9c678aa6fb2de82937 |
child 280785 | bc1262de864adb168bdcd0b612fcc03b39fd4948 |
push id | 29922 |
push user | cbook@mozilla.com |
push date | Thu, 21 Jan 2016 10:51:00 +0000 |
treeherder | mozilla-central@977d78a8dd78 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mak |
bugs | 1236554 |
milestone | 46.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
|
--- a/toolkit/components/places/tests/browser/browser_bug248970.js +++ b/toolkit/components/places/tests/browser/browser_bug248970.js @@ -25,22 +25,22 @@ add_task(function () { windowsToClose.forEach(function(win) { win.close(); }); }); yield PlacesTestUtils.clearHistory(); // Ensure we wait for the default bookmarks import. - let bookmarksDeferred = Promise.defer(); - waitForCondition(() => { - placeItemsCount = getPlacesItemsCount(); - return placeItemsCount > 0 - }, bookmarksDeferred.resolve, "Should have default bookmarks"); - yield bookmarksDeferred.promise; + yield new Promise(resolve => { + waitForCondition(() => { + placeItemsCount = getPlacesItemsCount(); + return placeItemsCount > 0 + }, resolve, "Should have default bookmarks") + }); // Create a handful of history items with various visit types yield PlacesTestUtils.addVisits([ { uri: visitedURIs[0], transition: TRANSITION_LINK }, { uri: visitedURIs[1], transition: TRANSITION_TYPED }, { uri: visitedURIs[2], transition: TRANSITION_BOOKMARK }, { uri: visitedURIs[3], transition: TRANSITION_REDIRECT_PERMANENT }, { uri: visitedURIs[4], transition: TRANSITION_REDIRECT_TEMPORARY }, @@ -50,19 +50,19 @@ add_task(function () { ]); placeItemsCount += 7; // We added 7 new items to history. is(getPlacesItemsCount(), placeItemsCount, "Check the total items count"); function* testOnWindow(aIsPrivate, aCount) { - let deferred = Promise.defer(); - whenNewWindowLoaded({ private: aIsPrivate }, deferred.resolve); - let win = yield deferred.promise; + let win = yield new Promise(resolve => { + whenNewWindowLoaded({ private: aIsPrivate }, resolve); + }); windowsToClose.push(win); // History items should be retrievable by query yield checkHistoryItems(); // Updates the place items count let count = getPlacesItemsCount();
--- a/toolkit/components/places/tests/browser/head.js +++ b/toolkit/components/places/tests/browser/head.js @@ -8,20 +8,16 @@ const TRANSITION_REDIRECT_TEMPORARY = Ci const TRANSITION_EMBED = Ci.nsINavHistoryService.TRANSITION_EMBED; const TRANSITION_FRAMED_LINK = Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK; const TRANSITION_DOWNLOAD = Ci.nsINavHistoryService.TRANSITION_DOWNLOAD; Components.utils.import("resource://gre/modules/NetUtil.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils", "resource://testing-common/PlacesTestUtils.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Promise", - "resource://gre/modules/Promise.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Task", - "resource://gre/modules/Task.jsm"); /** * Returns a moz_places field value for a url. * * @param aURI * The URI or spec to get field for. * param aCallback * Callback function that will get the property value. @@ -270,47 +266,36 @@ function DBConn(aForceNewConnection) { Services.obs.removeObserver(DBCloseCallback, aTopic); dbConn.asyncClose(); }, "profile-before-change", false); } return gDBConn.connectionReady ? gDBConn : null; } -function whenDelayedStartupFinished(aWindow, aCallback) { - Services.obs.addObserver(function observer(aSubject, aTopic) { - if (aWindow == aSubject) { - Services.obs.removeObserver(observer, aTopic); - executeSoon(function() { aCallback(aWindow); }); - } - }, "browser-delayed-startup-finished", false); -} - function whenNewWindowLoaded(aOptions, aCallback) { - let win = OpenBrowserWindow(aOptions); - whenDelayedStartupFinished(win, aCallback); + BrowserTestUtils.waitForNewWindow().then(aCallback); + OpenBrowserWindow(aOptions); } /** * Asynchronously check a url is visited. * * @param aURI The URI. * @param aExpectedValue The expected value. * @return {Promise} * @resolves When the check has been added successfully. * @rejects JavaScript exception. */ function promiseIsURIVisited(aURI, aExpectedValue) { - let deferred = Promise.defer(); - - PlacesUtils.asyncHistory.isURIVisited(aURI, function(aURI, aIsVisited) { - deferred.resolve(aIsVisited); + return new Promise(resolve => { + PlacesUtils.asyncHistory.isURIVisited(aURI, function(aURI, aIsVisited) { + resolve(aIsVisited); + }); }); - - return deferred.promise; } function waitForCondition(condition, nextTest, errorMsg) { let tries = 0; let interval = setInterval(function() { if (tries >= 30) { ok(false, errorMsg); moveOn();