forked from mirrors/gecko-dev
Bug 1343182 - Add updatePlaces' ignoreErrors, ignoreResults and aGroupNotifications to insertMany API in History.jsm. r=mak
MozReview-Commit-ID: 45VbtBu25cP --HG-- extra : rebase_source : dbae98bcf296ce119980e48a3e303aa279c62dba
This commit is contained in:
parent
0e17adee7c
commit
8d1b6e2ac3
4 changed files with 29 additions and 9 deletions
|
|
@ -576,12 +576,10 @@ 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/") {
|
||||
onManyFrecenciesChanged() {
|
||||
PlacesUtils.history.removeObserver(this);
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
});
|
||||
yield PlacesUtils.history.insertMany([{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue