Bug 1388149 - Make PlacesUtils.history.insertMany respect provided GUIDs r=markh

MozReview-Commit-ID: 7g6uABtHKg2

--HG--
extra : rebase_source : 0b43e026ad3de514d2ffbc56568bf3f4e3e17126
This commit is contained in:
Thom Chiovoloni 2017-08-07 16:01:10 -04:00
Родитель 2e035ad163
Коммит 3e1366bdf6
3 изменённых файлов: 50 добавлений и 0 удалений

Просмотреть файл

@ -137,6 +137,7 @@ add_task(async function test_store_create() {
]);
await onVisitObserved;
try {
do_check_true((await store.itemExists(tbguid)));
do_check_attribute_count(await store.getAllIDs(), 2);
let queryres = queryHistoryVisits(tburi);
do_check_eq(queryres.length, 1);

Просмотреть файл

@ -710,6 +710,7 @@ this.History = Object.freeze({
*/
function convertForUpdatePlaces(pageInfo) {
let info = {
guid: pageInfo.guid,
uri: PlacesUtils.toURI(pageInfo.url),
title: pageInfo.title,
visits: [],

Просмотреть файл

@ -145,3 +145,51 @@ add_task(async function test_transitions() {
});
Assert.equal(count, Object.keys(PlacesUtils.history.TRANSITIONS).length);
});
add_task(async function test_guid() {
const guidA = "aaaaaaaaaaaa";
const guidB = "bbbbbbbbbbbb";
const guidC = "cccccccccccc";
await PlacesUtils.history.insertMany([
{
title: "foo",
url: "http://example.com/foo",
guid: guidA,
visits: [
{ transition: TRANSITION_LINK, date: new Date() }
]
}
]);
Assert.ok(await PlacesUtils.history.fetch(guidA),
"Record is inserted with correct GUID");
let expectedGuids = new Set([guidB, guidC]);
await PlacesUtils.history.insertMany([
{
title: "bar",
url: "http://example.com/bar",
guid: guidB,
visits: [
{ transition: TRANSITION_LINK, date: new Date() }
]
},
{
title: "baz",
url: "http://example.com/baz",
guid: guidC,
visits: [
{ transition: TRANSITION_LINK, date: new Date() }
]
}
], pageInfo => {
Assert.ok(expectedGuids.has(pageInfo.guid));
expectedGuids.delete(pageInfo.guid);
});
Assert.equal(expectedGuids.size, 0);
Assert.ok(await PlacesUtils.history.fetch(guidB), "Record B is fetchable after insertMany");
Assert.ok(await PlacesUtils.history.fetch(guidC), "Record C is fetchable after insertMany");
});