зеркало из https://github.com/mozilla/gecko-dev.git
Bug 824502 - Fix unit tests for the folder=<id> to parent=<guid> transition. r=mak
MozReview-Commit-ID: FCaiJrSAMAV --HG-- extra : rebase_source : 1edf169c3a24b1c0b8c1be2e8eb0f06e8605df80
This commit is contained in:
Родитель
d38ce76f52
Коммит
b321b832fd
|
@ -665,7 +665,7 @@ add_task(async function test_get_recent_with_tag_and_query() {
|
|||
PlacesUtils.tagging.tagURI(NetUtil.newURI("http://example.com/${i}"), ["Test Tag"]);
|
||||
|
||||
// Add a query bookmark.
|
||||
let queryURL = `place:folder=${PlacesUtils.bookmarksMenuFolderId}&queryType=1`;
|
||||
let queryURL = `place:parent=${PlacesUtils.bookmarks.menuGuid}&queryType=1`;
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: queryURL,
|
||||
|
|
|
@ -1824,7 +1824,7 @@ BrowserGlue.prototype = {
|
|||
// children, or if it has a persisted currentset value.
|
||||
let toolbarIsCustomized = xulStore.hasValue(BROWSER_DOCURL, "PersonalToolbar", "currentset");
|
||||
let getToolbarFolderCount = () => {
|
||||
let toolbarFolder = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
let toolbarFolder = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid).root;
|
||||
let toolbarChildCount = toolbarFolder.childCount;
|
||||
toolbarFolder.containerOpen = false;
|
||||
return toolbarChildCount;
|
||||
|
|
|
@ -23,7 +23,6 @@ add_task(async function() {
|
|||
title: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
});
|
||||
let folderId = await PlacesUtils.promiseItemId(folder.guid);
|
||||
tree.selectItems([folder.guid]);
|
||||
Assert.equal(tree.selectedNode.bookmarkGuid, folder.guid,
|
||||
"Selected the expected node");
|
||||
|
@ -35,7 +34,7 @@ add_task(async function() {
|
|||
let shortcut = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: root.guid,
|
||||
title: "bar",
|
||||
url: `place:folder=${folderId}`
|
||||
url: `place:parent=${folder.guid}`
|
||||
});
|
||||
tree.selectItems([shortcut.guid]);
|
||||
Assert.equal(tree.selectedNode.bookmarkGuid, shortcut.guid,
|
||||
|
@ -94,11 +93,10 @@ add_task(async function() {
|
|||
tree.selectItems([guid]);
|
||||
Assert.ok(!tree.controller.canMoveNode(tree.selectedNode),
|
||||
"shouldn't be able to move default shortcuts to roots");
|
||||
let id = await PlacesUtils.promiseItemId(guid);
|
||||
let s = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: root.guid,
|
||||
title: "bar",
|
||||
url: `place:folder=${id}`,
|
||||
url: `place:parent=${guid}`,
|
||||
});
|
||||
tree.selectItems([s.guid]);
|
||||
Assert.equal(tree.selectedNode.bookmarkGuid, s.guid,
|
||||
|
|
|
@ -124,7 +124,7 @@ add_task(async function test_try_move_root_in_sidebar() {
|
|||
"Should have copied the folder title.");
|
||||
Assert.equal(newFolder.type, PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
"Should have a bookmark type (for a folder shortcut).");
|
||||
Assert.equal(newFolder.url, "place:folder=BOOKMARKS_MENU",
|
||||
Assert.equal(newFolder.url, `place:parent=${PlacesUtils.bookmarks.menuGuid}`,
|
||||
"Should have the correct url for the folder shortcut.");
|
||||
});
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
/* test that copying a non movable query or folder shortcut makes a new query with the same url, not a deep copy */
|
||||
|
||||
const SHORTCUT_URL = "place:folder=2";
|
||||
const QUERY_URL = "place:sort=8&maxResults=10";
|
||||
|
||||
add_task(async function copy_toolbar_shortcut() {
|
||||
|
|
|
@ -75,7 +75,7 @@ add_task(async function() {
|
|||
// open recently bookmarked node
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
url: "place:folder=BOOKMARKS_MENU&folder=UNFILED_BOOKMARKS&folder=TOOLBAR" +
|
||||
url: "place:" + PlacesUtils.bookmarks.userContentRoots.map(guid => `parent=${guid}`).join("&") +
|
||||
"&queryType=" + Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
|
||||
"&sort=" + Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_DESCENDING +
|
||||
"&maxResults=10" +
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
parentGuid: bmu.toolbarGuid,
|
||||
index: bmu.DEFAULT_INDEX,
|
||||
type: bmu.TYPE_BOOKMARK,
|
||||
url: "place:folder=TOOLBAR",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`,
|
||||
title: "shortcut to self - causing infinite recursion if not handled properly"
|
||||
});
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
|||
parentGuid: bmu.toolbarGuid,
|
||||
index: bmu.DEFAULT_INDEX,
|
||||
type: bmu.TYPE_BOOKMARK,
|
||||
url: "place:folder=UNFILED_BOOKMARKS",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`,
|
||||
title: "shortcut to unfiled, within toolbar"
|
||||
});
|
||||
|
||||
|
@ -69,7 +69,7 @@
|
|||
|
||||
// Setup the places tree contents.
|
||||
let tree = document.getElementById("tree");
|
||||
tree.place = "place:folder=TOOLBAR";
|
||||
tree.place = `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`;
|
||||
|
||||
// Select the folder via the selectItems(folder.guid) API being tested
|
||||
tree.selectItems([folder.guid]);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
url: "place:folder=UNFILED_BOOKMARKS",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`,
|
||||
title: "shortcut"
|
||||
});
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
url: "place:folder=UNFILED_BOOKMARKS&maxResults=10",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.unfiledGuid}&maxResults=10`,
|
||||
title: "query"
|
||||
});
|
||||
|
||||
|
@ -73,7 +73,7 @@
|
|||
|
||||
// Setup the places tree contents.
|
||||
let tree = document.getElementById("tree");
|
||||
tree.place = "place:folder=UNFILED_BOOKMARKS";
|
||||
tree.place = `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`;
|
||||
|
||||
// Select the last bookmark.
|
||||
tree.selectItems([bm.guid]);
|
||||
|
|
|
@ -22,8 +22,8 @@ function run_test() {
|
|||
|
||||
registerCleanupFunction(() => PlacesUtils.bookmarks.eraseEverything());
|
||||
|
||||
function countFolderChildren(aFolderItemId) {
|
||||
let rootNode = PlacesUtils.getFolderContents(aFolderItemId).root;
|
||||
function countFolderChildren(aFolderGuid) {
|
||||
let rootNode = PlacesUtils.getFolderContents(aFolderGuid).root;
|
||||
let cc = rootNode.childCount;
|
||||
// Dump contents.
|
||||
for (let i = 0; i < cc ; i++) {
|
||||
|
@ -73,9 +73,9 @@ add_task(async function test_version_0() {
|
|||
await rebuildSmartBookmarks();
|
||||
|
||||
// Count items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Check version has been updated.
|
||||
|
@ -99,9 +99,9 @@ add_task(async function test_version_change() {
|
|||
Assert.equal(bm.title, "new title");
|
||||
|
||||
// Sanity check items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Set preferences.
|
||||
|
@ -110,9 +110,9 @@ add_task(async function test_version_change() {
|
|||
await rebuildSmartBookmarks();
|
||||
|
||||
// Count items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Check smart bookmark has been replaced, itemId has changed.
|
||||
|
@ -132,9 +132,9 @@ add_task(async function test_version_change_pos() {
|
|||
info("bookmarks position is retained when version changes.");
|
||||
|
||||
// Sanity check items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
let bm = await PlacesUtils.bookmarks.fetch({
|
||||
|
@ -150,9 +150,9 @@ add_task(async function test_version_change_pos() {
|
|||
await rebuildSmartBookmarks();
|
||||
|
||||
// Count items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Check smart bookmarks are still in correct position.
|
||||
|
@ -172,9 +172,9 @@ add_task(async function test_version_change_pos_moved() {
|
|||
info("moved bookmarks position is retained when version changes.");
|
||||
|
||||
// Sanity check items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
let bm1 = await PlacesUtils.bookmarks.fetch({
|
||||
|
@ -203,9 +203,9 @@ add_task(async function test_version_change_pos_moved() {
|
|||
await rebuildSmartBookmarks();
|
||||
|
||||
// Count items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
bm1 = await PlacesUtils.bookmarks.fetch({
|
||||
|
@ -238,9 +238,9 @@ add_task(async function test_recreation() {
|
|||
await PlacesUtils.bookmarks.remove(bm.guid);
|
||||
|
||||
// Sanity check items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Set preferences.
|
||||
|
@ -250,9 +250,9 @@ add_task(async function test_recreation() {
|
|||
|
||||
// Count items.
|
||||
// We should not have recreated the smart bookmark on toolbar.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Check version has been updated.
|
||||
|
@ -264,9 +264,9 @@ add_task(async function test_recreation_version_0() {
|
|||
info("Even if a smart bookmark has been removed recreate it if version is 0.");
|
||||
|
||||
// Sanity check items.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Set preferences.
|
||||
|
@ -276,9 +276,9 @@ add_task(async function test_recreation_version_0() {
|
|||
|
||||
// Count items.
|
||||
// We should not have recreated the smart bookmark on toolbar.
|
||||
Assert.equal(countFolderChildren(PlacesUtils.toolbarFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.toolbarGuid),
|
||||
SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarksMenuFolderId),
|
||||
Assert.equal(countFolderChildren(PlacesUtils.bookmarks.menuGuid),
|
||||
SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
|
||||
|
||||
// Check version has been updated.
|
||||
|
|
|
@ -65,7 +65,7 @@ var SelectBookmarkDialog = {
|
|||
var names = [];
|
||||
var selectedNode = bookmarks.selectedNode;
|
||||
if (PlacesUtils.nodeIsFolder(selectedNode)) {
|
||||
var contents = PlacesUtils.getFolderContents(selectedNode.itemId).root;
|
||||
var contents = PlacesUtils.getFolderContents(selectedNode.bookmarkGuid).root;
|
||||
var cc = contents.childCount;
|
||||
for (var i = 0; i < cc; ++i) {
|
||||
var node = contents.getChild(i);
|
||||
|
|
|
@ -1448,8 +1448,7 @@ PT.SortByName.prototype = {
|
|||
|
||||
// This is not great, since it does main-thread IO.
|
||||
// PromiseBookmarksTree can't be used, since it' won't stop at the first level'.
|
||||
let folderId = await PlacesUtils.promiseItemId(guid);
|
||||
let root = PlacesUtils.getFolderContents(folderId, false, false).root;
|
||||
let root = PlacesUtils.getFolderContents(guid, false, false).root;
|
||||
for (let i = 0; i < root.childCount; ++i) {
|
||||
let node = root.getChild(i);
|
||||
oldOrderGuids.push(node.bookmarkGuid);
|
||||
|
|
|
@ -857,7 +857,7 @@ var PlacesUtils = {
|
|||
if (PlacesUtils.nodeIsFolder(node) &&
|
||||
node.type != Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT &&
|
||||
asQuery(node).queryOptions.excludeItems) {
|
||||
let folderRoot = PlacesUtils.getFolderContents(node.itemId, false, true).root;
|
||||
let folderRoot = PlacesUtils.getFolderContents(node.bookmarkGuid, false, true).root;
|
||||
try {
|
||||
return gatherDataFunc(folderRoot);
|
||||
} finally {
|
||||
|
@ -1145,7 +1145,7 @@ var PlacesUtils = {
|
|||
|
||||
/**
|
||||
* Generates a nsINavHistoryResult for the contents of a folder.
|
||||
* @param folderId
|
||||
* @param aFolderGuid
|
||||
* The folder to open
|
||||
* @param [optional] excludeItems
|
||||
* True to hide all items (individual bookmarks). This is used on
|
||||
|
@ -1157,13 +1157,12 @@ var PlacesUtils = {
|
|||
* @returns A nsINavHistoryResult containing the contents of the
|
||||
* folder. The result.root is guaranteed to be open.
|
||||
*/
|
||||
getFolderContents:
|
||||
function PU_getFolderContents(aFolderId, aExcludeItems, aExpandQueries) {
|
||||
if (typeof aFolderId !== "number") {
|
||||
throw new Error("aFolderId should be a number.");
|
||||
getFolderContents(aFolderGuid, aExcludeItems, aExpandQueries) {
|
||||
if (!this.isValidGuid(aFolderGuid)) {
|
||||
throw new Error("aFolderGuid should be a valid GUID.");
|
||||
}
|
||||
var query = this.history.getNewQuery();
|
||||
query.setFolders([aFolderId], 1);
|
||||
query.setParents([aFolderGuid], 1);
|
||||
var options = this.history.getNewQueryOptions();
|
||||
options.excludeItems = aExcludeItems;
|
||||
options.expandQueries = aExpandQueries;
|
||||
|
|
|
@ -74,16 +74,12 @@ add_task(async function search_bookmark_in_folder() {
|
|||
|
||||
|
||||
// query folder 1, folder 2 and get 4 bookmarks
|
||||
let folderIds = [];
|
||||
folderIds.push(await PlacesUtils.promiseItemId(testFolder1.guid));
|
||||
folderIds.push(await PlacesUtils.promiseItemId(testFolder2.guid));
|
||||
|
||||
let hs = PlacesUtils.history;
|
||||
let options = hs.getNewQueryOptions();
|
||||
let query = hs.getNewQuery();
|
||||
query.searchTerms = "title";
|
||||
options.queryType = options.QUERY_TYPE_BOOKMARKS;
|
||||
query.setFolders(folderIds, folderIds.length);
|
||||
query.setParents([testFolder1.guid, testFolder2.guid], 2);
|
||||
let rootNode = hs.executeQuery(query, options).root;
|
||||
rootNode.containerOpen = true;
|
||||
|
||||
|
|
|
@ -66,9 +66,7 @@ add_task(async function search_bookmark_by_lastModified_dateDated() {
|
|||
let query = hs.getNewQuery();
|
||||
options.queryType = options.QUERY_TYPE_BOOKMARKS;
|
||||
options.maxResults = 3;
|
||||
let folderIds = [];
|
||||
folderIds.push(await PlacesUtils.promiseItemId(folder.guid));
|
||||
query.setFolders(folderIds, 1);
|
||||
query.setParents([folder.guid], 1);
|
||||
|
||||
let result = hs.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
|
|
|
@ -97,8 +97,7 @@ add_task(async function test_bookmark_update_notifications() {
|
|||
updatedBookmark.lastModified.getTime()));
|
||||
|
||||
// Check that node properties are updated.
|
||||
let testFolderId = await PlacesUtils.promiseItemId(testFolder.guid);
|
||||
let root = PlacesUtils.getFolderContents(testFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(testFolder.guid).root;
|
||||
Assert.equal(root.childCount, 1);
|
||||
let childNode = root.getChild(0);
|
||||
|
||||
|
|
|
@ -82,13 +82,7 @@ var test = {
|
|||
let insertedBookmarks = await PlacesUtils.bookmarks.insertTree(bookmarksTree);
|
||||
|
||||
// create a query URI with 1 folder (ie: folder shortcut)
|
||||
let folderIdsMap = await PlacesUtils.promiseManyItemIds(this._folderGuids);
|
||||
let folderIds = [];
|
||||
for (let id of folderIdsMap.values()) {
|
||||
folderIds.push(id);
|
||||
}
|
||||
|
||||
this._queryURI1 = `place:folder=${folderIdsMap.get(this._folderGuids[0])}&queryType=1`;
|
||||
this._queryURI1 = `place:parent=${this._folderGuids[0]}&queryType=1`;
|
||||
this._queryTitle1 = "query1";
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: insertedBookmarks[0].guid,
|
||||
|
@ -98,7 +92,7 @@ var test = {
|
|||
});
|
||||
|
||||
// create a query URI with _count folders
|
||||
this._queryURI2 = `place:folder=${folderIds.join("&folder=")}&queryType=1`;
|
||||
this._queryURI2 = `place:parent=${this._folderGuids.join("&parent=")}&queryType=1`;
|
||||
this._queryTitle2 = "query2";
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: insertedBookmarks[0].guid,
|
||||
|
@ -135,7 +129,7 @@ var test = {
|
|||
}
|
||||
|
||||
var toolbar =
|
||||
PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId,
|
||||
PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid,
|
||||
false, true).root;
|
||||
Assert.equal(toolbar.childCount, 1);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
const FOLDER_TITLE = '"quoted folder"';
|
||||
|
||||
function checkQuotedFolder() {
|
||||
let toolbar = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarFolder).root;
|
||||
let toolbar = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid).root;
|
||||
|
||||
// test for our quoted folder
|
||||
Assert.equal(toolbar.childCount, 1);
|
||||
|
|
|
@ -21,7 +21,7 @@ const ITEM_URL = "http://test.mozilla.org";
|
|||
|
||||
function validateResults(expectedValidItemsCount) {
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var options = PlacesUtils.history.getNewQueryOptions();
|
||||
var result = PlacesUtils.history.executeQuery(query, options);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ const ITEM_URL = "http://test.mozilla.org/";
|
|||
const TAG_NAME = "testTag";
|
||||
|
||||
function validateResults() {
|
||||
let toolbar = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
let toolbar = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid).root;
|
||||
// test for our bookmark
|
||||
Assert.equal(toolbar.childCount, 1);
|
||||
for (var i = 0; i < toolbar.childCount; i++) {
|
||||
|
@ -44,7 +44,7 @@ add_task(async function() {
|
|||
// create a tag
|
||||
PlacesUtils.tagging.tagURI(Services.io.newURI(ITEM_URL), [TAG_NAME]);
|
||||
// get tag folder id
|
||||
let tagRoot = PlacesUtils.getFolderContents(PlacesUtils.tagsFolderId).root;
|
||||
let tagRoot = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.tagsGuid).root;
|
||||
Assert.equal(tagRoot.childCount, 1);
|
||||
let tagItemGuid = PlacesUtils.asContainer(tagRoot.getChild(0)).bookmarkGuid;
|
||||
tagRoot.containerOpen = false;
|
||||
|
|
|
@ -42,7 +42,7 @@ add_task(async function compress_bookmark_backups_test() {
|
|||
let recentBackup = await PlacesBackups.getMostRecentBackup();
|
||||
await PlacesUtils.bookmarks.remove(bm);
|
||||
await BookmarkJSONUtils.importFromFile(recentBackup, { replace: true });
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
let node = root.getChild(0);
|
||||
Assert.equal(node.uri, url);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ add_task(async function() {
|
|||
{ replace: true });
|
||||
|
||||
info("Checking first level");
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
let level1 = root.getChild(0);
|
||||
Assert.equal(level1.title, "f1");
|
||||
info("Checking second level");
|
||||
|
|
|
@ -24,7 +24,7 @@ add_task(async function() {
|
|||
await BookmarkHTMLUtils.importFromFile(file, { replace: true });
|
||||
|
||||
info("Checking first level");
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
let node = root.getChild(0);
|
||||
Assert.equal(node.uri, url);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ add_task(async function getRecent_returns_recent_bookmarks() {
|
|||
});
|
||||
|
||||
// Add a query bookmark.
|
||||
let queryURL = `place:folder=${PlacesUtils.bookmarksMenuFolderId}&queryType=1`;
|
||||
let queryURL = `place:parent=${PlacesUtils.bookmarks.menuGuid}&queryType=1`;
|
||||
let bm5 = await PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: queryURL,
|
||||
title: "a test query" });
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
const searchTerm = "about";
|
||||
|
||||
var testRoot;
|
||||
var testRootId;
|
||||
|
||||
add_task(async function setup() {
|
||||
// create a folder to hold all the tests
|
||||
|
@ -19,7 +18,6 @@ add_task(async function setup() {
|
|||
title: searchTerm,
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
});
|
||||
testRootId = await PlacesUtils.promiseItemId(testRoot.guid);
|
||||
});
|
||||
|
||||
add_task(async function test_savedsearches_bookmarks() {
|
||||
|
@ -43,7 +41,7 @@ add_task(async function test_savedsearches_bookmarks() {
|
|||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
options.expandQueries = 0;
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([testRootId], 1);
|
||||
query.setParents([testRoot.guid], 1);
|
||||
let result = PlacesUtils.history.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
@ -69,7 +67,7 @@ add_task(async function test_savedsearches_bookmarks() {
|
|||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
options.expandQueries = 1;
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([testRootId], 1);
|
||||
query.setParents([testRoot.guid], 1);
|
||||
let result = PlacesUtils.history.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
@ -145,7 +143,7 @@ add_task(async function test_savedsearches_history() {
|
|||
var options = PlacesUtils.history.getNewQueryOptions();
|
||||
options.expandQueries = 1;
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([testRootId], 1);
|
||||
query.setParents([testRoot.guid], 1);
|
||||
var result = PlacesUtils.history.executeQuery(query, options);
|
||||
var rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
|
|
@ -10,7 +10,7 @@ add_task(async function test_untitled_visited_bookmark() {
|
|||
}],
|
||||
});
|
||||
|
||||
let {root: node} = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId);
|
||||
let {root: node} = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid);
|
||||
|
||||
try {
|
||||
let fxBmk = await PlacesUtils.bookmarks.insert({
|
||||
|
@ -39,7 +39,7 @@ add_task(async function test_untitled_visited_bookmark() {
|
|||
add_task(async function test_untitled_unvisited_bookmark() {
|
||||
let tbURI = uri("http://getthunderbird.com");
|
||||
|
||||
let {root: node} = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId);
|
||||
let {root: node} = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid);
|
||||
|
||||
try {
|
||||
let tbBmk = await PlacesUtils.bookmarks.insert({
|
||||
|
@ -66,7 +66,7 @@ add_task(async function test_untitled_unvisited_bookmark() {
|
|||
});
|
||||
|
||||
add_task(async function test_untitled_folder() {
|
||||
let {root: node} = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId);
|
||||
let {root: node} = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid);
|
||||
|
||||
try {
|
||||
let folder = await PlacesUtils.bookmarks.insert({
|
||||
|
|
|
@ -55,7 +55,7 @@ function promiseOnItemChanged() {
|
|||
});
|
||||
|
||||
// query for bookmarks
|
||||
let rootNode = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
let rootNode = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid).root;
|
||||
|
||||
// set up observer
|
||||
let promiseObserved = promiseOnItemChanged();
|
||||
|
|
|
@ -16,8 +16,8 @@ add_task(async function test_query_result_favicon_changed_on_child() {
|
|||
|
||||
// Get the last 10 bookmarks added to the menu or the toolbar.
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarksMenuFolderId,
|
||||
PlacesUtils.toolbarFolderId], 2);
|
||||
query.setParents([PlacesUtils.bookmarks.menuGuid,
|
||||
PlacesUtils.bookmarks.toolbarGuid], 2);
|
||||
|
||||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
|
||||
|
@ -80,7 +80,7 @@ add_task(async function test_query_result_favicon_changed_not_affect_lastmodifie
|
|||
url: PAGE_URI2
|
||||
});
|
||||
|
||||
let result = PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId);
|
||||
let result = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.menuGuid);
|
||||
|
||||
Assert.equal(result.root.childCount, 1,
|
||||
"Should have only one item in the query");
|
||||
|
|
|
@ -107,6 +107,7 @@ add_task(async function test_bookmarks() {
|
|||
// this makes the tests more tolerant of changes to default_places.html
|
||||
let testRoot = bs.createFolder(root, "places bookmarks xpcshell tests",
|
||||
bs.DEFAULT_INDEX);
|
||||
let testRootGuid = await PlacesUtils.promiseItemGuid(testRoot);
|
||||
Assert.equal(bookmarksObserver._itemAddedId, testRoot);
|
||||
Assert.equal(bookmarksObserver._itemAddedParent, root);
|
||||
Assert.equal(bookmarksObserver._itemAddedIndex, bmStartIndex);
|
||||
|
@ -249,7 +250,7 @@ add_task(async function test_bookmarks() {
|
|||
try {
|
||||
let options = hs.getNewQueryOptions();
|
||||
let query = hs.getNewQuery();
|
||||
query.setFolders([testRoot], 1);
|
||||
query.setParents([testRootGuid], 1);
|
||||
let result = hs.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
@ -279,6 +280,7 @@ add_task(async function test_bookmarks() {
|
|||
let mURI = uri("http://multiple.uris.in.query");
|
||||
|
||||
let testFolder = bs.createFolder(testRoot, "test Folder", bs.DEFAULT_INDEX);
|
||||
let testFolderGuid = await PlacesUtils.promiseItemGuid(testFolder);
|
||||
// add 2 bookmarks
|
||||
bs.insertBookmark(testFolder, mURI, bs.DEFAULT_INDEX, "title 1");
|
||||
bs.insertBookmark(testFolder, mURI, bs.DEFAULT_INDEX, "title 2");
|
||||
|
@ -286,7 +288,7 @@ add_task(async function test_bookmarks() {
|
|||
// query
|
||||
let options = hs.getNewQueryOptions();
|
||||
let query = hs.getNewQuery();
|
||||
query.setFolders([testFolder], 1);
|
||||
query.setParents([testFolderGuid], 1);
|
||||
let result = hs.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
@ -383,7 +385,7 @@ add_task(async function test_bookmarks() {
|
|||
try {
|
||||
let options = hs.getNewQueryOptions();
|
||||
let query = hs.getNewQuery();
|
||||
query.setFolders([testRoot], 1);
|
||||
query.setParents([testRootGuid], 1);
|
||||
let result = hs.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
@ -441,10 +443,10 @@ add_task(async function test_bookmarks() {
|
|||
Assert.equal(bookmarksObserver._itemChangedProperty, "title");
|
||||
Assert.equal(bookmarksObserver._itemChangedValue, title15expected);
|
||||
|
||||
testSimpleFolderResult();
|
||||
await testSimpleFolderResult();
|
||||
});
|
||||
|
||||
function testSimpleFolderResult() {
|
||||
async function testSimpleFolderResult() {
|
||||
// the time before we create a folder, in microseconds
|
||||
// Workaround possible VM timers issues subtracting 1us.
|
||||
let beforeCreate = Date.now() * 1000 - 1;
|
||||
|
@ -452,6 +454,7 @@ function testSimpleFolderResult() {
|
|||
|
||||
// create a folder
|
||||
let parent = bs.createFolder(root, "test", bs.DEFAULT_INDEX);
|
||||
let parentGuid = await PlacesUtils.promiseItemGuid(parent);
|
||||
|
||||
// the time before we insert, in microseconds
|
||||
// Workaround possible VM timers issues subtracting 1ms.
|
||||
|
@ -473,7 +476,7 @@ function testSimpleFolderResult() {
|
|||
|
||||
let options = hs.getNewQueryOptions();
|
||||
let query = hs.getNewQuery();
|
||||
query.setFolders([parent], 1);
|
||||
query.setParents([parentGuid], 1);
|
||||
let result = hs.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
@ -506,20 +509,3 @@ function testSimpleFolderResult() {
|
|||
|
||||
rootNode.containerOpen = false;
|
||||
}
|
||||
|
||||
function getChildCount(aFolderId) {
|
||||
let cc = -1;
|
||||
try {
|
||||
let options = hs.getNewQueryOptions();
|
||||
let query = hs.getNewQuery();
|
||||
query.setFolders([aFolderId], 1);
|
||||
let result = hs.executeQuery(query, options);
|
||||
let rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
cc = rootNode.childCount;
|
||||
rootNode.containerOpen = false;
|
||||
} catch (ex) {
|
||||
do_throw("getChildCount failed: " + ex);
|
||||
}
|
||||
return cc;
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ Test.prototype = {
|
|||
|
||||
// Make a query.
|
||||
this.query = PlacesUtils.history.getNewQuery();
|
||||
this.query.setFolders([DataHelper.defaults.bookmark.parent], 1);
|
||||
this.query.setParents([DataHelper.defaults.bookmark.parentGuid], 1);
|
||||
this.opts = PlacesUtils.history.getNewQueryOptions();
|
||||
this.opts.asyncEnabled = true;
|
||||
this.result = PlacesUtils.history.executeQuery(this.query, this.opts);
|
||||
|
@ -265,20 +265,17 @@ Test.prototype = {
|
|||
var DataHelper = {
|
||||
defaults: {
|
||||
bookmark: {
|
||||
parent: PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
uri: "http://example.com/",
|
||||
title: "test bookmark"
|
||||
},
|
||||
|
||||
folder: {
|
||||
parent: PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
title: "test folder"
|
||||
},
|
||||
|
||||
separator: {
|
||||
parent: PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid
|
||||
}
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ add_task(async function test_eraseEverything() {
|
|||
]
|
||||
});
|
||||
|
||||
let unfiled = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
let unfiled = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
Assert.equal(unfiled.childCount, 1, "There should be 1 folder");
|
||||
let folder = unfiled.getChild(0);
|
||||
// Test dateAdded and lastModified properties.
|
||||
|
@ -28,7 +28,7 @@ add_task(async function test_eraseEverything() {
|
|||
Assert.equal(typeof folder.lastModified, "number");
|
||||
Assert.ok(folder.lastModified > 0);
|
||||
|
||||
let root = PlacesUtils.getFolderContents(folder.itemId).root;
|
||||
let root = PlacesUtils.getFolderContents(folder.bookmarkGuid).root;
|
||||
Assert.equal(root.childCount, 4, "The folder should have 4 children");
|
||||
for (let i = 0; i < root.childCount; ++i) {
|
||||
let node = root.getChild(i);
|
||||
|
@ -77,7 +77,7 @@ add_task(async function test_long_title() {
|
|||
url: "http://mozilla.org/",
|
||||
title,
|
||||
});
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
root.containerOpen = true;
|
||||
Assert.equal(root.childCount, 1);
|
||||
let node = root.getChild(0);
|
||||
|
|
|
@ -22,7 +22,7 @@ add_task(async function setup() {
|
|||
});
|
||||
folderShortcut = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "place:folder=TOOLBAR",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`,
|
||||
title: "a bookmark"
|
||||
});
|
||||
|
||||
|
@ -58,7 +58,7 @@ add_task(async function test_bookmarks_excludeQueries() {
|
|||
// When excluding queries, we exclude actual queries, but not folder shortcuts.
|
||||
let expectedGuids = [bm.guid, folderShortcut.guid];
|
||||
let query = {}, options = {};
|
||||
let queryString = `place:folder=${PlacesUtils.unfiledBookmarksFolderId}&excludeQueries=1`;
|
||||
let queryString = `place:parent=${PlacesUtils.bookmarks.unfiledGuid}&excludeQueries=1`;
|
||||
PlacesUtils.history.queryStringToQuery(queryString, query, options);
|
||||
|
||||
let root = PlacesUtils.history.executeQuery(query.value, options.value).root;
|
||||
|
|
|
@ -95,7 +95,7 @@ add_task(function visits_query() {
|
|||
|
||||
add_task(function bookmarks_query() {
|
||||
let [query, options] = newQueryWithOptions();
|
||||
query.setFolders([PlacesUtils.unfiledBookmarksFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.unfiledGuid], 1);
|
||||
testQueryContents(query, options, function(root) {
|
||||
compareArrayToResult([gTestData[0], gTestData[1], gTestData[2]], root);
|
||||
for (let i = 0; i < root.childCount; i++) {
|
||||
|
|
|
@ -47,7 +47,7 @@ add_task(async function test_onlyBookmarked() {
|
|||
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
|
|
@ -45,7 +45,7 @@ add_task(async function() {
|
|||
|
||||
async function test_query(opts, expectedRootCc, expectedFolderCc, expectedQueryCc) {
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.unfiledBookmarksFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.unfiledGuid], 1);
|
||||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
for (const [o, v] of Object.entries(opts)) {
|
||||
info(`Setting ${o} to ${v}`);
|
||||
|
|
|
@ -16,11 +16,10 @@ add_task(async function setup() {
|
|||
title: `Folder${i}`
|
||||
});
|
||||
folderGuids.push(folder.guid);
|
||||
folderIds.push(await PlacesUtils.promiseItemId(folder.guid));
|
||||
|
||||
for (let j = 0; j < 7; ++j) {
|
||||
let bm = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: (await PlacesUtils.promiseItemGuid(folderIds[i])),
|
||||
parentGuid: folderGuids[i],
|
||||
url: `http://Bookmark${i}_${j}.com`,
|
||||
title: ""
|
||||
});
|
||||
|
@ -33,7 +32,7 @@ add_task(async function test_queryMultipleFolders_ids() {
|
|||
// using queryStringToQuery
|
||||
let query = {}, options = {};
|
||||
let maxResults = 20;
|
||||
let queryString = `place:${folderIds.map((id) => "folder=" + id).join("&")}&sort=5&maxResults=${maxResults}`;
|
||||
let queryString = `place:${folderGuids.map(guid => "parent=" + guid).join("&")}&sort=5&maxResults=${maxResults}`;
|
||||
PlacesUtils.history.queryStringToQuery(queryString, query, options);
|
||||
let rootNode = PlacesUtils.history.executeQuery(query.value, options.value).root;
|
||||
rootNode.containerOpen = true;
|
||||
|
@ -48,7 +47,7 @@ add_task(async function test_queryMultipleFolders_ids() {
|
|||
// using getNewQuery and getNewQueryOptions
|
||||
query = PlacesUtils.history.getNewQuery();
|
||||
options = PlacesUtils.history.getNewQueryOptions();
|
||||
query.setFolders(folderIds, folderIds.length);
|
||||
query.setParents(folderGuids, folderGuids.length);
|
||||
options.sortingMode = options.SORT_BY_URI_ASCENDING;
|
||||
options.maxResults = maxResults;
|
||||
rootNode = PlacesUtils.history.executeQuery(query, options).root;
|
||||
|
|
|
@ -213,31 +213,32 @@ const querySwitches = [
|
|||
},
|
||||
// getFolders
|
||||
{
|
||||
desc: "nsINavHistoryQuery.getFolders",
|
||||
desc: "nsINavHistoryQuery.getParents",
|
||||
matches(aQuery1, aQuery2) {
|
||||
var q1Folders = aQuery1.getFolders();
|
||||
var q2Folders = aQuery2.getFolders();
|
||||
if (q1Folders.length !== q2Folders.length)
|
||||
var q1Parents = aQuery1.getParents();
|
||||
var q2Parents = aQuery2.getParents();
|
||||
if (q1Parents.length !== q2Parents.length)
|
||||
return false;
|
||||
for (let i = 0; i < q1Folders.length; i++) {
|
||||
if (!q2Folders.includes(q1Folders[i]))
|
||||
for (let i = 0; i < q1Parents.length; i++) {
|
||||
if (!q2Parents.includes(q1Parents[i]))
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < q2Folders.length; i++) {
|
||||
if (!q1Folders.includes(q2Folders[i]))
|
||||
for (let i = 0; i < q2Parents.length; i++) {
|
||||
if (!q1Parents.includes(q2Parents[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
runs: [
|
||||
function(aQuery, aQueryOptions) {
|
||||
aQuery.setFolders([], 0);
|
||||
aQuery.setParents([], 0);
|
||||
},
|
||||
function(aQuery, aQueryOptions) {
|
||||
aQuery.setFolders([PlacesUtils.placesRootId], 1);
|
||||
aQuery.setParents([PlacesUtils.bookmarks.rootGuid], 1);
|
||||
},
|
||||
function(aQuery, aQueryOptions) {
|
||||
aQuery.setFolders([PlacesUtils.placesRootId, PlacesUtils.tagsFolderId], 2);
|
||||
aQuery.setParents([PlacesUtils.bookmarks.rootGuid,
|
||||
PlacesUtils.bookmarks.tagsGuid], 2);
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ add_task(async function test_results_as_tag_query() {
|
|||
]
|
||||
});
|
||||
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId, false, true).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid, false, true).root;
|
||||
Assert.equal(root.childCount, 3, "We should get 3 results");
|
||||
let queryRoot = root.getChild(2);
|
||||
PlacesUtils.asContainer(queryRoot).containerOpen = true;
|
||||
|
|
|
@ -4,21 +4,21 @@ const MOBILE_BOOKMARKS_PREF = "browser.bookmarks.showMobileBookmarks";
|
|||
|
||||
const expectedRoots = [{
|
||||
title: "BookmarksToolbarFolderTitle",
|
||||
uri: "place:folder=TOOLBAR",
|
||||
uri: `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`,
|
||||
guid: PlacesUtils.bookmarks.virtualToolbarGuid,
|
||||
}, {
|
||||
title: "BookmarksMenuFolderTitle",
|
||||
uri: "place:folder=BOOKMARKS_MENU",
|
||||
uri: `place:parent=${PlacesUtils.bookmarks.menuGuid}`,
|
||||
guid: PlacesUtils.bookmarks.virtualMenuGuid,
|
||||
}, {
|
||||
title: "OtherBookmarksFolderTitle",
|
||||
uri: "place:folder=UNFILED_BOOKMARKS",
|
||||
uri: `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`,
|
||||
guid: PlacesUtils.bookmarks.virtualUnfiledGuid,
|
||||
}];
|
||||
|
||||
const expectedRootsWithMobile = [...expectedRoots, {
|
||||
title: "MobileBookmarksFolderTitle",
|
||||
uri: "place:folder=MOBILE_BOOKMARKS",
|
||||
uri: `place:parent=${PlacesUtils.bookmarks.mobileGuid}`,
|
||||
guid: PlacesUtils.bookmarks.virtualMobileGuid,
|
||||
}];
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ add_task(async function test_search_for_tagged_bookmarks() {
|
|||
query.searchTerms = "elephant";
|
||||
var options = PlacesUtils.history.getNewQueryOptions();
|
||||
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
|
||||
query.setFolders([folder], 1);
|
||||
query.setParents([folder.guid], 1);
|
||||
|
||||
var result = PlacesUtils.history.executeQuery(query, options);
|
||||
var rootNode = result.root;
|
||||
|
|
|
@ -44,7 +44,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
@ -115,7 +115,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
@ -213,7 +213,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
@ -318,7 +318,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
|
||||
// query options
|
||||
var options = PlacesUtils.history.getNewQueryOptions();
|
||||
|
@ -416,7 +416,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
@ -504,7 +504,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
@ -600,7 +600,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
@ -698,7 +698,7 @@ tests.push({
|
|||
check() {
|
||||
// Query
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
query.onlyBookmarked = true;
|
||||
|
||||
// query options
|
||||
|
|
|
@ -970,7 +970,7 @@ add_task(async function test_rewrite_tag_queries() {
|
|||
"Should retain existing tag");
|
||||
|
||||
let { root: toolbarContainer } = PlacesUtils.getFolderContents(
|
||||
PlacesUtils.toolbarFolderId, false, true);
|
||||
PlacesUtils.bookmarks.toolbarGuid, false, true);
|
||||
equal(toolbarContainer.childCount, 3,
|
||||
"Should add queries and bookmark to toolbar");
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ add_task(async function() {
|
|||
// have the extra bookmark properties (bookmarkGuid, dateAdded, lastModified).
|
||||
|
||||
// getFolderContents opens the root node.
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid).root;
|
||||
|
||||
async function insertAndTest(bmInfo) {
|
||||
bmInfo = await PlacesUtils.bookmarks.insert(bmInfo);
|
||||
|
@ -23,7 +23,7 @@ add_task(async function() {
|
|||
await insertAndTest({ parentGuid: root.bookmarkGuid,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
title: "Test Query",
|
||||
url: "place:folder=BOOKMARKS_MENU" });
|
||||
url: `place:parent=${PlacesUtils.bookmarks.menuGuid}` });
|
||||
|
||||
// folder
|
||||
await insertAndTest({ parentGuid: root.bookmarkGuid,
|
||||
|
|
|
@ -7,16 +7,14 @@ add_task(async function() {
|
|||
title: "fake"
|
||||
});
|
||||
|
||||
let folderId = await PlacesUtils.promiseItemId(folder.guid);
|
||||
|
||||
let shortcutInfo = await PlacesUtils.bookmarks.insert({
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: `place:folder=${folderId}`
|
||||
url: `place:parent=${folder.guid}`
|
||||
});
|
||||
|
||||
let unfiledRoot =
|
||||
PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
let shortcutNode = unfiledRoot.getChild(unfiledRoot.childCount - 1);
|
||||
Assert.equal(shortcutNode.bookmarkGuid, shortcutInfo.guid);
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ add_task(async function test_folder_shortcuts() {
|
|||
let shortcutInfo = await PlacesUtils.bookmarks.insert({
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "place:folder=TOOLBAR"
|
||||
url: `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`
|
||||
});
|
||||
|
||||
let unfiledRoot =
|
||||
PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
let shortcutNode = unfiledRoot.getChild(unfiledRoot.childCount - 1);
|
||||
Assert.strictEqual(shortcutNode.itemId,
|
||||
await PlacesUtils.promiseItemId(shortcutInfo.guid));
|
||||
|
@ -20,7 +20,7 @@ add_task(async function test_folder_shortcuts() {
|
|||
shortcutInfo = await PlacesUtils.bookmarks.insert({
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "place:folder=BOOKMARKS_MENU"
|
||||
url: `place:parent=${PlacesUtils.bookmarks.menuGuid}`
|
||||
});
|
||||
shortcutNode = unfiledRoot.getChild(unfiledRoot.childCount - 1);
|
||||
Assert.strictEqual(shortcutNode.itemId,
|
||||
|
@ -41,7 +41,7 @@ add_task(async function test_plain_folder() {
|
|||
});
|
||||
|
||||
let unfiledRoot =
|
||||
PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
let lastChild = unfiledRoot.getChild(unfiledRoot.childCount - 1);
|
||||
Assert.strictEqual(lastChild.bookmarkGuid, folderInfo.guid);
|
||||
Assert.strictEqual(PlacesUtils.asQuery(lastChild).targetFolderGuid,
|
||||
|
|
|
@ -40,8 +40,6 @@ add_task(async function test_hierarchical_query() {
|
|||
|
||||
let [folderGuid, b1, sf1, b2, sf2, b3] = bookmarks.map((bookmark) => bookmark.guid);
|
||||
|
||||
let testFolderId = await PlacesUtils.promiseItemId(folderGuid);
|
||||
|
||||
// bookmark query that should result in the "hierarchical" result
|
||||
// because there is one query, one folder,
|
||||
// no begin time, no end time, no domain, no uri, no search term
|
||||
|
@ -50,7 +48,7 @@ add_task(async function test_hierarchical_query() {
|
|||
var options = histsvc.getNewQueryOptions();
|
||||
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
|
||||
var query = histsvc.getNewQuery();
|
||||
query.setFolders([testFolderId], 1);
|
||||
query.setParents([folderGuid], 1);
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
@ -83,7 +81,7 @@ add_task(async function test_hierarchical_query() {
|
|||
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
|
||||
options.maxResults = 10;
|
||||
query = histsvc.getNewQuery();
|
||||
query.setFolders([testFolderId], 1);
|
||||
query.setParents([folderGuid], 1);
|
||||
result = histsvc.executeQuery(query, options);
|
||||
root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
|
|
@ -80,7 +80,7 @@ async function validate(infoMsg) {
|
|||
// Tests a bookmarks datastore that has a set of bookmarks, etc
|
||||
// that flex each supported field and feature.
|
||||
async function testMenuBookmarks() {
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.menuGuid).root;
|
||||
Assert.equal(root.childCount, 3);
|
||||
|
||||
let separatorNode = root.getChild(1);
|
||||
|
@ -124,7 +124,7 @@ async function testMenuBookmarks() {
|
|||
}
|
||||
|
||||
async function testToolbarBookmarks() {
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid).root;
|
||||
|
||||
// child count (add 3 for pre-existing items)
|
||||
Assert.equal(root.childCount, bookmarkData.length + 3);
|
||||
|
@ -158,7 +158,7 @@ async function testToolbarBookmarks() {
|
|||
}
|
||||
|
||||
function testUnfiledBookmarks() {
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
// child count (add 1 for pre-existing item)
|
||||
Assert.equal(root.childCount, bookmarkData.length + 1);
|
||||
for (let i = 1; i < root.childCount; ++i) {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
/**
|
||||
* Obtains the id of the folder obtained from the query.
|
||||
*
|
||||
* @param aFolderID
|
||||
* The id of the folder we want to generate a query for.
|
||||
* @returns the string representation of the query for the given folder.
|
||||
*/
|
||||
function query_string(aFolderID) {
|
||||
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
var query = hs.getNewQuery();
|
||||
query.setFolders([aFolderID], 1);
|
||||
var options = hs.getNewQueryOptions();
|
||||
return hs.queryToQueryString(query, options);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
const QUERIES = [
|
||||
"folder=PLACES_ROOT",
|
||||
"folder=BOOKMARKS_MENU",
|
||||
"folder=TAGS",
|
||||
"folder=UNFILED_BOOKMARKS",
|
||||
"folder=TOOLBAR"
|
||||
];
|
||||
const FOLDER_IDS = [
|
||||
PlacesUtils.placesRootId,
|
||||
PlacesUtils.bookmarksMenuFolderId,
|
||||
PlacesUtils.tagsFolderId,
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.toolbarFolderId,
|
||||
];
|
||||
|
||||
for (var i = 0; i < QUERIES.length; i++) {
|
||||
var result = query_string(FOLDER_IDS[i]);
|
||||
dump("Looking for '" + QUERIES[i] + "' in '" + result + "'\n");
|
||||
Assert.notEqual(-1, result.indexOf(QUERIES[i]));
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
/**
|
||||
* Obtains the id of the folder obtained from the query.
|
||||
*
|
||||
* @param aQuery
|
||||
* The query to obtain the folder id from.
|
||||
* @returns the folder id of the folder of the root node of the query.
|
||||
*/
|
||||
function folder_id(aQuery) {
|
||||
info("Checking query '" + aQuery + "'\n");
|
||||
let query = {}, options = {};
|
||||
PlacesUtils.history.queryStringToQuery(aQuery, query, options);
|
||||
var result = PlacesUtils.history.executeQuery(query.value, options.value);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
Assert.ok(root.hasChildren);
|
||||
var folderID = root.getChild(0).parent.itemId;
|
||||
root.containerOpen = false;
|
||||
return folderID;
|
||||
}
|
||||
|
||||
add_task(async function test_history_string_to_query() {
|
||||
const QUERIES = [
|
||||
"place:folder=PLACES_ROOT",
|
||||
"place:folder=BOOKMARKS_MENU",
|
||||
"place:folder=TAGS",
|
||||
"place:folder=UNFILED_BOOKMARKS",
|
||||
"place:folder=TOOLBAR"
|
||||
];
|
||||
const FOLDER_IDS = [
|
||||
PlacesUtils.placesRootId,
|
||||
PlacesUtils.bookmarksMenuFolderId,
|
||||
PlacesUtils.tagsFolderId,
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.toolbarFolderId,
|
||||
];
|
||||
|
||||
// add something in the bookmarks menu folder so a query to it returns results
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
title: "bmf",
|
||||
url: "http://example.com/bmf/",
|
||||
});
|
||||
|
||||
// add something to the tags folder
|
||||
PlacesUtils.tagging.tagURI(uri("http://www.example.com/"), ["tag"]);
|
||||
|
||||
// add something to the unfiled bookmarks folder
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
title: "ubf",
|
||||
url: "http://example.com/ubf/",
|
||||
});
|
||||
|
||||
// add something to the toolbar folder
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
title: "tf",
|
||||
url: "http://example.com/tf/",
|
||||
});
|
||||
|
||||
for (let i = 0; i < QUERIES.length; i++) {
|
||||
let result = folder_id(QUERIES[i]);
|
||||
Assert.equal(FOLDER_IDS[i], result);
|
||||
}
|
||||
});
|
|
@ -14,7 +14,7 @@ add_task(async function test_query_node_tags_property() {
|
|||
// get toolbar node
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
var query = histsvc.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var toolbarNode = result.root;
|
||||
toolbarNode.containerOpen = true;
|
||||
|
|
|
@ -21,15 +21,13 @@ add_task(async function test_query_with_remove_shortcut() {
|
|||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
});
|
||||
|
||||
let folderId = await PlacesUtils.promiseItemId(folder.guid);
|
||||
|
||||
let query = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
title: "",
|
||||
url: `place:folder=${folderId}`,
|
||||
url: `place:parent=${folder.guid}`,
|
||||
});
|
||||
|
||||
var root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId, false, true).root;
|
||||
var root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid, false, true).root;
|
||||
|
||||
var oldCount = root.childCount;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ add_task(async function test_query_title_update() {
|
|||
// query for that query
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
let query = histsvc.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
|
|
@ -39,7 +39,7 @@ add_task(async function test_execute() {
|
|||
// query for that query
|
||||
options = histsvc.getNewQueryOptions();
|
||||
query = histsvc.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
result = histsvc.executeQuery(query, options);
|
||||
root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
|
|
@ -1538,8 +1538,7 @@ add_task(async function test_sort_folder_by_name() {
|
|||
}
|
||||
});
|
||||
|
||||
let folderId = await PlacesUtils.promiseItemId(folder_info.guid);
|
||||
let folderContainer = PlacesUtils.getFolderContents(folderId).root;
|
||||
let folderContainer = PlacesUtils.getFolderContents(folder_info.guid).root;
|
||||
function ensureOrder(aOrder) {
|
||||
for (let i = 0; i < folderContainer.childCount; i++) {
|
||||
Assert.equal(folderContainer.getChild(i).bookmarkGuid, aOrder[i].guid);
|
||||
|
|
|
@ -267,18 +267,7 @@ async function testImportedBookmarks() {
|
|||
for (let group in test_bookmarks) {
|
||||
info("[testImportedBookmarks()] Checking group '" + group + "'");
|
||||
|
||||
let root;
|
||||
switch (group) {
|
||||
case "menu":
|
||||
root = PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId).root;
|
||||
break;
|
||||
case "toolbar":
|
||||
root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
break;
|
||||
case "unfiled":
|
||||
root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
break;
|
||||
}
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks[`${group}Guid`]).root;
|
||||
|
||||
let items = test_bookmarks[group];
|
||||
Assert.equal(root.childCount, items.length);
|
||||
|
|
|
@ -53,7 +53,7 @@ add_task(async function test_corrupt_database() {
|
|||
*/
|
||||
var database_check = async function() {
|
||||
// BOOKMARKS MENU
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.menuGuid).root;
|
||||
Assert.equal(root.childCount, 2);
|
||||
|
||||
let folderNode = root.getChild(1);
|
||||
|
@ -99,7 +99,7 @@ var database_check = async function() {
|
|||
root.containerOpen = false;
|
||||
|
||||
// BOOKMARKS TOOLBAR
|
||||
root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.toolbarGuid).root;
|
||||
Assert.equal(root.childCount, 3);
|
||||
|
||||
// For now some promises are resolved later, so we can't guarantee an order.
|
||||
|
@ -123,7 +123,7 @@ var database_check = async function() {
|
|||
root.containerOpen = false;
|
||||
|
||||
// UNFILED BOOKMARKS
|
||||
root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid).root;
|
||||
Assert.equal(root.childCount, 1);
|
||||
root.containerOpen = false;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ add_task(async function test_bookmarks_html_singleframe() {
|
|||
let bookmarksFile = OS.Path.join(do_get_cwd().path, "bookmarks_html_singleframe.html");
|
||||
await BookmarkHTMLUtils.importFromFile(bookmarksFile, { replace: true });
|
||||
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId).root;
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks.menuGuid).root;
|
||||
Assert.equal(root.childCount, 1);
|
||||
let folder = root.getChild(0);
|
||||
PlacesUtils.asContainer(folder).containerOpen = true;
|
||||
|
|
|
@ -138,21 +138,7 @@ async function testImportedBookmarks() {
|
|||
for (let group in test_bookmarks) {
|
||||
info("[testImportedBookmarks()] Checking group '" + group + "'");
|
||||
|
||||
let root;
|
||||
switch (group) {
|
||||
case "menu":
|
||||
root =
|
||||
PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId).root;
|
||||
break;
|
||||
case "toolbar":
|
||||
root =
|
||||
PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
|
||||
break;
|
||||
case "unfiled":
|
||||
root =
|
||||
PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
break;
|
||||
}
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarks[`${group}Guid`]).root;
|
||||
|
||||
let items = test_bookmarks[group];
|
||||
Assert.equal(root.childCount, items.length);
|
||||
|
|
|
@ -8,10 +8,10 @@ add_task(async function test_brokenFolderShortcut() {
|
|||
url: "http://1.moz.org/",
|
||||
title: "Bookmark 1",
|
||||
}, {
|
||||
url: "place:folder=1234",
|
||||
url: "place:parent=1234",
|
||||
title: "Shortcut 1",
|
||||
}, {
|
||||
url: "place:folder=-1",
|
||||
url: "place:parent=-1",
|
||||
title: "Shortcut 2",
|
||||
}, {
|
||||
url: "http://2.moz.org/",
|
||||
|
@ -24,7 +24,7 @@ add_task(async function test_brokenFolderShortcut() {
|
|||
|
||||
// Query containing a broken folder shortcuts among results.
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.unfiledBookmarksFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.unfiledGuid], 1);
|
||||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
let root = PlacesUtils.history.executeQuery(query, options).root;
|
||||
root.containerOpen = true;
|
||||
|
@ -32,7 +32,7 @@ add_task(async function test_brokenFolderShortcut() {
|
|||
Assert.equal(root.childCount, 4);
|
||||
|
||||
let shortcut = root.getChild(1);
|
||||
Assert.equal(shortcut.uri, "place:folder=1234");
|
||||
Assert.equal(shortcut.uri, "place:parent=1234");
|
||||
PlacesUtils.asContainer(shortcut);
|
||||
shortcut.containerOpen = true;
|
||||
Assert.equal(shortcut.childCount, 0);
|
||||
|
@ -42,7 +42,7 @@ add_task(async function test_brokenFolderShortcut() {
|
|||
Assert.equal(root.childCount, 3);
|
||||
|
||||
shortcut = root.getChild(1);
|
||||
Assert.equal(shortcut.uri, "place:folder=-1");
|
||||
Assert.equal(shortcut.uri, "place:parent=-1");
|
||||
PlacesUtils.asContainer(shortcut);
|
||||
shortcut.containerOpen = true;
|
||||
Assert.equal(shortcut.childCount, 0);
|
||||
|
@ -55,7 +55,7 @@ add_task(async function test_brokenFolderShortcut() {
|
|||
|
||||
// Broken folder shortcut as root node.
|
||||
query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([1234], 1);
|
||||
query.setParents([1234], 1);
|
||||
options = PlacesUtils.history.getNewQueryOptions();
|
||||
root = PlacesUtils.history.executeQuery(query, options).root;
|
||||
root.containerOpen = true;
|
||||
|
@ -64,7 +64,7 @@ add_task(async function test_brokenFolderShortcut() {
|
|||
|
||||
// Broken folder shortcut as root node with folder=-1.
|
||||
query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([-1], 1);
|
||||
query.setParents([-1], 1);
|
||||
options = PlacesUtils.history.getNewQueryOptions();
|
||||
root = PlacesUtils.history.executeQuery(query, options).root;
|
||||
root.containerOpen = true;
|
||||
|
|
|
@ -51,7 +51,7 @@ add_task(async function test_removePages() {
|
|||
Assert.ok(await checkEmptyHistory(), "History is empty");
|
||||
|
||||
// Check that the bookmark and its annotation still exist.
|
||||
let folder = await PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId);
|
||||
let folder = await PlacesUtils.getFolderContents(PlacesUtils.bookmarks.unfiledGuid);
|
||||
Assert.equal(folder.root.childCount, 1);
|
||||
Assert.equal(PlacesUtils.annotations.getPageAnnotation(pages[BOOKMARK_INDEX], ANNO_NAME),
|
||||
ANNO_VALUE);
|
||||
|
|
|
@ -24,14 +24,14 @@ add_task(async function test_get_child_index() {
|
|||
});
|
||||
|
||||
// Get the unfiled bookmark node.
|
||||
let unfiledNode = getNodeAt(PlacesUtils.unfiledBookmarksFolderId, 0);
|
||||
let unfiledNode = getNodeAt(PlacesUtils.bookmarks.unfiledGuid, 0);
|
||||
if (!unfiledNode)
|
||||
do_throw("Unable to find bookmark in hierarchy!");
|
||||
Assert.equal(unfiledNode.title, "Unfiled bookmark");
|
||||
|
||||
let hs = PlacesUtils.history;
|
||||
let query = hs.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarksMenuFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.menuGuid], 1);
|
||||
let options = hs.getNewQueryOptions();
|
||||
options.queryType = options.QUERY_TYPE_BOOKMARKS;
|
||||
let root = hs.executeQuery(query, options).root;
|
||||
|
@ -55,10 +55,10 @@ add_task(async function test_get_child_index() {
|
|||
root.containerOpen = false;
|
||||
});
|
||||
|
||||
function getNodeAt(aFolderId, aIndex) {
|
||||
function getNodeAt(aFolderGuid, aIndex) {
|
||||
let hs = PlacesUtils.history;
|
||||
let query = hs.getNewQuery();
|
||||
query.setFolders([aFolderId], 1);
|
||||
query.setParents([aFolderGuid], 1);
|
||||
let options = hs.getNewQueryOptions();
|
||||
options.queryType = options.QUERY_TYPE_BOOKMARKS;
|
||||
let root = hs.executeQuery(query, options).root;
|
||||
|
|
|
@ -25,7 +25,7 @@ add_task(async function test_history_clear() {
|
|||
// add a place: bookmark
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "place:folder=4",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.tagsGuid}`,
|
||||
title: "shortcut"
|
||||
});
|
||||
|
||||
|
|
|
@ -399,7 +399,7 @@ async function task_test_date_liveupdate(aResultType) {
|
|||
// Query toolbar and open our query container, then check again liveupdate.
|
||||
options = hs.getNewQueryOptions();
|
||||
query = hs.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
result = hs.executeQuery(query, options);
|
||||
root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
|
|
@ -135,7 +135,7 @@ add_task(async function check_history_query() {
|
|||
add_task(async function check_bookmarks_query() {
|
||||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([PlacesUtils.bookmarksMenuFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.menuGuid], 1);
|
||||
let result = PlacesUtils.history.executeQuery(query, options);
|
||||
result.addObserver(resultObserver);
|
||||
let root = result.root;
|
||||
|
|
|
@ -30,9 +30,7 @@ add_task(async function test_addBookmarksAndCheckGuids() {
|
|||
}]
|
||||
});
|
||||
|
||||
let folderId = await PlacesUtils.promiseItemId(bookmarks[0].guid);
|
||||
|
||||
let root = PlacesUtils.getFolderContents(folderId).root;
|
||||
let root = PlacesUtils.getFolderContents(bookmarks[0].guid).root;
|
||||
Assert.equal(root.childCount, 5);
|
||||
|
||||
// check bookmark guids
|
||||
|
@ -85,9 +83,7 @@ add_task(async function test_updateBookmarksAndCheckGuids() {
|
|||
}]
|
||||
});
|
||||
|
||||
let folderId = await PlacesUtils.promiseItemId(bookmarks[0].guid);
|
||||
|
||||
let root = PlacesUtils.getFolderContents(folderId).root;
|
||||
let root = PlacesUtils.getFolderContents(bookmarks[0].guid).root;
|
||||
Assert.equal(root.childCount, 2);
|
||||
|
||||
// ensure the bookmark and page guids remain the same after modifing other property.
|
||||
|
@ -198,9 +194,7 @@ add_task(async function test_addItemsWithGUIDs() {
|
|||
}]
|
||||
});
|
||||
|
||||
let folderId = await PlacesUtils.promiseItemId(bookmarks[0].guid);
|
||||
|
||||
let root = PlacesUtils.getFolderContents(folderId).root;
|
||||
let root = PlacesUtils.getFolderContents(bookmarks[0].guid).root;
|
||||
Assert.equal(root.childCount, 2);
|
||||
Assert.equal(root.bookmarkGuid, FOLDER_GUID);
|
||||
Assert.equal(root.getChild(0).bookmarkGuid, BOOKMARK_GUID);
|
||||
|
|
|
@ -10,16 +10,15 @@ function run_test() {
|
|||
// Bug 376798
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
query.setFolders([PlacesUtils.bookmarks.placesRoot], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.rootGuid], 1);
|
||||
Assert.equal(PlacesUtils.history.queryToQueryString(query, options),
|
||||
"place:folder=PLACES_ROOT");
|
||||
`place:parent=${PlacesUtils.bookmarks.rootGuid}`);
|
||||
|
||||
// Bug 378828
|
||||
options.sortingAnnotation = "test anno";
|
||||
options.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING;
|
||||
var placeURI =
|
||||
"place:folder=PLACES_ROOT&sort=" + Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING +
|
||||
"&sortingAnnotation=test%20anno";
|
||||
`place:parent=${PlacesUtils.bookmarks.rootGuid}&sort=${Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING}&sortingAnnotation=test%20anno`;
|
||||
Assert.equal(PlacesUtils.history.queryToQueryString(query, options), placeURI);
|
||||
options = {};
|
||||
PlacesUtils.history.queryStringToQuery(placeURI, {}, options);
|
||||
|
|
|
@ -189,12 +189,10 @@ async function test_promiseBookmarksTreeForEachNode(aNode, aOptions, aExcludedGu
|
|||
return item;
|
||||
}
|
||||
|
||||
async function test_promiseBookmarksTreeAgainstResult(aItemGuid = "",
|
||||
async function test_promiseBookmarksTreeAgainstResult(aItemGuid = PlacesUtils.bookmarks.rootGuid,
|
||||
aOptions = { includeItemIds: true },
|
||||
aExcludedGuids) {
|
||||
let itemId = aItemGuid ?
|
||||
await PlacesUtils.promiseItemId(aItemGuid) : PlacesUtils.placesRootId;
|
||||
let node = PlacesUtils.getFolderContents(itemId).root;
|
||||
let node = PlacesUtils.getFolderContents(aItemGuid).root;
|
||||
return test_promiseBookmarksTreeForEachNode(node, aOptions, aExcludedGuids);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,14 +46,12 @@ add_task(async function test() {
|
|||
}]
|
||||
});
|
||||
|
||||
let testFolderId = await PlacesUtils.promiseItemId(bookmarks[0].guid);
|
||||
|
||||
let guid1 = bookmarks[1].guid;
|
||||
let guid2 = bookmarks[2].guid;
|
||||
let guid3 = bookmarks[3].guid;
|
||||
|
||||
// query with natural order
|
||||
let result = PlacesUtils.getFolderContents(testFolderId);
|
||||
let result = PlacesUtils.getFolderContents(bookmarks[0].guid);
|
||||
let root = result.root;
|
||||
|
||||
Assert.equal(root.childCount, 3);
|
||||
|
|
|
@ -75,9 +75,7 @@ add_task(async function test_bookmarkFields() {
|
|||
}],
|
||||
});
|
||||
|
||||
let folderId = await PlacesUtils.promiseItemId(bookmarks[0].guid);
|
||||
|
||||
let root = PlacesUtils.getFolderContents(folderId).root;
|
||||
let root = PlacesUtils.getFolderContents(bookmarks[0].guid).root;
|
||||
equal(root.childCount, 1);
|
||||
|
||||
equal(root.visitType, 0, "Visit type should be 0");
|
||||
|
|
|
@ -13,7 +13,7 @@ function run_test() {
|
|||
var options = PlacesUtils.history.getNewQueryOptions();
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
|
||||
query.setFolders([PlacesUtils.tagsFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.tagsGuid], 1);
|
||||
var result = PlacesUtils.history.executeQuery(query, options);
|
||||
var tagRoot = result.root;
|
||||
tagRoot.containerOpen = true;
|
||||
|
|
|
@ -35,7 +35,7 @@ add_task(async function test_getURLsForContainerNode_folder() {
|
|||
});
|
||||
|
||||
var query = hs.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var options = hs.getNewQueryOptions();
|
||||
|
||||
info("Check folder without uri nodes");
|
||||
|
@ -75,7 +75,7 @@ add_task(async function test_getURLsForContainerNode_folder_excludeItems() {
|
|||
});
|
||||
|
||||
var query = hs.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var options = hs.getNewQueryOptions();
|
||||
options.excludeItems = true;
|
||||
|
||||
|
@ -100,7 +100,7 @@ add_task(async function test_getURLsForContainerNode_query() {
|
|||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
title: "inside query",
|
||||
url: "place:folder=BOOKMARKS_MENU&sort=1",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.menuGuid}&sort=1`,
|
||||
});
|
||||
|
||||
// Create a folder and a query node inside it, these should not be considered
|
||||
|
@ -118,7 +118,7 @@ add_task(async function test_getURLsForContainerNode_query() {
|
|||
});
|
||||
|
||||
var query = hs.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var options = hs.getNewQueryOptions();
|
||||
|
||||
info("Check query without uri nodes");
|
||||
|
@ -142,7 +142,7 @@ add_task(async function test_getURLsForContainerNode_query_excludeItems() {
|
|||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
title: "inside query",
|
||||
url: "place:folder=BOOKMARKS_MENU&sort=1",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.menuGuid}&sort=1`,
|
||||
});
|
||||
|
||||
// Create a folder and a query node inside it, these should not be considered
|
||||
|
@ -160,7 +160,7 @@ add_task(async function test_getURLsForContainerNode_query_excludeItems() {
|
|||
});
|
||||
|
||||
var query = hs.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var options = hs.getNewQueryOptions();
|
||||
options.excludeItems = true;
|
||||
|
||||
|
@ -185,7 +185,7 @@ add_task(async function test_getURLsForContainerNode_query_excludeQueries() {
|
|||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
title: "inside query",
|
||||
url: "place:folder=BOOKMARKS_MENU&sort=1",
|
||||
url: `place:parent=${PlacesUtils.bookmarks.menuGuid}&sort=1`,
|
||||
});
|
||||
|
||||
// Create a folder and a query node inside it, these should not be considered
|
||||
|
@ -203,7 +203,7 @@ add_task(async function test_getURLsForContainerNode_query_excludeQueries() {
|
|||
});
|
||||
|
||||
var query = hs.getNewQuery();
|
||||
query.setFolders([PlacesUtils.toolbarFolderId], 1);
|
||||
query.setParents([PlacesUtils.bookmarks.toolbarGuid], 1);
|
||||
var options = hs.getNewQueryOptions();
|
||||
options.expandQueries = false;
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ support-files =
|
|||
[test_331487.js]
|
||||
[test_384370.js]
|
||||
[test_385397.js]
|
||||
[test_399264_query_to_string.js]
|
||||
[test_399264_string_to_query.js]
|
||||
[test_399266.js]
|
||||
# Bug 821781: test fails intermittently on Linux
|
||||
skip-if = os == "linux"
|
||||
|
|
Загрузка…
Ссылка в новой задаче