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,11 +576,9 @@ add_task(function* checkUndoVisitsState() {
|
||||||
// to accurately determine whether we're doing the right thing.
|
// to accurately determine whether we're doing the right thing.
|
||||||
let frecencyUpdatesHandled = new Promise(resolve => {
|
let frecencyUpdatesHandled = new Promise(resolve => {
|
||||||
PlacesUtils.history.addObserver({
|
PlacesUtils.history.addObserver({
|
||||||
onFrecencyChanged(aURI) {
|
onManyFrecenciesChanged() {
|
||||||
if (aURI.spec == "http://www.unrelated.org/") {
|
PlacesUtils.history.removeObserver(this);
|
||||||
PlacesUtils.history.removeObserver(this);
|
resolve();
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,10 @@ add_task(function* test_Links_onLinkChanged() {
|
||||||
|
|
||||||
// add a visit
|
// add a visit
|
||||||
let testURI = NetUtil.newURI(url);
|
let testURI = NetUtil.newURI(url);
|
||||||
yield PlacesTestUtils.addVisits(testURI);
|
yield PlacesUtils.history.insert({
|
||||||
|
url: testURI,
|
||||||
|
visits: [{ transition: PlacesUtils.history.TRANSITIONS.LINK }]
|
||||||
|
});
|
||||||
yield linkChangedPromise;
|
yield linkChangedPromise;
|
||||||
|
|
||||||
yield PlacesTestUtils.clearHistory();
|
yield PlacesTestUtils.clearHistory();
|
||||||
|
|
|
||||||
|
|
@ -1035,15 +1035,17 @@ var insertMany = Task.async(function*(db, pageInfos, onResult, onError) {
|
||||||
let pageInfo = mergeUpdateInfoIntoPageInfo(result);
|
let pageInfo = mergeUpdateInfoIntoPageInfo(result);
|
||||||
onResultData.push(pageInfo);
|
onResultData.push(pageInfo);
|
||||||
},
|
},
|
||||||
handleCompletion: () => {
|
ignoreErrors: !onError,
|
||||||
|
ignoreResults: !onResult,
|
||||||
|
handleCompletion: (updatedCount) => {
|
||||||
notifyOnResult(onResultData, onResult);
|
notifyOnResult(onResultData, onResult);
|
||||||
notifyOnResult(onErrorData, onError);
|
notifyOnResult(onErrorData, onError);
|
||||||
if (onResultData.length) {
|
if (updatedCount > 0) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
reject({message: "No items were added to history."})
|
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) {
|
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(name);
|
||||||
do_print(`filter: ${filter}`);
|
do_print(`filter: ${filter}`);
|
||||||
do_print(`useCallbacks: ${useCallbacks}`);
|
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(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");
|
Assert.equal(BAD_URLS.sort().toString(), onErrorUrls.sort().toString(), "onError callback was called for each bad url");
|
||||||
} else {
|
} else {
|
||||||
|
let promiseManyFrecencies = promiseManyFrecenciesChanged();
|
||||||
result = yield PlacesUtils.history.insertMany(pageInfos);
|
result = yield PlacesUtils.history.insertMany(pageInfos);
|
||||||
|
yield promiseManyFrecencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.equal(undefined, result, "insertMany returned undefined");
|
Assert.equal(undefined, result, "insertMany returned undefined");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue