diff --git a/browser/components/migration/tests/unit/test_automigration.js b/browser/components/migration/tests/unit/test_automigration.js index 5b8cf7f3c9b1..78e6b44acb1a 100644 --- a/browser/components/migration/tests/unit/test_automigration.js +++ b/browser/components/migration/tests/unit/test_automigration.js @@ -576,11 +576,9 @@ add_task(function* checkUndoVisitsState() { // to accurately determine whether we're doing the right thing. let frecencyUpdatesHandled = new Promise(resolve => { PlacesUtils.history.addObserver({ - onFrecencyChanged(aURI) { - if (aURI.spec == "http://www.unrelated.org/") { - PlacesUtils.history.removeObserver(this); - resolve(); - } + onManyFrecenciesChanged() { + PlacesUtils.history.removeObserver(this); + resolve(); } }, false); }); diff --git a/browser/components/newtab/tests/xpcshell/test_PlacesProvider.js b/browser/components/newtab/tests/xpcshell/test_PlacesProvider.js index e1780bfa6764..ec4667be1faa 100644 --- a/browser/components/newtab/tests/xpcshell/test_PlacesProvider.js +++ b/browser/components/newtab/tests/xpcshell/test_PlacesProvider.js @@ -164,7 +164,10 @@ add_task(function* test_Links_onLinkChanged() { // add a visit let testURI = NetUtil.newURI(url); - yield PlacesTestUtils.addVisits(testURI); + yield PlacesUtils.history.insert({ + url: testURI, + visits: [{ transition: PlacesUtils.history.TRANSITIONS.LINK }] + }); yield linkChangedPromise; yield PlacesTestUtils.clearHistory(); diff --git a/toolkit/components/places/History.jsm b/toolkit/components/places/History.jsm index 6094fb054ae3..fd331bb495b3 100644 --- a/toolkit/components/places/History.jsm +++ b/toolkit/components/places/History.jsm @@ -1035,15 +1035,17 @@ var insertMany = Task.async(function*(db, pageInfos, onResult, onError) { let pageInfo = mergeUpdateInfoIntoPageInfo(result); onResultData.push(pageInfo); }, - handleCompletion: () => { + ignoreErrors: !onError, + ignoreResults: !onResult, + handleCompletion: (updatedCount) => { notifyOnResult(onResultData, onResult); notifyOnResult(onErrorData, onError); - if (onResultData.length) { + if (updatedCount > 0) { resolve(); } else { reject({message: "No items were added to history."}) } } - }); + }, true); }); }); diff --git a/toolkit/components/places/tests/history/test_insertMany.js b/toolkit/components/places/tests/history/test_insertMany.js index 1164d0a2fa12..3ad7d18c1acd 100644 --- a/toolkit/components/places/tests/history/test_insertMany.js +++ b/toolkit/components/places/tests/history/test_insertMany.js @@ -53,6 +53,21 @@ add_task(function* test_insertMany() { }); let inserter = Task.async(function*(name, filter, useCallbacks) { + function promiseManyFrecenciesChanged() { + return new Promise((resolve, reject) => { + let obs = new NavHistoryObserver(); + obs.onManyFrecenciesChanged = () => { + PlacesUtils.history.removeObserver(obs); + resolve(); + }; + obs.onFrecencyChanged = () => { + PlacesUtils.history.removeObserver(obs); + reject(); + }; + PlacesUtils.history.addObserver(obs, false); + }); + } + do_print(name); do_print(`filter: ${filter}`); do_print(`useCallbacks: ${useCallbacks}`); @@ -81,7 +96,9 @@ add_task(function* test_insertMany() { Assert.equal(GOOD_URLS.sort().toString(), onResultUrls.sort().toString(), "onResult callback was called for each good url"); Assert.equal(BAD_URLS.sort().toString(), onErrorUrls.sort().toString(), "onError callback was called for each bad url"); } else { + let promiseManyFrecencies = promiseManyFrecenciesChanged(); result = yield PlacesUtils.history.insertMany(pageInfos); + yield promiseManyFrecencies; } Assert.equal(undefined, result, "insertMany returned undefined");