Bug 1071505 - use constant GUIDs for Places roots (test changes). rs=mano

--HG--
rename : toolkit/components/places/tests/migration/places_v6_no_frecency.sqlite => toolkit/components/places/tests/migration/places_v6.sqlite
rename : toolkit/components/places/tests/migration/test_current_from_v10.js => toolkit/components/places/tests/migration/test_current_from_v16.js
rename : toolkit/components/places/tests/migration/test_database_from_v6_no_frecency.js => toolkit/components/places/tests/migration/test_current_from_v6.js
This commit is contained in:
Marco Bonardo 2014-11-04 17:40:41 +01:00
Родитель 0cab188e85
Коммит 0af2372b47
31 изменённых файлов: 302 добавлений и 836 удалений

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

@ -8,11 +8,10 @@ add_task(function* test_eraseEverything() {
let frecencyForMozilla = frecencyForUrl("http://example.com/");
Assert.ok(frecencyForExample > 0);
Assert.ok(frecencyForMozilla > 0);
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let unfiledFolder = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let unfiledFolder = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER });
checkBookmarkObject(unfiledFolder);
let unfiledBookmark = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let unfiledBookmark = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
keyword: "kw1" });
@ -25,11 +24,10 @@ add_task(function* test_eraseEverything() {
PlacesUtils.annotations.setItemAnnotation((yield PlacesUtils.promiseItemId(unfiledBookmarkInFolder.guid)),
"testanno1", "testvalue1", 0, 0);
let menuGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.bookmarksMenuFolderId);
let menuFolder = yield PlacesUtils.bookmarks.insert({ parentGuid: menuGuid,
let menuFolder = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER });
checkBookmarkObject(menuFolder);
let menuBookmark = yield PlacesUtils.bookmarks.insert({ parentGuid: menuGuid,
let menuBookmark = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
keyword: "kw2" });
@ -42,11 +40,10 @@ add_task(function* test_eraseEverything() {
PlacesUtils.annotations.setItemAnnotation((yield PlacesUtils.promiseItemId(menuBookmarkInFolder.guid)),
"testanno1", "testvalue1", 0, 0);
let toolbarGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.toolbarFolderId);
let toolbarFolder = yield PlacesUtils.bookmarks.insert({ parentGuid: toolbarGuid,
let toolbarFolder = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER });
checkBookmarkObject(toolbarFolder);
let toolbarBookmark = yield PlacesUtils.bookmarks.insert({ parentGuid: toolbarGuid,
let toolbarBookmark = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
keyword: "kw3" });
@ -82,16 +79,11 @@ add_task(function* test_eraseEverything_roots() {
yield PlacesUtils.bookmarks.eraseEverything();
// Ensure the roots have not been removed.
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
Assert.ok(yield PlacesUtils.bookmarks.fetch(unfiledGuid));
let toolbarGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.toolbarFolderId);
Assert.ok(yield PlacesUtils.bookmarks.fetch(toolbarGuid));
let menuGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.bookmarksMenuFolderId);
Assert.ok(yield PlacesUtils.bookmarks.fetch(menuGuid));
let tagsGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.tagsFolderId);
Assert.ok(yield PlacesUtils.bookmarks.fetch(tagsGuid));
let rootGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.placesRootId);
Assert.ok(yield PlacesUtils.bookmarks.fetch(rootGuid));
Assert.ok(yield PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.unfiledGuid));
Assert.ok(yield PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.toolbarGuid));
Assert.ok(yield PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.menuGuid));
Assert.ok(yield PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.tagsGuid));
Assert.ok(yield PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.rootGuid));
});
function run_test() {

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

@ -100,8 +100,7 @@ add_task(function* fetch_nonexistent_guid() {
});
add_task(function* fetch_bookmark() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "a bookmark" });
@ -115,7 +114,7 @@ add_task(function* fetch_bookmark() {
Assert.deepEqual(gAccumulator.results[0], bm1);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm2.index, 0);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
@ -127,8 +126,7 @@ add_task(function* fetch_bookmark() {
});
add_task(function* fetch_bookmar_empty_title() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "" });
@ -146,8 +144,7 @@ add_task(function* fetch_bookmar_empty_title() {
});
add_task(function* fetch_folder() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: "a folder" });
checkBookmarkObject(bm1);
@ -156,7 +153,7 @@ add_task(function* fetch_folder() {
checkBookmarkObject(bm2);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm2.index, 0);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_FOLDER);
@ -168,8 +165,7 @@ add_task(function* fetch_folder() {
});
add_task(function* fetch_folder_empty_title() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: "" });
checkBookmarkObject(bm1);
@ -185,9 +181,7 @@ add_task(function* fetch_folder_empty_title() {
});
add_task(function* fetch_separator() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR });
checkBookmarkObject(bm1);
@ -195,7 +189,7 @@ add_task(function* fetch_separator() {
checkBookmarkObject(bm2);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm2.index, 0);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);
@ -215,8 +209,7 @@ add_task(function* fetch_byposition_nonexisting_parentGuid() {
});
add_task(function* fetch_byposition_nonexisting_index() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.fetch({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.fetch({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
index: 100 },
gAccumulator.callback);
Assert.equal(bm, null);
@ -224,8 +217,7 @@ add_task(function* fetch_byposition_nonexisting_index() {
});
add_task(function* fetch_byposition() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "a bookmark" });
@ -240,7 +232,7 @@ add_task(function* fetch_byposition() {
Assert.deepEqual(gAccumulator.results[0], bm1);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm2.index, 0);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
@ -257,8 +249,7 @@ add_task(function* fetch_byurl_nonexisting() {
});
add_task(function* fetch_byurl() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://byurl.com/",
title: "a bookmark" });
@ -272,14 +263,14 @@ add_task(function* fetch_byurl() {
Assert.deepEqual(gAccumulator.results[0], bm1);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
Assert.equal(bm2.url.href, "http://byurl.com/");
Assert.equal(bm2.title, "a bookmark");
Assert.ok(!("keyword" in bm2));
let bm3 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm3 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://byurl.com/",
title: "a bookmark" });
@ -312,8 +303,7 @@ add_task(function* fetch_bykeyword_nonexisting() {
});
add_task(function* fetch_bykeyword() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://bykeyword1.com/",
keyword: "bykeyword" });
@ -327,13 +317,13 @@ add_task(function* fetch_bykeyword() {
Assert.deepEqual(gAccumulator.results[0], bm1);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
Assert.equal(bm2.url.href, "http://bykeyword1.com/");
Assert.equal(bm2.keyword, "bykeyword");
let bm3 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm3 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://bykeyword2.com/",
keyword: "bykeyword" });

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

@ -115,12 +115,11 @@ add_task(function* long_title_trim() {
for (let i = 0; i < 4096; i++) {
longtitle += "a";
}
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: longtitle });
checkBookmarkObject(bm);
Assert.equal(bm.parentGuid, unfiledGuid);
Assert.equal(bm.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm.index, 0);
Assert.equal(bm.dateAdded, bm.lastModified);
Assert.equal(bm.type, PlacesUtils.bookmarks.TYPE_FOLDER);
@ -130,12 +129,11 @@ add_task(function* long_title_trim() {
});
add_task(function* create_separator() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
index: PlacesUtils.bookmarks.DEFAULT_INDEX });
checkBookmarkObject(bm);
Assert.equal(bm.parentGuid, unfiledGuid);
Assert.equal(bm.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm.index, 1);
Assert.equal(bm.dateAdded, bm.lastModified);
Assert.equal(bm.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);
@ -143,9 +141,8 @@ add_task(function* create_separator() {
});
add_task(function* create_separator_w_title_fail() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
try {
yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
title: "a separator" });
Assert.ok(false, "Trying to set title for a separator should reject");
@ -162,14 +159,13 @@ add_task(function* create_separator_invalid_parent_fail() {
});
add_task(function* create_separator_given_guid() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
guid: "123456789012" });
checkBookmarkObject(bm);
Assert.equal(bm.guid, "123456789012");
Assert.equal(bm.parentGuid, unfiledGuid);
Assert.equal(bm.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm.index, 2);
Assert.equal(bm.dateAdded, bm.lastModified);
Assert.equal(bm.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);
@ -184,12 +180,11 @@ add_task(function* create_item_given_guid_no_type_fail() {
});
add_task(function* create_separator_big_index() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
index: 9999 });
checkBookmarkObject(bm);
Assert.equal(bm.parentGuid, unfiledGuid);
Assert.equal(bm.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm.index, 3);
Assert.equal(bm.dateAdded, bm.lastModified);
Assert.equal(bm.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);
@ -199,8 +194,7 @@ add_task(function* create_separator_big_index() {
add_task(function* create_separator_given_dateAdded() {
let time = new Date();
let past = new Date(time - 86400000);
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
dateAdded: past });
checkBookmarkObject(bm);
@ -209,11 +203,10 @@ add_task(function* create_separator_given_dateAdded() {
});
add_task(function* create_folder() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER });
checkBookmarkObject(bm);
Assert.equal(bm.parentGuid, unfiledGuid);
Assert.equal(bm.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm.dateAdded, bm.lastModified);
Assert.equal(bm.type, PlacesUtils.bookmarks.TYPE_FOLDER);
Assert.ok(!("title" in bm), "title should not be set");
@ -231,8 +224,7 @@ add_task(function* create_folder() {
});
add_task(function* create_bookmark() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER });
let parentGuid = bm.guid;
@ -278,8 +270,7 @@ add_task(function* create_bookmark() {
});
add_task(function* create_bookmark_frecency() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "a bookmark" });

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

@ -2,10 +2,9 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(function* insert_separator_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let observer = expectNotifications();
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
parentGuid: unfiledGuid});
parentGuid: PlacesUtils.bookmarks.unfiledGuid});
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemAdded",
@ -16,10 +15,9 @@ add_task(function* insert_separator_notification() {
});
add_task(function* insert_folder_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let observer = expectNotifications();
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
title: "a folder" });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
@ -31,10 +29,9 @@ add_task(function* insert_folder_notification() {
});
add_task(function* insert_folder_notitle_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let observer = expectNotifications();
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: unfiledGuid });
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemAdded",
@ -45,10 +42,9 @@ add_task(function* insert_folder_notitle_notification() {
});
add_task(function* insert_bookmark_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let observer = expectNotifications();
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://example.com/"),
title: "a bookmark" });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
@ -61,10 +57,9 @@ add_task(function* insert_bookmark_notification() {
});
add_task(function* insert_bookmark_notitle_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let observer = expectNotifications();
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://example.com/") });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
@ -76,10 +71,9 @@ add_task(function* insert_bookmark_notitle_notification() {
});
add_task(function* insert_bookmark_keyword_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let observer = expectNotifications();
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://example.com/"),
keyword: "kw" });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
@ -96,16 +90,14 @@ add_task(function* insert_bookmark_keyword_notification() {
});
add_task(function* insert_bookmark_tag_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://tag.example.com/") });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
let tagsGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.tagsFolderId);
let tagFolder = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: tagsGuid,
parentGuid: PlacesUtils.bookmarks.tagsGuid,
title: "tag" });
let observer = expectNotifications();
let tag = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -130,9 +122,8 @@ add_task(function* insert_bookmark_tag_notification() {
});
add_task(function* update_bookmark_lastModified() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://lastmod.example.com/") });
let observer = expectNotifications();
bm = yield PlacesUtils.bookmarks.update({ guid: bm.guid,
@ -148,9 +139,8 @@ add_task(function* update_bookmark_lastModified() {
});
add_task(function* update_bookmark_title() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://title.example.com/") });
let observer = expectNotifications();
bm = yield PlacesUtils.bookmarks.update({ guid: bm.guid,
@ -166,9 +156,8 @@ add_task(function* update_bookmark_title() {
});
add_task(function* update_bookmark_uri() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://url.example.com/") });
let observer = expectNotifications();
bm = yield PlacesUtils.bookmarks.update({ guid: bm.guid,
@ -184,9 +173,8 @@ add_task(function* update_bookmark_uri() {
});
add_task(function* update_bookmark_keyword() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://keyword.example.com/") });
let observer = expectNotifications();
bm = yield PlacesUtils.bookmarks.update({ guid: bm.guid,
@ -202,9 +190,8 @@ add_task(function* update_bookmark_keyword() {
});
add_task(function* remove_bookmark() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://remove.example.com/") });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
@ -220,9 +207,8 @@ add_task(function* remove_bookmark() {
});
add_task(function* remove_folder() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: unfiledGuid });
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
@ -235,16 +221,14 @@ add_task(function* remove_folder() {
});
add_task(function* remove_bookmark_tag_notification() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://untag.example.com/") });
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
let tagsGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.tagsFolderId);
let tagFolder = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: tagsGuid,
parentGuid: PlacesUtils.bookmarks.tagsGuid,
title: "tag" });
let tag = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: tagFolder.guid,
@ -269,9 +253,8 @@ add_task(function* eraseEverything_notification() {
// Let's start from a clean situation.
yield PlacesUtils.bookmarks.eraseEverything();
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let folder1 = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: unfiledGuid });
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
let folder1Id = yield PlacesUtils.promiseItemId(folder1.guid);
let folder1ParentId = yield PlacesUtils.promiseItemId(folder1.parentGuid);
@ -282,20 +265,18 @@ add_task(function* eraseEverything_notification() {
let parentId = yield PlacesUtils.promiseItemId(bm.parentGuid);
let folder2 = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: unfiledGuid });
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
let folder2Id = yield PlacesUtils.promiseItemId(folder2.guid);
let folder2ParentId = yield PlacesUtils.promiseItemId(folder2.parentGuid);
let toolbarGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.toolbarFolderId);
let toolbarBm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: toolbarGuid,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
url: new URL("http://example.com/") });
let toolbarBmId = yield PlacesUtils.promiseItemId(toolbarBm.guid);
let toolbarBmParentId = yield PlacesUtils.promiseItemId(toolbarBm.parentGuid);
let menuGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.bookmarksMenuFolderId);
let menuBm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: menuGuid,
parentGuid: PlacesUtils.bookmarks.menuGuid,
url: new URL("http://example.com/") });
let menuBmId = yield PlacesUtils.promiseItemId(menuBm.guid);
let menuBmParentId = yield PlacesUtils.promiseItemId(menuBm.parentGuid);

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

@ -44,17 +44,15 @@ add_task(function* remove_nonexistent_guid() {
});
add_task(function* remove_roots_fail() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
try {
yield PlacesUtils.bookmarks.remove(unfiledGuid);
yield PlacesUtils.bookmarks.remove(PlacesUtils.bookmarks.unfiledGuid);
Assert.ok(false, "Should have thrown");
} catch (ex) {
Assert.ok(/It's not possible to remove Places root folders/.test(ex));
}
let placesRootGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.placesRootId);
try {
yield PlacesUtils.bookmarks.remove(placesRootGuid);
yield PlacesUtils.bookmarks.remove(PlacesUtils.bookmarks.rootGuid);
Assert.ok(false, "Should have thrown");
} catch (ex) {
Assert.ok(/It's not possible to remove Places root folders/.test(ex));
@ -62,8 +60,7 @@ add_task(function* remove_roots_fail() {
});
add_task(function* remove_bookmark() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "a bookmark" });
@ -73,7 +70,7 @@ add_task(function* remove_bookmark() {
checkBookmarkObject(bm2);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm2.index, 0);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
@ -84,8 +81,7 @@ add_task(function* remove_bookmark() {
add_task(function* remove_bookmark_orphans() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "a bookmark",
@ -111,8 +107,7 @@ add_task(function* remove_bookmark_orphans() {
});
add_task(function* remove_bookmark_empty_title() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "" });
@ -128,8 +123,7 @@ add_task(function* remove_bookmark_empty_title() {
});
add_task(function* remove_folder() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: "a folder" });
checkBookmarkObject(bm1);
@ -138,7 +132,7 @@ add_task(function* remove_folder() {
checkBookmarkObject(bm2);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm2.index, 0);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_FOLDER);
@ -148,8 +142,7 @@ add_task(function* remove_folder() {
});
add_task(function* remove_folder_empty_title() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: "" });
checkBookmarkObject(bm1);
@ -163,8 +156,7 @@ add_task(function* remove_folder_empty_title() {
});
add_task(function* remove_separator() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR });
checkBookmarkObject(bm1);
@ -172,7 +164,7 @@ add_task(function* remove_separator() {
checkBookmarkObject(bm2);
Assert.deepEqual(bm1, bm2);
Assert.equal(bm2.parentGuid, unfiledGuid);
Assert.equal(bm2.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(bm2.index, 0);
Assert.deepEqual(bm2.dateAdded, bm2.lastModified);
Assert.equal(bm2.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);

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

@ -97,9 +97,8 @@ add_task(function* nonexisting_bookmark_throws() {
});
add_task(function* invalid_properties_for_existing_bookmark() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: unfiledGuid,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/" });
try {
@ -145,7 +144,7 @@ add_task(function* invalid_properties_for_existing_bookmark() {
}
let folder = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: unfiledGuid });
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
try {
yield PlacesUtils.bookmarks.update({ guid: folder.guid,
url: "http://example.com/" });
@ -162,7 +161,7 @@ add_task(function* invalid_properties_for_existing_bookmark() {
}
let separator = yield PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
parentGuid: unfiledGuid });
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
try {
yield PlacesUtils.bookmarks.update({ guid: separator.guid,
url: "http://example.com/" });
@ -191,8 +190,7 @@ add_task(function* long_title_trim() {
for (let i = 0; i < 4096; i++) {
longtitle += "a";
}
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: "title" });
checkBookmarkObject(bm);
@ -207,9 +205,8 @@ add_task(function* long_title_trim() {
});
add_task(function* update_lastModified() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let yesterday = new Date(Date.now() - 86400000);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: "title",
dateAdded: yesterday });
@ -242,8 +239,7 @@ add_task(function* update_lastModified() {
});
add_task(function* update_keyword() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "title",
@ -277,8 +273,7 @@ add_task(function* update_keyword() {
});
add_task(function* update_url() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
url: "http://example.com/",
title: "title",
@ -303,8 +298,7 @@ add_task(function* update_url() {
});
add_task(function* update_index() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let parent = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let parent = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER }) ;
let f1 = yield PlacesUtils.bookmarks.insert({ parentGuid: parent.guid,
type: PlacesUtils.bookmarks.TYPE_FOLDER });
@ -344,8 +338,7 @@ add_task(function* update_index() {
});
add_task(function* update_move_folder_into_descendant_throws() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let parent = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let parent = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER }) ;
let descendant = yield PlacesUtils.bookmarks.insert({ parentGuid: parent.guid,
type: PlacesUtils.bookmarks.TYPE_FOLDER });
@ -370,8 +363,7 @@ add_task(function* update_move_folder_into_descendant_throws() {
});
add_task(function* update_move() {
let unfiledGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.unfiledBookmarksFolderId);
let parent = yield PlacesUtils.bookmarks.insert({ parentGuid: unfiledGuid,
let parent = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER }) ;
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: parent.guid,
url: "http://example.com/",

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

@ -3,7 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const CURRENT_SCHEMA_VERSION = 24;
const CURRENT_SCHEMA_VERSION = 25;
const FIRST_UPGRADABLE_SCHEMA_VERSION = 11;
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
@ -43,6 +44,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesTransactions",
"resource://gre/modules/PlacesTransactions.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Sqlite",
"resource://gre/modules/Sqlite.jsm");
// This imports various other objects in addition to PlacesUtils.
Cu.import("resource://gre/modules/PlacesUtils.jsm");

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

@ -1,10 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cr = Components.results;
const Cu = Components.utils;
"use strict"
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
@ -16,25 +15,31 @@ let (commonFile = do_get_file("../head_common.js", false)) {
// Put any other stuff relative to this test folder below.
const kDBName = "places.sqlite";
const DB_FILENAME = "places.sqlite";
/**
* Sets the database to use for the given test. This should be the very first
* thing we do otherwise, this database will not be used!
* thing in the test, otherwise this database will not be used!
*
* @param aFileName
* The filename of the database to use. This database must exist in
* toolkit/components/places/tests/migration!
* @return {Promise}
*/
function setPlacesDatabase(aFileName)
{
let file = do_get_file(aFileName);
let setupPlacesDatabase = Task.async(function* (aFileName) {
let currentDir = yield OS.File.getCurrentDirectory();
let src = OS.Path.join(currentDir, aFileName);
Assert.ok((yield OS.File.exists(src)), "Database file found");
// Ensure that our database doesn't already exist.
let (dbFile = gProfD.clone()) {
dbFile.append(kDBName);
do_check_false(dbFile.exists());
}
let dest = OS.Path.join(OS.Constants.Path.profileDir, DB_FILENAME);
Assert.ok(!(yield OS.File.exists(dest)), "Database file should not exist yet");
file.copyToFollowingLinks(gProfD, kDBName);
yield OS.File.copy(src, dest);
});
// This works provided all tests in this folder use add_task.
function run_test() {
run_next_test();
}

Двоичный файл не отображается.

Двоичные данные
toolkit/components/places/tests/migration/places_v11.sqlite Normal file

Двоичный файл не отображается.

Двоичные данные
toolkit/components/places/tests/migration/places_v17.sqlite Normal file

Двоичный файл не отображается.

Двоичные данные
toolkit/components/places/tests/migration/places_v21.sqlite Normal file

Двоичный файл не отображается.

Двоичные данные
toolkit/components/places/tests/migration/places_v22.sqlite Normal file

Двоичный файл не отображается.

Двоичные данные
toolkit/components/places/tests/migration/places_v23.sqlite Normal file

Двоичный файл не отображается.

Двоичные данные
toolkit/components/places/tests/migration/places_v24.sqlite Normal file

Двоичный файл не отображается.

Двоичные данные
toolkit/components/places/tests/migration/places_v25.sqlite Normal file

Двоичный файл не отображается.

Двоичный файл не отображается.

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

@ -0,0 +1,19 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(function* setup() {
yield setupPlacesDatabase(`places_v${CURRENT_SCHEMA_VERSION}.sqlite`);
// Downgrade the schema version to the first supported one.
let path = OS.Path.join(OS.Constants.Path.profileDir, DB_FILENAME);
let db = yield Sqlite.openConnection({ path: path });
yield db.setSchemaVersion(FIRST_UPGRADABLE_SCHEMA_VERSION);
yield db.close();
});
add_task(function* database_is_valid() {
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_UPGRADED);
let db = yield PlacesUtils.promiseDBConnection();
Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
});

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

@ -1,368 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests migration invariants from schema version 10 to the current
* schema version.
*/
////////////////////////////////////////////////////////////////////////////////
//// Constants
const kGuidAnnotationName = "sync/guid";
const kExpectedAnnotations = 5;
const kExpectedValidGuids = 2;
////////////////////////////////////////////////////////////////////////////////
//// Globals
// Set in test_initial_state to the value in the database.
var gItemGuid = [];
var gItemId = [];
var gPlaceGuid = [];
var gPlaceId = [];
////////////////////////////////////////////////////////////////////////////////
//// Helpers
/**
* Determines if a guid is valid or not.
*
* @return true if it is a valid guid, false otherwise.
*/
function isValidGuid(aGuid)
{
return /^[a-zA-Z0-9\-_]{12}$/.test(aGuid);
}
////////////////////////////////////////////////////////////////////////////////
//// Test Functions
function test_initial_state()
{
// Mostly sanity checks our starting DB to make sure it's setup as we expect
// it to be.
let dbFile = gProfD.clone();
dbFile.append(kDBName);
let db = Services.storage.openUnsharedDatabase(dbFile);
let stmt = db.createStatement("PRAGMA journal_mode");
do_check_true(stmt.executeStep());
// WAL journal mode should not be set on this database.
do_check_neq(stmt.getString(0).toLowerCase(), "wal");
stmt.finalize();
do_check_false(db.indexExists("moz_bookmarks_guid_uniqueindex"));
do_check_false(db.indexExists("moz_places_guid_uniqueindex"));
// There should be five item annotations for a bookmark guid.
stmt = db.createStatement(
`SELECT content AS guid, item_id
FROM moz_items_annos
WHERE anno_attribute_id = (
SELECT id
FROM moz_anno_attributes
WHERE name = :attr_name
)`
);
stmt.params.attr_name = kGuidAnnotationName;
while (stmt.executeStep()) {
gItemGuid.push(stmt.row.guid);
gItemId.push(stmt.row.item_id)
}
do_check_eq(gItemGuid.length, gItemId.length);
do_check_eq(gItemGuid.length, kExpectedAnnotations);
stmt.finalize();
// There should be five item annotations for a place guid.
stmt = db.createStatement(
`SELECT content AS guid, place_id
FROM moz_annos
WHERE anno_attribute_id = (
SELECT id
FROM moz_anno_attributes
WHERE name = :attr_name
)`
);
stmt.params.attr_name = kGuidAnnotationName;
while (stmt.executeStep()) {
gPlaceGuid.push(stmt.row.guid);
gPlaceId.push(stmt.row.place_id)
}
do_check_eq(gPlaceGuid.length, gPlaceId.length);
do_check_eq(gPlaceGuid.length, kExpectedAnnotations);
stmt.finalize();
// Check our schema version to make sure it is actually at 10.
do_check_eq(db.schemaVersion, 10);
db.close();
run_next_test();
}
function test_moz_bookmarks_guid_exists()
{
// This will throw if the column does not exist
let stmt = DBConn().createStatement(
`SELECT guid
FROM moz_bookmarks`
);
stmt.finalize();
run_next_test();
}
function test_bookmark_guids_non_null()
{
// First, sanity check that we have a non-zero amount of bookmarks.
let stmt = DBConn().createStatement(
`SELECT COUNT(1)
FROM moz_bookmarks`
);
do_check_true(stmt.executeStep());
do_check_neq(stmt.getInt32(0), 0);
stmt.finalize();
// Now, make sure we have no NULL guid entry.
stmt = DBConn().createStatement(
`SELECT guid
FROM moz_bookmarks
WHERE guid IS NULL`
);
do_check_false(stmt.executeStep());
stmt.finalize();
run_next_test();
}
function test_bookmark_guid_annotation_imported()
{
// Make sure we have the imported guid; not a newly generated one.
let stmt = DBConn().createStatement(
`SELECT id
FROM moz_bookmarks
WHERE guid = :guid
AND id = :item_id`
);
let validGuids = 0;
let seenGuids = [];
for (let i = 0; i < gItemGuid.length; i++) {
let guid = gItemGuid[i];
stmt.params.guid = guid;
stmt.params.item_id = gItemId[i];
// Check that it is a valid guid that we expect, and that it is not a
// duplicate (which would violate the unique constraint).
let valid = isValidGuid(guid) && seenGuids.indexOf(guid) == -1;
seenGuids.push(guid);
if (valid) {
validGuids++;
do_check_true(stmt.executeStep());
}
else {
do_check_false(stmt.executeStep());
}
stmt.reset();
}
do_check_eq(validGuids, kExpectedValidGuids);
stmt.finalize();
run_next_test();
}
function test_bookmark_guid_annotation_removed()
{
let stmt = DBConn().createStatement(
`SELECT COUNT(1)
FROM moz_items_annos
WHERE anno_attribute_id = (
SELECT id
FROM moz_anno_attributes
WHERE name = :attr_name
)`
);
stmt.params.attr_name = kGuidAnnotationName;
do_check_true(stmt.executeStep());
do_check_eq(stmt.getInt32(0), 0);
stmt.finalize();
run_next_test();
}
function test_moz_places_guid_exists()
{
// This will throw if the column does not exist
let stmt = DBConn().createStatement(
`SELECT guid
FROM moz_places`
);
stmt.finalize();
run_next_test();
}
function test_place_guids_non_null()
{
// First, sanity check that we have a non-zero amount of places.
let stmt = DBConn().createStatement(
`SELECT COUNT(1)
FROM moz_places`
);
do_check_true(stmt.executeStep());
do_check_neq(stmt.getInt32(0), 0);
stmt.finalize();
// Now, make sure we have no NULL guid entry.
stmt = DBConn().createStatement(
`SELECT guid
FROM moz_places
WHERE guid IS NULL`
);
do_check_false(stmt.executeStep());
stmt.finalize();
run_next_test();
}
function test_place_guid_annotation_imported()
{
// Make sure we have the imported guid; not a newly generated one.
let stmt = DBConn().createStatement(
`SELECT id
FROM moz_places
WHERE guid = :guid
AND id = :item_id`
);
let validGuids = 0;
let seenGuids = [];
for (let i = 0; i < gPlaceGuid.length; i++) {
let guid = gPlaceGuid[i];
stmt.params.guid = guid;
stmt.params.item_id = gPlaceId[i];
// Check that it is a valid guid that we expect, and that it is not a
// duplicate (which would violate the unique constraint).
let valid = isValidGuid(guid) && seenGuids.indexOf(guid) == -1;
seenGuids.push(guid);
if (valid) {
validGuids++;
do_check_true(stmt.executeStep());
}
else {
do_check_false(stmt.executeStep());
}
stmt.reset();
}
do_check_eq(validGuids, kExpectedValidGuids);
stmt.finalize();
run_next_test();
}
function test_place_guid_annotation_removed()
{
let stmt = DBConn().createStatement(
`SELECT COUNT(1)
FROM moz_annos
WHERE anno_attribute_id = (
SELECT id
FROM moz_anno_attributes
WHERE name = :attr_name
)`
);
stmt.params.attr_name = kGuidAnnotationName;
do_check_true(stmt.executeStep());
do_check_eq(stmt.getInt32(0), 0);
stmt.finalize();
run_next_test();
}
function test_moz_hosts()
{
// This will throw if the column does not exist
let stmt = DBConn().createStatement(
`SELECT host, frecency, typed, prefix
FROM moz_hosts`
);
stmt.finalize();
// moz_hosts is populated asynchronously, so query asynchronously to serialize
// to that.
// check the number of entries in moz_hosts equals the number of
// unique rev_host in moz_places
stmt = DBConn().createAsyncStatement(
`SELECT (SELECT COUNT(host) FROM moz_hosts),
(SELECT COUNT(DISTINCT rev_host)
FROM moz_places
WHERE LENGTH(rev_host) > 1)`);
try {
stmt.executeAsync({
handleResult: function (aResult) {
this._hasResults = true;
let row = aResult.getNextRow();
let mozHostsCount = row.getResultByIndex(0);
let mozPlacesCount = row.getResultByIndex(1);
do_check_true(mozPlacesCount > 0);
do_check_eq(mozPlacesCount, mozHostsCount);
},
handleError: function () {},
handleCompletion: function (aReason) {
do_check_eq(aReason, Ci.mozIStorageStatementCallback.REASON_FINISHED);
do_check_true(this._hasResults);
run_next_test();
}
});
}
finally {
stmt.finalize();
}
}
function test_final_state()
{
// We open a new database mostly so that we can check that the settings were
// actually saved.
let dbFile = gProfD.clone();
dbFile.append(kDBName);
let db = Services.storage.openUnsharedDatabase(dbFile);
let (stmt = db.createStatement("PRAGMA journal_mode")) {
do_check_true(stmt.executeStep());
// WAL journal mode should be set on this database.
do_check_eq(stmt.getString(0).toLowerCase(), "wal");
stmt.finalize();
}
do_check_true(db.indexExists("moz_bookmarks_guid_uniqueindex"));
do_check_true(db.indexExists("moz_places_guid_uniqueindex"));
do_check_true(db.indexExists("moz_favicons_guid_uniqueindex"));
do_check_eq(db.schemaVersion, CURRENT_SCHEMA_VERSION);
db.close();
run_next_test();
}
////////////////////////////////////////////////////////////////////////////////
//// Test Runner
[
test_initial_state,
test_moz_bookmarks_guid_exists,
test_bookmark_guids_non_null,
test_bookmark_guid_annotation_imported,
test_bookmark_guid_annotation_removed,
test_moz_places_guid_exists,
test_place_guids_non_null,
test_place_guid_annotation_imported,
test_place_guid_annotation_removed,
test_moz_hosts,
test_final_state,
].forEach(add_test);
function run_test()
{
setPlacesDatabase("places_v10.sqlite");
run_next_test();
}

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

@ -1,132 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests migration invariants from a database with schema version 14
* that was then downgraded to a database with a schema version 10. Places
* should then migrate this database to one with the current schema version.
*/
////////////////////////////////////////////////////////////////////////////////
//// Test Functions
function test_initial_state()
{
// Mostly sanity checks our starting DB to make sure it's setup as we expect
// it to be.
let dbFile = gProfD.clone();
dbFile.append(kDBName);
let db = Services.storage.openUnsharedDatabase(dbFile);
let stmt = db.createStatement("PRAGMA journal_mode");
do_check_true(stmt.executeStep());
// WAL journal mode should have been unset this database when it was migrated
// down to v10.
do_check_neq(stmt.getString(0).toLowerCase(), "wal");
stmt.finalize();
do_check_true(db.indexExists("moz_bookmarks_guid_uniqueindex"));
do_check_true(db.indexExists("moz_places_guid_uniqueindex"));
// There should be a non-zero amount of bookmarks without a guid.
stmt = db.createStatement(
`SELECT COUNT(1)
FROM moz_bookmarks
WHERE guid IS NULL`
);
do_check_true(stmt.executeStep());
do_check_neq(stmt.getInt32(0), 0);
stmt.finalize();
// There should be a non-zero amount of places without a guid.
stmt = db.createStatement(
`SELECT COUNT(1)
FROM moz_places
WHERE guid IS NULL`
);
do_check_true(stmt.executeStep());
do_check_neq(stmt.getInt32(0), 0);
stmt.finalize();
// Check our schema version to make sure it is actually at 10.
do_check_eq(db.schemaVersion, 10);
db.close();
run_next_test();
}
function test_bookmark_guids_non_null()
{
// First, sanity check that we have a non-zero amount of bookmarks. If
// migration failed, we would have zero.
let stmt = DBConn().createStatement(
`SELECT COUNT(1)
FROM moz_bookmarks`
);
do_check_true(stmt.executeStep());
do_check_neq(stmt.getInt32(0), 0);
stmt.finalize();
// Now, make sure we have no NULL guid entries.
stmt = DBConn().createStatement(
`SELECT guid
FROM moz_bookmarks
WHERE guid IS NULL`
);
do_check_false(stmt.executeStep());
stmt.finalize();
run_next_test();
}
function test_place_guids_non_null()
{
// First, sanity check that we have a non-zero amount of places. If migration
// failed, we would have zero.
let stmt = DBConn().createStatement(
`SELECT COUNT(1)
FROM moz_places`
);
do_check_true(stmt.executeStep());
do_check_neq(stmt.getInt32(0), 0);
stmt.finalize();
// Now, make sure we have no NULL guid entry.
stmt = DBConn().createStatement(
`SELECT guid
FROM moz_places
WHERE guid IS NULL`
);
do_check_false(stmt.executeStep());
stmt.finalize();
run_next_test();
}
function test_final_state()
{
// We open a new database mostly so that we can check that the settings were
// actually saved.
let dbFile = gProfD.clone();
dbFile.append(kDBName);
let db = Services.storage.openUnsharedDatabase(dbFile);
do_check_eq(db.schemaVersion, CURRENT_SCHEMA_VERSION);
db.close();
run_next_test();
}
////////////////////////////////////////////////////////////////////////////////
//// Test Runner
[
test_initial_state,
test_bookmark_guids_non_null,
test_place_guids_non_null,
test_final_state,
].forEach(add_test);
function run_test()
{
setPlacesDatabase("places_v10_from_v14.sqlite");
run_next_test();
}

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

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(function* setup() {
yield setupPlacesDatabase("places_v16.sqlite");
});
add_task(function* database_is_valid() {
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_UPGRADED);
let db = yield PlacesUtils.promiseDBConnection();
Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
});
add_task(function* test_moz_hosts() {
let db = yield PlacesUtils.promiseDBConnection();
// This will throw if the column does not exist.
yield db.execute("SELECT host, frecency, typed, prefix FROM moz_hosts");
// moz_hosts is populated asynchronously, so we need to wait.
yield promiseAsyncUpdates();
// check the number of entries in moz_hosts equals the number of
// unique rev_host in moz_places
let rows = yield db.execute(
`SELECT (SELECT COUNT(host) FROM moz_hosts),
(SELECT COUNT(DISTINCT rev_host)
FROM moz_places
WHERE LENGTH(rev_host) > 1)
`);
Assert.equal(rows.length, 1);
let mozHostsCount = rows[0].getResultByIndex(0);
let mozPlacesCount = rows[0].getResultByIndex(1);
Assert.ok(mozPlacesCount > 0, "There is some url in the database");
Assert.equal(mozPlacesCount, mozHostsCount, "moz_hosts has the expected number of entries");
});
add_task(function* test_journal() {
let db = yield PlacesUtils.promiseDBConnection();
let rows = yield db.execute("PRAGMA journal_mode");
Assert.equal(rows.length, 1);
// WAL journal mode should be set on this database.
Assert.equal(rows[0].getResultByIndex(0), "wal");
});

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

@ -1,62 +1,42 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests migration invariants from schema version 19 to the current
* schema version.
*/
const ANNO_LEGACYGUID = "placesInternal/GUID";
////////////////////////////////////////////////////////////////////////////////
//// Globals
const kGuidAnnotationName = "placesInternal/GUID";
function getTotalGuidAnnotationsCount(aStorageConnection) {
stmt = aStorageConnection.createStatement(
let getTotalGuidAnnotationsCount = Task.async(function* (db) {
let rows = yield db.execute(
`SELECT count(*)
FROM moz_items_annos a
JOIN moz_anno_attributes b ON a.anno_attribute_id = b.id
WHERE b.name = :attr_name`
);
try {
stmt.params.attr_name = kGuidAnnotationName;
do_check_true(stmt.executeStep());
return stmt.getInt32(0);
} finally {
stmt.finalize();
}
}
////////////////////////////////////////////////////////////////////////////////
//// Tests
function run_test()
{
setPlacesDatabase("places_v19.sqlite");
run_next_test();
}
add_test(function test_initial_state()
{
let dbFile = gProfD.clone();
dbFile.append(kDBName);
let db = Services.storage.openUnsharedDatabase(dbFile);
// There should be an obsolete bookmark GUID annotation.
do_check_eq(getTotalGuidAnnotationsCount(db), 1);
// Check our schema version to make sure it is actually at 19.
do_check_eq(db.schemaVersion, 19);
db.close();
run_next_test();
WHERE b.name = :attr_name
`, { attr_name: ANNO_LEGACYGUID });
return rows[0].getResultByIndex(0);
});
add_test(function test_bookmark_guid_annotation_removed()
{
// There should be no obsolete bookmark GUID annotation anymore.
do_check_eq(getTotalGuidAnnotationsCount(DBConn()), 0);
run_next_test();
add_task(function* setup() {
yield setupPlacesDatabase("places_v19.sqlite");
});
add_task(function* initial_state() {
let path = OS.Path.join(OS.Constants.Path.profileDir, DB_FILENAME);
let db = yield Sqlite.openConnection({ path: path });
Assert.equal((yield getTotalGuidAnnotationsCount(db)), 1,
"There should be 1 obsolete guid annotation");
yield db.close();
});
add_task(function* database_is_valid() {
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_UPGRADED);
let db = yield PlacesUtils.promiseDBConnection();
Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
});
add_task(function test_bookmark_guid_annotation_removed()
{
let db = yield PlacesUtils.promiseDBConnection();
Assert.equal((yield getTotalGuidAnnotationsCount(db)), 0,
"There should be no more obsolete GUID annotations.");
});

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

@ -0,0 +1,35 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(function* setup() {
yield setupPlacesDatabase("places_v24.sqlite");
});
add_task(function* database_is_valid() {
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_UPGRADED);
let db = yield PlacesUtils.promiseDBConnection();
Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
});
add_task(function test_bookmark_guid_annotation_removed()
{
yield PlacesUtils.bookmarks.eraseEverything();
let db = yield PlacesUtils.promiseDBConnection();
let m = new Map([
[PlacesUtils.placesRootId, PlacesUtils.bookmarks.rootGuid],
[PlacesUtils.bookmarksMenuFolderId, PlacesUtils.bookmarks.menuGuid],
[PlacesUtils.toolbarFolderId, PlacesUtils.bookmarks.toolbarGuid],
[PlacesUtils.unfiledBookmarksFolderId, PlacesUtils.bookmarks.unfiledGuid],
[PlacesUtils.tagsFolderId, PlacesUtils.bookmarks.tagsGuid]
]);
let rows = yield db.execute(`SELECT id, guid FROM moz_bookmarks`);
for (let row of rows) {
let id = row.getResultByName("id");
let guid = row.getResultByName("guid");
Assert.equal(m.get(id), guid, "The root folder has the correct GUID");
}
});

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

@ -0,0 +1,38 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests migration from a preliminary schema version 6 that
* lacks frecency column and moz_inputhistory table.
*/
add_task(function* setup() {
yield setupPlacesDatabase("places_v6.sqlite");
});
add_task(function* corrupt_database_not_exists() {
let corruptPath = OS.Path.join(OS.Constants.Path.profileDir,
"places.sqlite.corrupt");
Assert.ok(!(yield OS.File.exists(corruptPath)), "Corrupt file should not exist");
});
add_task(function* database_is_valid() {
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_CORRUPT);
let db = yield PlacesUtils.promiseDBConnection();
Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
});
add_task(function* check_columns() {
// Check the database has been replaced, these would throw otherwise.
let db = yield PlacesUtils.promiseDBConnection();
yield db.execute("SELECT frecency from moz_places");
yield db.execute("SELECT 1 from moz_inputhistory");
});
add_task(function* corrupt_database_exists() {
let corruptPath = OS.Path.join(OS.Constants.Path.profileDir,
"places.sqlite.corrupt");
Assert.ok((yield OS.File.exists(corruptPath)), "Corrupt file should exist");
});

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

@ -1,34 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests migration replaces the database if schema version < 6.
*/
add_test(function corrupt_database_not_exists() {
let dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_false(dbFile.exists());
run_next_test();
});
add_test(function database_is_valid() {
do_check_eq(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_CORRUPT);
do_check_eq(DBConn().schemaVersion, CURRENT_SCHEMA_VERSION);
run_next_test();
});
add_test(function corrupt_database_exists() {
let dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_true(dbFile.exists());
run_next_test();
});
function run_test()
{
setPlacesDatabase("places_alpha.sqlite");
run_next_test();
}

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

@ -1,31 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests migration from a preliminary schema version 6 that
* lacks frecency column and moz_inputhistory table.
*/
add_test(function database_is_valid() {
do_check_eq(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_UPGRADED);
// This throws if frecency column does not exist.
stmt = DBConn().createStatement("SELECT frecency from moz_places");
stmt.finalize();
// Check moz_inputhistory is in place.
do_check_true(DBConn().tableExists("moz_inputhistory"));
run_next_test();
});
add_test(function corrupt_database_not_exists() {
let dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_false(dbFile.exists());
run_next_test();
});
function run_test()
{
setPlacesDatabase("places_v6_no_frecency.sqlite");
run_next_test();
}

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

@ -1,34 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests migration from a preliminary schema version 6 that
* lacks important indices. The database should be replaced.
*/
add_test(function corrupt_database_not_exists() {
let dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_false(dbFile.exists());
run_next_test();
});
add_test(function database_is_valid() {
do_check_eq(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_CORRUPT);
do_check_eq(DBConn().schemaVersion, CURRENT_SCHEMA_VERSION);
run_next_test();
});
add_test(function corrupt_database_exists() {
let dbFile = gProfD.clone();
dbFile.append("places.sqlite.corrupt");
do_check_true(dbFile.exists());
run_next_test();
});
function run_test()
{
setPlacesDatabase("places_v6_no_indices.sqlite");
run_next_test();
}

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

@ -1,18 +1,22 @@
[DEFAULT]
head = head_migration.js
tail =
skip-if = toolkit == 'android' || toolkit == 'gonk'
support-files =
places_alpha.sqlite
places_v10.sqlite
places_v10_from_v14.sqlite
places_v19.sqlite
places_v6_no_frecency.sqlite
places_v6_no_indices.sqlite
[test_current_from_v10.js]
[test_current_from_v10_migrated_from_v14.js]
support-files =
places_v6.sqlite
places_v10.sqlite
places_v11.sqlite
places_v16.sqlite
places_v17.sqlite
places_v19.sqlite
places_v21.sqlite
places_v22.sqlite
places_v23.sqlite
places_v24.sqlite
places_v25.sqlite
[test_current_from_downgraded.js]
[test_current_from_v6.js]
[test_current_from_v16.js]
[test_current_from_v19.js]
[test_database_from_alpha.js]
[test_database_from_v6_no_frecency.js]
[test_database_from_v6_no_indices.js]
[test_current_from_v24.js]

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

@ -210,17 +210,13 @@ function* test_promiseBookmarksTreeAgainstResult(aItemGuid = "",
add_task(function* () {
// Add some bookmarks to cover various use cases.
let toolbarGuid =
yield PlacesUtils.promiseItemGuid(PlacesUtils.toolbarFolderId);
let menuGuid =
yield PlacesUtils.promiseItemGuid(PlacesUtils.bookmarksMenuFolderId);
yield new_bookmark({ parentGuid: toolbarGuid });
yield new_folder({ parentGuid: menuGuid
yield new_bookmark({ parentGuid: PlacesUtils.bookmarks.toolbarGuid });
yield new_folder({ parentGuid: PlacesUtils.bookmarks.menuGuid
, annotations: [{ name: "TestAnnoA", value: "TestVal"
, name: "TestAnnoB", value: 0 }]});
yield PlacesTransactions.transact(
PlacesTransactions.NewSeparator({ parentGuid: menuGuid }));
let folderGuid = yield new_folder({ parentGuid: menuGuid });
PlacesTransactions.NewSeparator({ parentGuid: PlacesUtils.bookmarks.menuGuid }));
let folderGuid = yield new_folder({ parentGuid: PlacesUtils.bookmarks.menuGuid });
yield new_bookmark({ title: null
, parentGuid: folderGuid
, keyword: "test_keyword"
@ -234,8 +230,7 @@ add_task(function* () {
yield test_promiseBookmarksTreeAgainstResult();
// Do specify it
let rootGuid = yield PlacesUtils.promiseItemGuid(PlacesUtils.placesRootId);
yield test_promiseBookmarksTreeAgainstResult(rootGuid);
yield test_promiseBookmarksTreeAgainstResult(PlacesUtils.bookmarks.rootGuid);
// Exclude the bookmarks menu.
// The calllback should be four times - once for the toolbar, once for
@ -246,13 +241,13 @@ add_task(function* () {
// passed in.
let guidsPassedToExcludeCallback = new Set();
let placesRootWithoutTheMenu =
yield test_promiseBookmarksTreeAgainstResult(rootGuid, {
yield test_promiseBookmarksTreeAgainstResult(PlacesUtils.bookmarks.rootGuid, {
excludeItemsCallback: aItem => {
guidsPassedToExcludeCallback.add(aItem.guid);
return aItem.root == "bookmarksMenuFolder";
},
includeItemIds: true
}, [menuGuid]);
}, [PlacesUtils.bookmarks.menuGuid]);
do_check_eq(guidsPassedToExcludeCallback.size, 4);
do_check_eq(placesRootWithoutTheMenu.children.length, 2);
});