зеркало из https://github.com/mozilla/gecko-dev.git
Bug 648364 - Replace custom helpers with PlacesUtils.jsm. r=rnewman
This commit is contained in:
Родитель
a85e5bfc44
Коммит
36a5232ef5
|
@ -64,6 +64,7 @@ const RECAPTCHA_DOMAIN = "https://www.google.com";
|
|||
Cu.import("resource://services-sync/main.js");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Cu.import("resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
var gSyncSetup = {
|
||||
|
@ -822,7 +823,9 @@ var gSyncSetup = {
|
|||
if (this._case1Setup)
|
||||
break;
|
||||
|
||||
let places_db = Weave.Svc.History.DBConnection;
|
||||
let places_db = PlacesUtils.history
|
||||
.QueryInterface(Ci.nsPIPlacesDatabase)
|
||||
.DBConnection;
|
||||
if (Weave.Engines.get("history").enabled) {
|
||||
let daysOfHistory = 0;
|
||||
let stm = places_db.createStatement(
|
||||
|
@ -853,7 +856,7 @@ var gSyncSetup = {
|
|||
"FROM moz_bookmarks b " +
|
||||
"LEFT JOIN moz_bookmarks t ON " +
|
||||
"b.parent = t.id WHERE b.type = 1 AND t.parent <> :tag");
|
||||
stm.params.tag = Weave.Svc.Bookmark.tagsFolder;
|
||||
stm.params.tag = PlacesUtils.tagsFolderId;
|
||||
if (stm.executeStep())
|
||||
bookmarks = stm.row.bookmarks;
|
||||
// Support %S for historical reasons (see bug 600141)
|
||||
|
|
|
@ -186,17 +186,17 @@ let kSpecialIds = {
|
|||
// Create the special mobile folder to store mobile bookmarks.
|
||||
createMobileRoot: function createMobileRoot() {
|
||||
let root = PlacesUtils.placesRootId;
|
||||
let mRoot = Svc.Bookmark.createFolder(root, "mobile", -1);
|
||||
Svc.Annos.setItemAnnotation(mRoot, MOBILEROOT_ANNO, 1, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
Svc.Annos.setItemAnnotation(mRoot, EXCLUDEBACKUP_ANNO, 1, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
let mRoot = PlacesUtils.bookmarks.createFolder(root, "mobile", -1);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
mRoot, MOBILEROOT_ANNO, 1, 0, PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
mRoot, EXCLUDEBACKUP_ANNO, 1, 0, PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
return mRoot;
|
||||
},
|
||||
|
||||
findMobileRoot: function findMobileRoot(create) {
|
||||
// Use the (one) mobile root if it already exists.
|
||||
let root = Svc.Annos.getItemsWithAnnotation(MOBILEROOT_ANNO, {});
|
||||
let root = PlacesUtils.annotations.getItemsWithAnnotation(MOBILEROOT_ANNO, {});
|
||||
if (root.length != 0)
|
||||
return root[0];
|
||||
|
||||
|
@ -244,7 +244,27 @@ BookmarksEngine.prototype = {
|
|||
_trackerObj: BookmarksTracker,
|
||||
version: 2,
|
||||
|
||||
_sync: Utils.batchSync("Bookmark", SyncEngine),
|
||||
_sync: function _sync() {
|
||||
let engine = this;
|
||||
let batchEx = null;
|
||||
|
||||
// Try running sync in batch mode
|
||||
PlacesUtils.bookmarks.runInBatchMode({
|
||||
runBatched: function wrappedSync() {
|
||||
try {
|
||||
SyncEngine.prototype._sync.call(engine);
|
||||
}
|
||||
catch(ex) {
|
||||
batchEx = ex;
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
|
||||
// Expose the exception if something inside the batch failed
|
||||
if (batchEx!= null) {
|
||||
throw batchEx;
|
||||
}
|
||||
},
|
||||
|
||||
_syncStartup: function _syncStart() {
|
||||
SyncEngine.prototype._syncStartup.call(this);
|
||||
|
@ -262,37 +282,38 @@ BookmarksEngine.prototype = {
|
|||
// Figure out what key to store the mapping
|
||||
let key;
|
||||
let id = this._store.idForGUID(guid);
|
||||
switch (Svc.Bookmark.getItemType(id)) {
|
||||
case Svc.Bookmark.TYPE_BOOKMARK:
|
||||
switch (PlacesUtils.bookmarks.getItemType(id)) {
|
||||
case PlacesUtils.bookmarks.TYPE_BOOKMARK:
|
||||
|
||||
// Smart bookmarks map to their annotation value.
|
||||
let queryId;
|
||||
try {
|
||||
queryId = Svc.Annos.getItemAnnotation(id, SMART_BOOKMARKS_ANNO);
|
||||
queryId = PlacesUtils.annotations.getItemAnnotation(
|
||||
id, SMART_BOOKMARKS_ANNO);
|
||||
} catch(ex) {}
|
||||
|
||||
if (queryId)
|
||||
key = "q" + queryId;
|
||||
else
|
||||
key = "b" + Svc.Bookmark.getBookmarkURI(id).spec + ":" +
|
||||
Svc.Bookmark.getItemTitle(id);
|
||||
key = "b" + PlacesUtils.bookmarks.getBookmarkURI(id).spec + ":" +
|
||||
PlacesUtils.bookmarks.getItemTitle(id);
|
||||
break;
|
||||
case Svc.Bookmark.TYPE_FOLDER:
|
||||
key = "f" + Svc.Bookmark.getItemTitle(id);
|
||||
case PlacesUtils.bookmarks.TYPE_FOLDER:
|
||||
key = "f" + PlacesUtils.bookmarks.getItemTitle(id);
|
||||
break;
|
||||
case Svc.Bookmark.TYPE_SEPARATOR:
|
||||
key = "s" + Svc.Bookmark.getItemIndex(id);
|
||||
case PlacesUtils.bookmarks.TYPE_SEPARATOR:
|
||||
key = "s" + PlacesUtils.bookmarks.getItemIndex(id);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
// The mapping is on a per parent-folder-name basis
|
||||
let parent = Svc.Bookmark.getFolderIdForItem(id);
|
||||
let parent = PlacesUtils.bookmarks.getFolderIdForItem(id);
|
||||
if (parent <= 0)
|
||||
continue;
|
||||
|
||||
let parentName = Svc.Bookmark.getItemTitle(parent);
|
||||
let parentName = PlacesUtils.bookmarks.getItemTitle(parent);
|
||||
if (lazyMap[parentName] == null)
|
||||
lazyMap[parentName] = {};
|
||||
|
||||
|
@ -418,10 +439,6 @@ function BookmarksStore(name) {
|
|||
|
||||
// Explicitly nullify our references to our cached services so we don't leak
|
||||
Svc.Obs.add("places-shutdown", function() {
|
||||
this.__bms = null;
|
||||
this.__hsvc = null;
|
||||
this.__ls = null;
|
||||
this.__ts = null;
|
||||
for each ([query, stmt] in Iterator(this._stmts))
|
||||
stmt.finalize();
|
||||
}, this);
|
||||
|
@ -429,40 +446,6 @@ function BookmarksStore(name) {
|
|||
BookmarksStore.prototype = {
|
||||
__proto__: Store.prototype,
|
||||
|
||||
__bms: null,
|
||||
get _bms() {
|
||||
if (!this.__bms)
|
||||
this.__bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
||||
getService(Ci.nsINavBookmarksService);
|
||||
return this.__bms;
|
||||
},
|
||||
|
||||
__hsvc: null,
|
||||
get _hsvc() {
|
||||
if (!this.__hsvc)
|
||||
this.__hsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService).
|
||||
QueryInterface(Ci.nsPIPlacesDatabase);
|
||||
return this.__hsvc;
|
||||
},
|
||||
|
||||
__ls: null,
|
||||
get _ls() {
|
||||
if (!this.__ls)
|
||||
this.__ls = Cc["@mozilla.org/browser/livemark-service;2"].
|
||||
getService(Ci.nsILivemarkService);
|
||||
return this.__ls;
|
||||
},
|
||||
|
||||
__ts: null,
|
||||
get _ts() {
|
||||
if (!this.__ts)
|
||||
this.__ts = Cc["@mozilla.org/browser/tagging-service;1"].
|
||||
getService(Ci.nsITaggingService);
|
||||
return this.__ts;
|
||||
},
|
||||
|
||||
|
||||
itemExists: function BStore_itemExists(id) {
|
||||
return this.idForGUID(id, true) > 0;
|
||||
},
|
||||
|
@ -483,7 +466,8 @@ BookmarksStore.prototype = {
|
|||
let queriesRef = {};
|
||||
let queryCountRef = {};
|
||||
let optionsRef = {};
|
||||
Svc.History.queryStringToQueries(uri, queriesRef, queryCountRef, optionsRef);
|
||||
PlacesUtils.history.queryStringToQueries(uri, queriesRef, queryCountRef,
|
||||
optionsRef);
|
||||
|
||||
// We only process tag URIs.
|
||||
if (optionsRef.value.resultType != optionsRef.value.RESULTS_AS_TAG_CONTENTS)
|
||||
|
@ -492,7 +476,7 @@ BookmarksStore.prototype = {
|
|||
// Tag something to ensure that the tag exists.
|
||||
let tag = record.folderName;
|
||||
let dummyURI = Utils.makeURI("about:weave#BStore_preprocess");
|
||||
this._ts.tagURI(dummyURI, [tag]);
|
||||
PlacesUtils.tagging.tagURI(dummyURI, [tag]);
|
||||
|
||||
// Look for the id of the tag, which might just have been added.
|
||||
let tags = this._getNode(PlacesUtils.tagsFolderId);
|
||||
|
@ -513,9 +497,8 @@ BookmarksStore.prototype = {
|
|||
for each (let q in queriesRef.value)
|
||||
q.setFolders([child.itemId], 1);
|
||||
|
||||
record.bmkUri = Svc.History.queriesToQueryString(queriesRef.value,
|
||||
queryCountRef.value,
|
||||
optionsRef.value);
|
||||
record.bmkUri = PlacesUtils.history.queriesToQueryString(
|
||||
queriesRef.value, queryCountRef.value, optionsRef.value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -576,8 +559,9 @@ BookmarksStore.prototype = {
|
|||
|
||||
// Create an annotation to remember that it needs reparenting.
|
||||
if (record._orphan) {
|
||||
Svc.Annos.setItemAnnotation(itemId, PARENT_ANNO, parentGUID, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
itemId, PARENT_ANNO, parentGUID, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -586,8 +570,10 @@ BookmarksStore.prototype = {
|
|||
* Find all ids of items that have a given value for an annotation
|
||||
*/
|
||||
_findAnnoItems: function BStore__findAnnoItems(anno, val) {
|
||||
return Svc.Annos.getItemsWithAnnotation(anno, {}).filter(function(id)
|
||||
Svc.Annos.getItemAnnotation(id, anno) == val);
|
||||
return PlacesUtils.annotations.getItemsWithAnnotation(anno, {})
|
||||
.filter(function(id) {
|
||||
return PlacesUtils.annotations.getItemAnnotation(id, anno) == val;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -602,7 +588,7 @@ BookmarksStore.prototype = {
|
|||
orphans.forEach(function(orphan) {
|
||||
// Move the orphan to the parent and drop the missing parent annotation
|
||||
if (this._reparentItem(orphan, parentId)) {
|
||||
Svc.Annos.removeItemAnnotation(orphan, PARENT_ANNO);
|
||||
PlacesUtils.annotations.removeItemAnnotation(orphan, PARENT_ANNO);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
@ -612,7 +598,8 @@ BookmarksStore.prototype = {
|
|||
parentId);
|
||||
try {
|
||||
if (parentId > 0) {
|
||||
Svc.Bookmark.moveItem(itemId, parentId, Svc.Bookmark.DEFAULT_INDEX);
|
||||
PlacesUtils.bookmarks.moveItem(itemId, parentId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
return true;
|
||||
}
|
||||
} catch(ex) {
|
||||
|
@ -624,7 +611,7 @@ BookmarksStore.prototype = {
|
|||
// Turn a record's nsINavBookmarksService constant and other attributes into
|
||||
// a granular type for comparison.
|
||||
_recordType: function _recordType(itemId) {
|
||||
let bms = this._bms;
|
||||
let bms = PlacesUtils.bookmarks;
|
||||
let type = bms.getItemType(itemId);
|
||||
|
||||
switch (type) {
|
||||
|
@ -665,42 +652,45 @@ BookmarksStore.prototype = {
|
|||
case "query":
|
||||
case "microsummary": {
|
||||
let uri = Utils.makeURI(record.bmkUri);
|
||||
newId = this._bms.insertBookmark(record._parent, uri,
|
||||
Svc.Bookmark.DEFAULT_INDEX, record.title);
|
||||
newId = PlacesUtils.bookmarks.insertBookmark(
|
||||
record._parent, uri, PlacesUtils.bookmarks.DEFAULT_INDEX, record.title);
|
||||
this._log.debug("created bookmark " + newId + " under " + record._parent
|
||||
+ " as " + record.title + " " + record.bmkUri);
|
||||
|
||||
// Smart bookmark annotations are strings.
|
||||
if (record.queryId) {
|
||||
Svc.Annos.setItemAnnotation(newId, SMART_BOOKMARKS_ANNO, record.queryId,
|
||||
0, Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
newId, SMART_BOOKMARKS_ANNO, record.queryId, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
}
|
||||
|
||||
if (Utils.isArray(record.tags)) {
|
||||
this._tagURI(uri, record.tags);
|
||||
}
|
||||
this._bms.setKeywordForBookmark(newId, record.keyword);
|
||||
PlacesUtils.bookmarks.setKeywordForBookmark(newId, record.keyword);
|
||||
if (record.description) {
|
||||
Svc.Annos.setItemAnnotation(newId, DESCRIPTION_ANNO,
|
||||
record.description, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
newId, DESCRIPTION_ANNO, record.description, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
}
|
||||
|
||||
if (record.loadInSidebar) {
|
||||
Svc.Annos.setItemAnnotation(newId, SIDEBAR_ANNO, true, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
newId, SIDEBAR_ANNO, true, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
}
|
||||
|
||||
} break;
|
||||
case "folder":
|
||||
newId = this._bms.createFolder(record._parent, record.title,
|
||||
Svc.Bookmark.DEFAULT_INDEX);
|
||||
newId = PlacesUtils.bookmarks.createFolder(
|
||||
record._parent, record.title, PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
this._log.debug("created folder " + newId + " under " + record._parent
|
||||
+ " as " + record.title);
|
||||
|
||||
if (record.description) {
|
||||
Svc.Annos.setItemAnnotation(newId, DESCRIPTION_ANNO, record.description,
|
||||
0, Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
newId, DESCRIPTION_ANNO, record.description, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
}
|
||||
|
||||
// record.children will be dealt with in _orderChildren.
|
||||
|
@ -721,17 +711,16 @@ BookmarksStore.prototype = {
|
|||
|
||||
// Use createLivemarkFolderOnly, not createLivemark, to avoid it
|
||||
// automatically updating during a sync.
|
||||
newId = this._ls.createLivemarkFolderOnly(record._parent, record.title,
|
||||
siteURI,
|
||||
Utils.makeURI(record.feedUri),
|
||||
Svc.Bookmark.DEFAULT_INDEX);
|
||||
newId = PlacesUtils.livemarks.createLivemarkFolderOnly(
|
||||
record._parent, record.title, siteURI, Utils.makeURI(record.feedUri),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
this._log.debug("Created livemark " + newId + " under " + record._parent +
|
||||
" as " + record.title + ", " + record.siteUri + ", " +
|
||||
record.feedUri + ", GUID " + record.id);
|
||||
break;
|
||||
case "separator":
|
||||
newId = this._bms.insertSeparator(record._parent,
|
||||
Svc.Bookmark.DEFAULT_INDEX);
|
||||
newId = PlacesUtils.bookmarks.insertSeparator(
|
||||
record._parent, PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
this._log.debug("created separator " + newId + " under " + record._parent);
|
||||
break;
|
||||
case "item":
|
||||
|
@ -749,20 +738,20 @@ BookmarksStore.prototype = {
|
|||
// Factored out of `remove` to avoid redundant DB queries when the Places ID
|
||||
// is already known.
|
||||
removeById: function removeById(itemId, guid) {
|
||||
let type = this._bms.getItemType(itemId);
|
||||
let type = PlacesUtils.bookmarks.getItemType(itemId);
|
||||
|
||||
switch (type) {
|
||||
case this._bms.TYPE_BOOKMARK:
|
||||
case PlacesUtils.bookmarks.TYPE_BOOKMARK:
|
||||
this._log.debug(" -> removing bookmark " + guid);
|
||||
this._bms.removeItem(itemId);
|
||||
PlacesUtils.bookmarks.removeItem(itemId);
|
||||
break;
|
||||
case this._bms.TYPE_FOLDER:
|
||||
case PlacesUtils.bookmarks.TYPE_FOLDER:
|
||||
this._log.debug(" -> removing folder " + guid);
|
||||
Svc.Bookmark.removeItem(itemId);
|
||||
PlacesUtils.bookmarks.removeItem(itemId);
|
||||
break;
|
||||
case this._bms.TYPE_SEPARATOR:
|
||||
case PlacesUtils.bookmarks.TYPE_SEPARATOR:
|
||||
this._log.debug(" -> removing separator " + guid);
|
||||
this._bms.removeItem(itemId);
|
||||
PlacesUtils.bookmarks.removeItem(itemId);
|
||||
break;
|
||||
default:
|
||||
this._log.error("remove: Unknown item type: " + type);
|
||||
|
@ -810,51 +799,54 @@ BookmarksStore.prototype = {
|
|||
|
||||
// Move the bookmark to a new parent or new position if necessary
|
||||
if (record._parent > 0 &&
|
||||
Svc.Bookmark.getFolderIdForItem(itemId) != record._parent) {
|
||||
PlacesUtils.bookmarks.getFolderIdForItem(itemId) != record._parent) {
|
||||
this._reparentItem(itemId, record._parent);
|
||||
}
|
||||
|
||||
for (let [key, val] in Iterator(record.cleartext)) {
|
||||
switch (key) {
|
||||
case "title":
|
||||
this._bms.setItemTitle(itemId, val);
|
||||
PlacesUtils.bookmarks.setItemTitle(itemId, val);
|
||||
break;
|
||||
case "bmkUri":
|
||||
this._bms.changeBookmarkURI(itemId, Utils.makeURI(val));
|
||||
PlacesUtils.bookmarks.changeBookmarkURI(itemId, Utils.makeURI(val));
|
||||
break;
|
||||
case "tags":
|
||||
if (Utils.isArray(val)) {
|
||||
this._tagURI(this._bms.getBookmarkURI(itemId), val);
|
||||
this._tagURI(PlacesUtils.bookmarks.getBookmarkURI(itemId), val);
|
||||
}
|
||||
break;
|
||||
case "keyword":
|
||||
this._bms.setKeywordForBookmark(itemId, val);
|
||||
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, val);
|
||||
break;
|
||||
case "description":
|
||||
if (val) {
|
||||
Svc.Annos.setItemAnnotation(itemId, DESCRIPTION_ANNO, val, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
itemId, DESCRIPTION_ANNO, val, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
} else {
|
||||
Svc.Annos.removeItemAnnotation(itemId, DESCRIPTION_ANNO);
|
||||
PlacesUtils.annotations.removeItemAnnotation(itemId, DESCRIPTION_ANNO);
|
||||
}
|
||||
break;
|
||||
case "loadInSidebar":
|
||||
if (val) {
|
||||
Svc.Annos.setItemAnnotation(itemId, SIDEBAR_ANNO, true, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
itemId, SIDEBAR_ANNO, true, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
} else {
|
||||
Svc.Annos.removeItemAnnotation(itemId, SIDEBAR_ANNO);
|
||||
PlacesUtils.annotations.removeItemAnnotation(itemId, SIDEBAR_ANNO);
|
||||
}
|
||||
break;
|
||||
case "queryId":
|
||||
Svc.Annos.setItemAnnotation(itemId, SMART_BOOKMARKS_ANNO, val, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
itemId, SMART_BOOKMARKS_ANNO, val, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
break;
|
||||
case "siteUri":
|
||||
this._ls.setSiteURI(itemId, Utils.makeURI(val));
|
||||
PlacesUtils.livemarks.setSiteURI(itemId, Utils.makeURI(val));
|
||||
break;
|
||||
case "feedUri":
|
||||
this._ls.setFeedURI(itemId, Utils.makeURI(val));
|
||||
PlacesUtils.livemarks.setFeedURI(itemId, Utils.makeURI(val));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -877,9 +869,10 @@ BookmarksStore.prototype = {
|
|||
// This code path could be optimized by caching the parent earlier.
|
||||
// Doing so should take in count any edge case due to reparenting
|
||||
// or parent invalidations though.
|
||||
if (!parent)
|
||||
parent = Svc.Bookmark.getFolderIdForItem(itemid);
|
||||
Svc.Bookmark.moveItem(itemid, parent, idx - delta);
|
||||
if (!parent) {
|
||||
parent = PlacesUtils.bookmarks.getFolderIdForItem(itemid);
|
||||
}
|
||||
PlacesUtils.bookmarks.moveItem(itemid, parent, idx - delta);
|
||||
} catch (ex) {
|
||||
this._log.debug("Could not move item " + children[idx] + ": " + ex);
|
||||
}
|
||||
|
@ -899,9 +892,10 @@ BookmarksStore.prototype = {
|
|||
},
|
||||
|
||||
_getNode: function BStore__getNode(folder) {
|
||||
let query = this._hsvc.getNewQuery();
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.setFolders([folder], 1);
|
||||
return this._hsvc.executeQuery(query, this._hsvc.getNewQueryOptions()).root;
|
||||
return PlacesUtils.history.executeQuery(
|
||||
query, PlacesUtils.history.getNewQueryOptions()).root;
|
||||
},
|
||||
|
||||
_getTags: function BStore__getTags(uri) {
|
||||
|
@ -911,19 +905,19 @@ BookmarksStore.prototype = {
|
|||
} catch(e) {
|
||||
this._log.warn("Could not parse URI \"" + uri + "\": " + e);
|
||||
}
|
||||
return this._ts.getTagsForURI(uri, {});
|
||||
return PlacesUtils.tagging.getTagsForURI(uri, {});
|
||||
},
|
||||
|
||||
_getDescription: function BStore__getDescription(id) {
|
||||
try {
|
||||
return Svc.Annos.getItemAnnotation(id, DESCRIPTION_ANNO);
|
||||
return PlacesUtils.annotations.getItemAnnotation(id, DESCRIPTION_ANNO);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
_isLoadInSidebar: function BStore__isLoadInSidebar(id) {
|
||||
return Svc.Annos.itemHasAnnotation(id, SIDEBAR_ANNO);
|
||||
return PlacesUtils.annotations.itemHasAnnotation(id, SIDEBAR_ANNO);
|
||||
},
|
||||
|
||||
get _childGUIDsStm() {
|
||||
|
@ -958,10 +952,10 @@ BookmarksStore.prototype = {
|
|||
return record;
|
||||
}
|
||||
|
||||
let parent = Svc.Bookmark.getFolderIdForItem(placeId);
|
||||
switch (this._bms.getItemType(placeId)) {
|
||||
case this._bms.TYPE_BOOKMARK:
|
||||
let bmkUri = this._bms.getBookmarkURI(placeId).spec;
|
||||
let parent = PlacesUtils.bookmarks.getFolderIdForItem(placeId);
|
||||
switch (PlacesUtils.bookmarks.getItemType(placeId)) {
|
||||
case PlacesUtils.bookmarks.TYPE_BOOKMARK:
|
||||
let bmkUri = PlacesUtils.bookmarks.getBookmarkURI(placeId).spec;
|
||||
if (bmkUri.search(/^place:/) == 0) {
|
||||
record = new BookmarkQuery(collection, id);
|
||||
|
||||
|
@ -971,7 +965,7 @@ BookmarksStore.prototype = {
|
|||
// There might not be the tag yet when creating on a new client
|
||||
if (folder != null) {
|
||||
folder = folder[1];
|
||||
record.folderName = this._bms.getItemTitle(folder);
|
||||
record.folderName = PlacesUtils.bookmarks.getItemTitle(folder);
|
||||
this._log.trace("query id: " + folder + " = " + record.folderName);
|
||||
}
|
||||
}
|
||||
|
@ -979,7 +973,7 @@ BookmarksStore.prototype = {
|
|||
|
||||
// Persist the Smart Bookmark anno, if found.
|
||||
try {
|
||||
let anno = Svc.Annos.getItemAnnotation(placeId, SMART_BOOKMARKS_ANNO);
|
||||
let anno = PlacesUtils.annotations.getItemAnnotation(placeId, SMART_BOOKMARKS_ANNO);
|
||||
if (anno != null) {
|
||||
this._log.trace("query anno: " + SMART_BOOKMARKS_ANNO +
|
||||
" = " + anno);
|
||||
|
@ -991,45 +985,45 @@ BookmarksStore.prototype = {
|
|||
else {
|
||||
record = new Bookmark(collection, id);
|
||||
}
|
||||
record.title = this._bms.getItemTitle(placeId);
|
||||
record.title = PlacesUtils.bookmarks.getItemTitle(placeId);
|
||||
|
||||
record.parentName = Svc.Bookmark.getItemTitle(parent);
|
||||
record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
|
||||
record.bmkUri = bmkUri;
|
||||
record.tags = this._getTags(record.bmkUri);
|
||||
record.keyword = this._bms.getKeywordForBookmark(placeId);
|
||||
record.keyword = PlacesUtils.bookmarks.getKeywordForBookmark(placeId);
|
||||
record.description = this._getDescription(placeId);
|
||||
record.loadInSidebar = this._isLoadInSidebar(placeId);
|
||||
break;
|
||||
|
||||
case this._bms.TYPE_FOLDER:
|
||||
case PlacesUtils.bookmarks.TYPE_FOLDER:
|
||||
if (PlacesUtils.itemIsLivemark(placeId)) {
|
||||
record = new Livemark(collection, id);
|
||||
|
||||
let siteURI = this._ls.getSiteURI(placeId);
|
||||
let siteURI = PlacesUtils.livemarks.getSiteURI(placeId);
|
||||
if (siteURI != null)
|
||||
record.siteUri = siteURI.spec;
|
||||
record.feedUri = this._ls.getFeedURI(placeId).spec;
|
||||
record.feedUri = PlacesUtils.livemarks.getFeedURI(placeId).spec;
|
||||
|
||||
} else {
|
||||
record = new BookmarkFolder(collection, id);
|
||||
}
|
||||
|
||||
if (parent > 0)
|
||||
record.parentName = Svc.Bookmark.getItemTitle(parent);
|
||||
record.title = this._bms.getItemTitle(placeId);
|
||||
record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
|
||||
record.title = PlacesUtils.bookmarks.getItemTitle(placeId);
|
||||
record.description = this._getDescription(placeId);
|
||||
record.children = this._getChildGUIDsForId(placeId);
|
||||
break;
|
||||
|
||||
case this._bms.TYPE_SEPARATOR:
|
||||
case PlacesUtils.bookmarks.TYPE_SEPARATOR:
|
||||
record = new BookmarkSeparator(collection, id);
|
||||
if (parent > 0)
|
||||
record.parentName = Svc.Bookmark.getItemTitle(parent);
|
||||
record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
|
||||
// Create a positioning identifier for the separator, used by _lazyMap
|
||||
record.pos = Svc.Bookmark.getItemIndex(placeId);
|
||||
record.pos = PlacesUtils.bookmarks.getItemIndex(placeId);
|
||||
break;
|
||||
|
||||
case this._bms.TYPE_DYNAMIC_CONTAINER:
|
||||
case PlacesUtils.bookmarks.TYPE_DYNAMIC_CONTAINER:
|
||||
record = new PlacesItem(collection, id);
|
||||
this._log.warn("Don't know how to serialize dynamic containers yet");
|
||||
break;
|
||||
|
@ -1037,7 +1031,7 @@ BookmarksStore.prototype = {
|
|||
default:
|
||||
record = new PlacesItem(collection, id);
|
||||
this._log.warn("Unknown item type, cannot serialize: " +
|
||||
this._bms.getItemType(placeId));
|
||||
PlacesUtils.bookmarks.getItemType(placeId));
|
||||
}
|
||||
|
||||
record.parentid = this.GUIDForId(parent);
|
||||
|
@ -1052,8 +1046,9 @@ BookmarksStore.prototype = {
|
|||
return this._stmts[query];
|
||||
|
||||
this._log.trace("Creating SQL statement: " + query);
|
||||
return this._stmts[query] = this._hsvc.DBConnection
|
||||
.createAsyncStatement(query);
|
||||
let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
|
||||
.DBConnection;
|
||||
return this._stmts[query] = db.createAsyncStatement(query);
|
||||
},
|
||||
|
||||
get _frecencyStm() {
|
||||
|
@ -1199,10 +1194,10 @@ BookmarksStore.prototype = {
|
|||
|
||||
// Temporarily tag a dummy uri to preserve tag ids when untagging
|
||||
let dummyURI = Utils.makeURI("about:weave#BStore_tagURI");
|
||||
this._ts.tagURI(dummyURI, tags);
|
||||
this._ts.untagURI(bmkURI, null);
|
||||
this._ts.tagURI(bmkURI, tags);
|
||||
this._ts.untagURI(dummyURI, null);
|
||||
PlacesUtils.tagging.tagURI(dummyURI, tags);
|
||||
PlacesUtils.tagging.untagURI(bmkURI, null);
|
||||
PlacesUtils.tagging.tagURI(bmkURI, tags);
|
||||
PlacesUtils.tagging.untagURI(dummyURI, null);
|
||||
},
|
||||
|
||||
getAllIDs: function BStore_getAllIDs() {
|
||||
|
@ -1223,7 +1218,7 @@ BookmarksStore.prototype = {
|
|||
if (guid != "places") {
|
||||
let id = kSpecialIds.specialIdForGUID(guid);
|
||||
if (id)
|
||||
this._bms.removeFolderChildren(id);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1243,7 +1238,7 @@ BookmarksTracker.prototype = {
|
|||
switch (topic) {
|
||||
case "weave:engine:start-tracking":
|
||||
if (!this._enabled) {
|
||||
Svc.Bookmark.addObserver(this, true);
|
||||
PlacesUtils.bookmarks.addObserver(this, true);
|
||||
Svc.Obs.add("bookmarks-restore-begin", this);
|
||||
Svc.Obs.add("bookmarks-restore-success", this);
|
||||
Svc.Obs.add("bookmarks-restore-failed", this);
|
||||
|
@ -1252,18 +1247,12 @@ BookmarksTracker.prototype = {
|
|||
break;
|
||||
case "weave:engine:stop-tracking":
|
||||
if (this._enabled) {
|
||||
Svc.Bookmark.removeObserver(this);
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
Svc.Obs.remove("bookmarks-restore-begin", this);
|
||||
Svc.Obs.remove("bookmarks-restore-success", this);
|
||||
Svc.Obs.remove("bookmarks-restore-failed", this);
|
||||
this._enabled = false;
|
||||
}
|
||||
// Fall through to clean up.
|
||||
case "places-shutdown":
|
||||
// Explicitly nullify our references to our cached services so
|
||||
// we don't leak
|
||||
this.__ls = null;
|
||||
this.__bms = null;
|
||||
break;
|
||||
|
||||
case "bookmarks-restore-begin":
|
||||
|
@ -1286,22 +1275,6 @@ BookmarksTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
__bms: null,
|
||||
get _bms() {
|
||||
if (!this.__bms)
|
||||
this.__bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
||||
getService(Ci.nsINavBookmarksService);
|
||||
return this.__bms;
|
||||
},
|
||||
|
||||
__ls: null,
|
||||
get _ls() {
|
||||
if (!this.__ls)
|
||||
this.__ls = Cc["@mozilla.org/browser/livemark-service;2"].
|
||||
getService(Ci.nsILivemarkService);
|
||||
return this.__ls;
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsINavBookmarkObserver,
|
||||
Ci.nsINavBookmarkObserver_MOZILLA_1_9_1_ADDITIONS,
|
||||
|
@ -1342,14 +1315,14 @@ BookmarksTracker.prototype = {
|
|||
// Get the folder id if we weren't given one.
|
||||
if (folder == null) {
|
||||
try {
|
||||
folder = this._bms.getFolderIdForItem(itemId);
|
||||
folder = PlacesUtils.bookmarks.getFolderIdForItem(itemId);
|
||||
} catch (ex) {
|
||||
this._log.debug("getFolderIdForItem(" + itemId +
|
||||
") threw; calling _ensureMobileQuery.");
|
||||
// I'm guessing that gFIFI can throw, and perhaps that's why
|
||||
// _ensureMobileQuery is here at all. Try not to call it.
|
||||
this._ensureMobileQuery();
|
||||
folder = this._bms.getFolderIdForItem(itemId);
|
||||
folder = PlacesUtils.bookmarks.getFolderIdForItem(itemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1363,11 +1336,11 @@ BookmarksTracker.prototype = {
|
|||
return true;
|
||||
|
||||
// Ignore tag items (the actual instance of a tag for a bookmark).
|
||||
if (this._bms.getFolderIdForItem(folder) == tags)
|
||||
if (PlacesUtils.bookmarks.getFolderIdForItem(folder) == tags)
|
||||
return true;
|
||||
|
||||
// Make sure to remove items that have the exclude annotation.
|
||||
if (Svc.Annos.itemHasAnnotation(itemId, EXCLUDEBACKUP_ANNO)) {
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(itemId, EXCLUDEBACKUP_ANNO)) {
|
||||
this.removeChangedID(guid);
|
||||
return true;
|
||||
}
|
||||
|
@ -1398,8 +1371,8 @@ BookmarksTracker.prototype = {
|
|||
|
||||
_ensureMobileQuery: function _ensureMobileQuery() {
|
||||
let find = function (val)
|
||||
Svc.Annos.getItemsWithAnnotation(ORGANIZERQUERY_ANNO, {}).filter(
|
||||
function (id) Svc.Annos.getItemAnnotation(id, ORGANIZERQUERY_ANNO) == val
|
||||
PlacesUtils.annotations.getItemsWithAnnotation(ORGANIZERQUERY_ANNO, {}).filter(
|
||||
function (id) PlacesUtils.annotations.getItemAnnotation(id, ORGANIZERQUERY_ANNO) == val
|
||||
);
|
||||
|
||||
// Don't continue if the Library isn't ready
|
||||
|
@ -1415,21 +1388,22 @@ BookmarksTracker.prototype = {
|
|||
let title = Str.sync.get("mobile.label");
|
||||
|
||||
// Don't add OR remove the mobile bookmarks if there's nothing.
|
||||
if (Svc.Bookmark.getIdForItemAt(kSpecialIds.mobile, 0) == -1) {
|
||||
if (PlacesUtils.bookmarks.getIdForItemAt(kSpecialIds.mobile, 0) == -1) {
|
||||
if (mobile.length != 0)
|
||||
Svc.Bookmark.removeItem(mobile[0]);
|
||||
PlacesUtils.bookmarks.removeItem(mobile[0]);
|
||||
}
|
||||
// Add the mobile bookmarks query if it doesn't exist
|
||||
else if (mobile.length == 0) {
|
||||
let query = Svc.Bookmark.insertBookmark(all[0], queryURI, -1, title);
|
||||
Svc.Annos.setItemAnnotation(query, ORGANIZERQUERY_ANNO, MOBILE_ANNO, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
Svc.Annos.setItemAnnotation(query, EXCLUDEBACKUP_ANNO, 1, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
let query = PlacesUtils.bookmarks.insertBookmark(all[0], queryURI, -1, title);
|
||||
PlacesUtils.annotations.setItemAnnotation(query, ORGANIZERQUERY_ANNO, MOBILE_ANNO, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(query, EXCLUDEBACKUP_ANNO, 1, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
}
|
||||
// Make sure the existing title is correct
|
||||
else if (Svc.Bookmark.getItemTitle(mobile[0]) != title)
|
||||
Svc.Bookmark.setItemTitle(mobile[0], title);
|
||||
else if (PlacesUtils.bookmarks.getItemTitle(mobile[0]) != title) {
|
||||
PlacesUtils.bookmarks.setItemTitle(mobile[0], title);
|
||||
}
|
||||
|
||||
this.ignoreAll = false;
|
||||
},
|
||||
|
@ -1476,7 +1450,7 @@ BookmarksTracker.prototype = {
|
|||
}
|
||||
|
||||
// Remove any position annotations now that the user moved the item
|
||||
Svc.Annos.removeItemAnnotation(itemId, PARENT_ANNO);
|
||||
PlacesUtils.annotations.removeItemAnnotation(itemId, PARENT_ANNO);
|
||||
},
|
||||
|
||||
onBeginUpdateBatch: function () {},
|
||||
|
|
|
@ -89,24 +89,12 @@ function HistoryStore(name) {
|
|||
Svc.Obs.add("places-shutdown", function() {
|
||||
for each ([query, stmt] in Iterator(this._stmts))
|
||||
stmt.finalize();
|
||||
this.__hsvc = null;
|
||||
this._stmts = [];
|
||||
}, this);
|
||||
}
|
||||
HistoryStore.prototype = {
|
||||
__proto__: Store.prototype,
|
||||
|
||||
__hsvc: null,
|
||||
get _hsvc() {
|
||||
if (!this.__hsvc)
|
||||
this.__hsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService).
|
||||
QueryInterface(Ci.nsIGlobalHistory2).
|
||||
QueryInterface(Ci.nsIBrowserHistory).
|
||||
QueryInterface(Ci.nsPIPlacesDatabase);
|
||||
return this.__hsvc;
|
||||
},
|
||||
|
||||
__asyncHistory: null,
|
||||
get _asyncHistory() {
|
||||
if (!this.__asyncHistory) {
|
||||
|
@ -122,8 +110,9 @@ HistoryStore.prototype = {
|
|||
return this._stmts[query];
|
||||
|
||||
this._log.trace("Creating SQL statement: " + query);
|
||||
return this._stmts[query] = this._hsvc.DBConnection
|
||||
.createAsyncStatement(query);
|
||||
let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
|
||||
.DBConnection;
|
||||
return this._stmts[query] = db.createAsyncStatement(query);
|
||||
},
|
||||
|
||||
get _setGUIDStm() {
|
||||
|
@ -299,7 +288,7 @@ HistoryStore.prototype = {
|
|||
}
|
||||
record.guid = record.id;
|
||||
|
||||
if (!this._hsvc.canAddURI(record.uri)) {
|
||||
if (!PlacesUtils.history.canAddURI(record.uri)) {
|
||||
this._log.trace("Ignoring record " + record.id + " with URI "
|
||||
+ record.uri.spec + ": can't add this URI.");
|
||||
return false;
|
||||
|
@ -325,8 +314,8 @@ HistoryStore.prototype = {
|
|||
+ visit.date);
|
||||
throw "Visit has no date!";
|
||||
}
|
||||
if (!visit.type || !(visit.type >= Svc.History.TRANSITION_LINK &&
|
||||
visit.type <= Svc.History.TRANSITION_FRAMED_LINK)) {
|
||||
if (!visit.type || !(visit.type >= PlacesUtils.history.TRANSITION_LINK &&
|
||||
visit.type <= PlacesUtils.history.TRANSITION_FRAMED_LINK)) {
|
||||
this._log.warn("Encountered record with invalid visit type: "
|
||||
+ visit.type);
|
||||
throw "Invalid visit type!";
|
||||
|
@ -366,7 +355,7 @@ HistoryStore.prototype = {
|
|||
}
|
||||
|
||||
let uri = Utils.makeURI(page.url);
|
||||
Svc.History.removePage(uri);
|
||||
PlacesUtils.history.removePage(uri);
|
||||
this._log.trace("Removed page: " + [record.id, page.url, page.title]);
|
||||
},
|
||||
|
||||
|
@ -380,7 +369,7 @@ HistoryStore.prototype = {
|
|||
if (typeof(url) == "string")
|
||||
url = Utils.makeURI(url);
|
||||
// Don't call isVisited on a null URL to work around crasher bug 492442.
|
||||
return url ? this._hsvc.isVisited(url) : false;
|
||||
return url ? PlacesUtils.history.isVisited(url) : false;
|
||||
},
|
||||
|
||||
createRecord: function createRecord(id, collection) {
|
||||
|
@ -399,7 +388,7 @@ HistoryStore.prototype = {
|
|||
},
|
||||
|
||||
wipe: function HistStore_wipe() {
|
||||
this._hsvc.removeAllPages();
|
||||
PlacesUtils.history.removeAllPages();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -416,13 +405,13 @@ HistoryTracker.prototype = {
|
|||
switch (topic) {
|
||||
case "weave:engine:start-tracking":
|
||||
if (!this._enabled) {
|
||||
Svc.History.addObserver(this, true);
|
||||
PlacesUtils.history.addObserver(this, true);
|
||||
this._enabled = true;
|
||||
}
|
||||
break;
|
||||
case "weave:engine:stop-tracking":
|
||||
if (this._enabled) {
|
||||
Svc.History.removeObserver(this);
|
||||
PlacesUtils.history.removeObserver(this);
|
||||
this._enabled = false;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const EXPORTED_SYMBOLS = ['Utils', 'Svc', 'Services', 'Str'];
|
||||
const EXPORTED_SYMBOLS = ['Utils', 'Svc', 'Services', 'PlacesUtils', 'Str'];
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
@ -48,6 +48,7 @@ Cu.import("resource://services-sync/ext/Preferences.js");
|
|||
Cu.import("resource://services-sync/ext/StringBundle.js");
|
||||
Cu.import("resource://services-sync/log4moz.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// Constants for makeSyncCallback, waitForSyncCallback
|
||||
|
@ -174,29 +175,6 @@ let Utils = {
|
|||
};
|
||||
},
|
||||
|
||||
batchSync: function batchSync(service, engineType) {
|
||||
return function batchedSync() {
|
||||
let engine = this;
|
||||
let batchEx = null;
|
||||
|
||||
// Try running sync in batch mode
|
||||
Svc[service].runInBatchMode({
|
||||
runBatched: function wrappedSync() {
|
||||
try {
|
||||
engineType.prototype._sync.call(engine);
|
||||
}
|
||||
catch(ex) {
|
||||
batchEx = ex;
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
|
||||
// Expose the exception if something inside the batch failed
|
||||
if (batchEx!= null)
|
||||
throw batchEx;
|
||||
};
|
||||
},
|
||||
|
||||
runInTransaction: function(db, callback, thisObj) {
|
||||
let hasTransaction = false;
|
||||
try {
|
||||
|
@ -1159,12 +1137,12 @@ let Utils = {
|
|||
getIcon: function(iconUri, defaultIcon) {
|
||||
try {
|
||||
let iconURI = Utils.makeURI(iconUri);
|
||||
return Svc.Favicon.getFaviconLinkForIcon(iconURI).spec;
|
||||
return PlacesUtils.favicons.getFaviconLinkForIcon(iconURI).spec;
|
||||
}
|
||||
catch(ex) {}
|
||||
|
||||
// Just give the provided default icon or the system's default
|
||||
return defaultIcon || Svc.Favicon.defaultFavicon.spec;
|
||||
return defaultIcon || PlacesUtils.favicons.defaultFavicon.spec;
|
||||
},
|
||||
|
||||
getErrorString: function Utils_getErrorString(error, args) {
|
||||
|
@ -1548,12 +1526,8 @@ this.__defineGetter__("_sessionCID", function() {
|
|||
return appinfo_id == SEAMONKEY_ID ? "@mozilla.org/suite/sessionstore;1"
|
||||
: "@mozilla.org/browser/sessionstore;1";
|
||||
});
|
||||
[["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"],
|
||||
["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"],
|
||||
["Env", "@mozilla.org/process/environment;1", "nsIEnvironment"],
|
||||
["Favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"],
|
||||
[["Env", "@mozilla.org/process/environment;1", "nsIEnvironment"],
|
||||
["Form", "@mozilla.org/satchel/form-history;1", "nsIFormHistory2"],
|
||||
["History", "@mozilla.org/browser/nav-history-service;1", "nsPIPlacesDatabase"],
|
||||
["Idle", "@mozilla.org/widget/idleservice;1", "nsIIdleService"],
|
||||
["KeyFactory", "@mozilla.org/security/keyobjectfactory;1", "nsIKeyObjectFactory"],
|
||||
["Memory", "@mozilla.org/xpcom/memory-service;1", "nsIMemory"],
|
||||
|
|
|
@ -18,15 +18,15 @@ add_test(function bad_record_allIDs() {
|
|||
_("Ensure that bad Places queries don't cause an error in getAllIDs.");
|
||||
let engine = new BookmarksEngine();
|
||||
let store = engine._store;
|
||||
let badRecordID = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder,
|
||||
let badRecordID = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder,
|
||||
Utils.makeURI("place:folder=1138"),
|
||||
Svc.Bookmark.DEFAULT_INDEX,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
null);
|
||||
|
||||
do_check_true(badRecordID > 0);
|
||||
_("Record is " + badRecordID);
|
||||
_("Type: " + Svc.Bookmark.getItemType(badRecordID));
|
||||
_("Type: " + PlacesUtils.bookmarks.getItemType(badRecordID));
|
||||
|
||||
_("Fetching children.");
|
||||
store._getChildren("toolbar", {});
|
||||
|
@ -39,7 +39,7 @@ add_test(function bad_record_allIDs() {
|
|||
do_check_true("toolbar" in all);
|
||||
|
||||
_("Clean up.");
|
||||
Svc.Bookmark.removeItem(badRecordID);
|
||||
PlacesUtils.bookmarks.removeItem(badRecordID);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
|
@ -54,7 +54,7 @@ add_test(function test_ID_caching() {
|
|||
let mobileID = store.idForGUID("mobile");
|
||||
_("Change the GUID for that item, and drop the mobile anno.");
|
||||
store._setGUID(mobileID, "abcdefghijkl");
|
||||
Svc.Annos.removeItemAnnotation(mobileID, "mobile/bookmarksRoot");
|
||||
PlacesUtils.annotations.removeItemAnnotation(mobileID, "mobile/bookmarksRoot");
|
||||
|
||||
let err;
|
||||
let newMobileID;
|
||||
|
@ -102,18 +102,18 @@ add_test(function test_processIncoming_error_orderChildren() {
|
|||
|
||||
try {
|
||||
|
||||
let folder1_id = Svc.Bookmark.createFolder(
|
||||
Svc.Bookmark.toolbarFolder, "Folder 1", 0);
|
||||
let folder1_id = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.toolbarFolder, "Folder 1", 0);
|
||||
let folder1_guid = store.GUIDForId(folder1_id);
|
||||
|
||||
let fxuri = Utils.makeURI("http://getfirefox.com/");
|
||||
let tburi = Utils.makeURI("http://getthunderbird.com/");
|
||||
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk1_guid = store.GUIDForId(bmk1_id);
|
||||
let bmk2_id = Svc.Bookmark.insertBookmark(
|
||||
folder1_id, tburi, Svc.Bookmark.DEFAULT_INDEX, "Get Thunderbird!");
|
||||
let bmk2_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder1_id, tburi, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!");
|
||||
let bmk2_guid = store.GUIDForId(bmk2_id);
|
||||
|
||||
// Create a server record for folder1 where we flip the order of
|
||||
|
@ -151,8 +151,8 @@ add_test(function test_processIncoming_error_orderChildren() {
|
|||
do_check_eq(new_children[0], folder1_payload.children[0]);
|
||||
do_check_eq(new_children[1], folder1_payload.children[1]);
|
||||
|
||||
do_check_eq(Svc.Bookmark.getItemIndex(bmk1_id), 1);
|
||||
do_check_eq(Svc.Bookmark.getItemIndex(bmk2_id), 0);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk1_id), 1);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk2_id), 0);
|
||||
|
||||
} finally {
|
||||
store.wipe();
|
||||
|
@ -185,8 +185,8 @@ add_test(function test_restorePromptsReupload() {
|
|||
|
||||
try {
|
||||
|
||||
let folder1_id = Svc.Bookmark.createFolder(
|
||||
Svc.Bookmark.toolbarFolder, "Folder 1", 0);
|
||||
let folder1_id = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.toolbarFolder, "Folder 1", 0);
|
||||
let folder1_guid = store.GUIDForId(folder1_id);
|
||||
_("Folder 1: " + folder1_id + ", " + folder1_guid);
|
||||
|
||||
|
@ -194,8 +194,8 @@ add_test(function test_restorePromptsReupload() {
|
|||
let tburi = Utils.makeURI("http://getthunderbird.com/");
|
||||
|
||||
_("Create a single record.");
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk1_guid = store.GUIDForId(bmk1_id);
|
||||
_("Get Firefox!: " + bmk1_id + ", " + bmk1_guid);
|
||||
|
||||
|
@ -213,12 +213,12 @@ add_test(function test_restorePromptsReupload() {
|
|||
PlacesUtils.backupBookmarksToFile(backupFile);
|
||||
|
||||
_("Create a different record and sync.");
|
||||
let bmk2_id = Svc.Bookmark.insertBookmark(
|
||||
folder1_id, tburi, Svc.Bookmark.DEFAULT_INDEX, "Get Thunderbird!");
|
||||
let bmk2_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder1_id, tburi, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!");
|
||||
let bmk2_guid = store.GUIDForId(bmk2_id);
|
||||
_("Get Thunderbird!: " + bmk2_id + ", " + bmk2_guid);
|
||||
|
||||
Svc.Bookmark.removeItem(bmk1_id);
|
||||
PlacesUtils.bookmarks.removeItem(bmk1_id);
|
||||
|
||||
let error;
|
||||
try {
|
||||
|
@ -249,8 +249,8 @@ add_test(function test_restorePromptsReupload() {
|
|||
count++;
|
||||
let id = store.idForGUID(guid, true);
|
||||
// Only one bookmark, so _all_ should be Firefox!
|
||||
if (Svc.Bookmark.getItemType(id) == Svc.Bookmark.TYPE_BOOKMARK) {
|
||||
let uri = Svc.Bookmark.getBookmarkURI(id);
|
||||
if (PlacesUtils.bookmarks.getItemType(id) == PlacesUtils.bookmarks.TYPE_BOOKMARK) {
|
||||
let uri = PlacesUtils.bookmarks.getBookmarkURI(id);
|
||||
_("Found URI " + uri.spec + " for GUID " + guid);
|
||||
do_check_eq(uri.spec, fxuri.spec);
|
||||
newFX = guid; // Save the new GUID after restore.
|
||||
|
@ -356,18 +356,18 @@ add_test(function test_mismatched_types() {
|
|||
});
|
||||
|
||||
try {
|
||||
let bms = store._bms;
|
||||
let bms = PlacesUtils.bookmarks;
|
||||
let oldR = new FakeRecord(BookmarkFolder, oldRecord);
|
||||
let newR = new FakeRecord(Livemark, newRecord);
|
||||
oldR._parent = Svc.Bookmark.toolbarFolder;
|
||||
newR._parent = Svc.Bookmark.toolbarFolder;
|
||||
oldR._parent = PlacesUtils.bookmarks.toolbarFolder;
|
||||
newR._parent = PlacesUtils.bookmarks.toolbarFolder;
|
||||
|
||||
store.applyIncoming(oldR);
|
||||
_("Applied old. It's a folder.");
|
||||
let oldID = store.idForGUID(oldR.id);
|
||||
_("Old ID: " + oldID);
|
||||
do_check_eq(bms.getItemType(oldID), bms.TYPE_FOLDER);
|
||||
do_check_false(store._ls.isLivemark(oldID));
|
||||
do_check_false(PlacesUtils.livemarks.isLivemark(oldID));
|
||||
|
||||
store.applyIncoming(newR);
|
||||
let newID = store.idForGUID(newR.id);
|
||||
|
@ -375,7 +375,7 @@ add_test(function test_mismatched_types() {
|
|||
|
||||
_("Applied new. It's a livemark.");
|
||||
do_check_eq(bms.getItemType(newID), bms.TYPE_FOLDER);
|
||||
do_check_true(store._ls.isLivemark(newID));
|
||||
do_check_true(PlacesUtils.livemarks.isLivemark(newID));
|
||||
|
||||
} finally {
|
||||
store.wipe();
|
||||
|
|
|
@ -91,8 +91,8 @@ add_test(function test_livemark_descriptions() {
|
|||
|
||||
// Attempt to provoke an error by adding a bad description anno.
|
||||
let id = store.idForGUID(record.id);
|
||||
Svc.Annos.setItemAnnotation(id, DESCRIPTION_ANNO, "", 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(id, DESCRIPTION_ANNO, "", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -106,7 +106,7 @@ add_test(function test_livemark_invalid() {
|
|||
store.create(noParentRec);
|
||||
let recID = store.idForGUID(noParentRec.id, true);
|
||||
do_check_true(recID > 0);
|
||||
do_check_eq(Svc.Bookmark.getFolderIdForItem(recID), Svc.Bookmark.unfiledBookmarksFolder);
|
||||
do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(recID), PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
|
||||
_("Parent is unknown. Will be set to unfiled.");
|
||||
let lateParentRec = makeLivemark(record631361.payload, true);
|
||||
|
@ -118,7 +118,8 @@ add_test(function test_livemark_invalid() {
|
|||
store.create(lateParentRec);
|
||||
recID = store.idForGUID(lateParentRec.id, true);
|
||||
do_check_true(recID > 0);
|
||||
do_check_eq(Svc.Bookmark.getFolderIdForItem(recID), Svc.Bookmark.unfiledBookmarksFolder);
|
||||
do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(recID),
|
||||
PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
|
||||
_("No feed URI, which is invalid. Will be skipped.");
|
||||
let noFeedURIRec = makeLivemark(record631361.payload, true);
|
||||
|
|
|
@ -7,16 +7,16 @@ function getBookmarks(folderId) {
|
|||
|
||||
let pos = 0;
|
||||
while (true) {
|
||||
let itemId = Svc.Bookmark.getIdForItemAt(folderId, pos);
|
||||
let itemId = PlacesUtils.bookmarks.getIdForItemAt(folderId, pos);
|
||||
_("Got itemId", itemId, "under", folderId, "at", pos);
|
||||
if (itemId == -1)
|
||||
break;
|
||||
|
||||
switch (Svc.Bookmark.getItemType(itemId)) {
|
||||
case Svc.Bookmark.TYPE_BOOKMARK:
|
||||
bookmarks.push(Svc.Bookmark.getItemTitle(itemId));
|
||||
switch (PlacesUtils.bookmarks.getItemType(itemId)) {
|
||||
case PlacesUtils.bookmarks.TYPE_BOOKMARK:
|
||||
bookmarks.push(PlacesUtils.bookmarks.getItemTitle(itemId));
|
||||
break;
|
||||
case Svc.Bookmark.TYPE_FOLDER:
|
||||
case PlacesUtils.bookmarks.TYPE_FOLDER:
|
||||
bookmarks.push(getBookmarks(itemId));
|
||||
break;
|
||||
default:
|
||||
|
@ -30,7 +30,7 @@ function getBookmarks(folderId) {
|
|||
}
|
||||
|
||||
function check(expected) {
|
||||
let bookmarks = getBookmarks(Svc.Bookmark.unfiledBookmarksFolder);
|
||||
let bookmarks = getBookmarks(PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
|
||||
_("Checking if the bookmark structure is", JSON.stringify(expected));
|
||||
_("Got bookmarks:", JSON.stringify(bookmarks));
|
||||
|
|
|
@ -25,7 +25,7 @@ function run_test() {
|
|||
_("Verify that the URI has been rewritten.");
|
||||
do_check_neq(tagRecord.bmkUri, uri);
|
||||
|
||||
let tags = store._getNode(store._bms.tagsFolder);
|
||||
let tags = store._getNode(PlacesUtils.tagsFolderId);
|
||||
tags.containerOpen = true;
|
||||
let tagID;
|
||||
for (let i = 0; i < tags.childCount; ++i) {
|
||||
|
|
|
@ -37,16 +37,16 @@ function smartBookmarkCount() {
|
|||
// We do it this way because PlacesUtils.annotations.getItemsWithAnnotation
|
||||
// doesn't work the same (or at all?) between 3.6 and 4.0.
|
||||
let out = {};
|
||||
Svc.Annos.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO, out);
|
||||
PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO, out);
|
||||
return out.value;
|
||||
}
|
||||
|
||||
function clearBookmarks() {
|
||||
_("Cleaning up existing items.");
|
||||
Svc.Bookmark.removeFolderChildren(Svc.Bookmark.bookmarksMenuFolder);
|
||||
Svc.Bookmark.removeFolderChildren(Svc.Bookmark.tagsFolder);
|
||||
Svc.Bookmark.removeFolderChildren(Svc.Bookmark.toolbarFolder);
|
||||
Svc.Bookmark.removeFolderChildren(Svc.Bookmark.unfiledBookmarksFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.bookmarksMenuFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.tagsFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.toolbarFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
startCount = smartBookmarkCount();
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ function test_annotation_uploaded() {
|
|||
_("New item ID: " + mostVisitedID);
|
||||
do_check_true(!!mostVisitedID);
|
||||
|
||||
let annoValue = Svc.Annos.getItemAnnotation(mostVisitedID,
|
||||
let annoValue = PlacesUtils.annotations.getItemAnnotation(mostVisitedID,
|
||||
SMART_BOOKMARKS_ANNO);
|
||||
_("Anno: " + annoValue);
|
||||
do_check_eq("MostVisited", annoValue);
|
||||
|
@ -135,11 +135,12 @@ function test_annotation_uploaded() {
|
|||
|
||||
// "Clear" by changing attributes: if we delete it, apparently it sticks
|
||||
// around as a deleted record...
|
||||
Svc.Bookmark.setItemGUID(mostVisitedID, "abcdefabcdef");
|
||||
Svc.Bookmark.setItemTitle(mostVisitedID, "Not Most Visited");
|
||||
Svc.Bookmark.changeBookmarkURI(mostVisitedID,
|
||||
Utils.makeURI("http://something/else"));
|
||||
Svc.Annos.removeItemAnnotation(mostVisitedID, SMART_BOOKMARKS_ANNO);
|
||||
PlacesUtils.bookmarks.setItemGUID(mostVisitedID, "abcdefabcdef");
|
||||
PlacesUtils.bookmarks.setItemTitle(mostVisitedID, "Not Most Visited");
|
||||
PlacesUtils.bookmarks.changeBookmarkURI(
|
||||
mostVisitedID, Utils.makeURI("http://something/else"));
|
||||
PlacesUtils.annotations.removeItemAnnotation(mostVisitedID,
|
||||
SMART_BOOKMARKS_ANNO);
|
||||
store.wipe();
|
||||
engine.resetClient();
|
||||
do_check_eq(smartBookmarkCount(), startCount);
|
||||
|
@ -153,17 +154,18 @@ function test_annotation_uploaded() {
|
|||
|
||||
_("Find by GUID and verify that it's annotated.");
|
||||
let newID = store.idForGUID(serverGUID);
|
||||
let newAnnoValue = Svc.Annos.getItemAnnotation(newID, SMART_BOOKMARKS_ANNO);
|
||||
let newAnnoValue = PlacesUtils.annotations.getItemAnnotation(
|
||||
newID, SMART_BOOKMARKS_ANNO);
|
||||
do_check_eq(newAnnoValue, "MostVisited");
|
||||
do_check_eq(Svc.Bookmark.getBookmarkURI(newID).spec, uri.spec);
|
||||
do_check_eq(PlacesUtils.bookmarks.getBookmarkURI(newID).spec, uri.spec);
|
||||
|
||||
_("Test updating.");
|
||||
let newRecord = store.createRecord(serverGUID);
|
||||
do_check_eq(newRecord.queryId, newAnnoValue);
|
||||
newRecord.queryId = "LeastVisited";
|
||||
store.update(newRecord);
|
||||
do_check_eq("LeastVisited",
|
||||
Svc.Annos.getItemAnnotation(newID, SMART_BOOKMARKS_ANNO));
|
||||
do_check_eq("LeastVisited", PlacesUtils.annotations.getItemAnnotation(
|
||||
newID, SMART_BOOKMARKS_ANNO));
|
||||
|
||||
|
||||
} finally {
|
||||
|
@ -211,7 +213,8 @@ function test_smart_bookmarks_duped() {
|
|||
|
||||
record.bmkUri = "http://foo/";
|
||||
do_check_eq(mostVisitedGUID, engine._lazyMap(record));
|
||||
do_check_neq(Svc.Bookmark.getBookmarkURI(mostVisitedID).spec, record.bmkUri);
|
||||
do_check_neq(PlacesUtils.bookmarks.getBookmarkURI(mostVisitedID).spec,
|
||||
record.bmkUri);
|
||||
|
||||
_("Verify that different annos don't dupe.");
|
||||
let other = new BookmarkQuery("bookmarks", "abcdefabcdef");
|
||||
|
|
|
@ -14,7 +14,7 @@ let tburi = Utils.makeURI("http://getthunderbird.com/");
|
|||
function test_bookmark_create() {
|
||||
try {
|
||||
_("Ensure the record isn't present yet.");
|
||||
let ids = Svc.Bookmark.getBookmarkIdsForURI(fxuri, {});
|
||||
let ids = PlacesUtils.bookmarks.getBookmarkIdsForURI(fxuri, {});
|
||||
do_check_eq(ids.length, 0);
|
||||
|
||||
_("Let's create a new record.");
|
||||
|
@ -32,14 +32,15 @@ function test_bookmark_create() {
|
|||
_("Verify it has been created correctly.");
|
||||
let id = store.idForGUID(fxrecord.id);
|
||||
do_check_eq(store.GUIDForId(id), fxrecord.id);
|
||||
do_check_eq(Svc.Bookmark.getItemType(id), Svc.Bookmark.TYPE_BOOKMARK);
|
||||
do_check_true(Svc.Bookmark.getBookmarkURI(id).equals(fxuri));
|
||||
do_check_eq(Svc.Bookmark.getItemTitle(id), fxrecord.title);
|
||||
do_check_eq(Svc.Annos.getItemAnnotation(id, "bookmarkProperties/description"),
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemType(id),
|
||||
PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_true(PlacesUtils.bookmarks.getBookmarkURI(id).equals(fxuri));
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemTitle(id), fxrecord.title);
|
||||
do_check_eq(PlacesUtils.annotations.getItemAnnotation(id, "bookmarkProperties/description"),
|
||||
fxrecord.description);
|
||||
do_check_eq(Svc.Bookmark.getFolderIdForItem(id),
|
||||
Svc.Bookmark.toolbarFolder);
|
||||
do_check_eq(Svc.Bookmark.getKeywordForBookmark(id), fxrecord.keyword);
|
||||
do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(id),
|
||||
PlacesUtils.bookmarks.toolbarFolder);
|
||||
do_check_eq(PlacesUtils.bookmarks.getKeywordForBookmark(id), fxrecord.keyword);
|
||||
|
||||
_("Have the store create a new record object. Verify that it has the same data.");
|
||||
let newrecord = store.createRecord(fxrecord.id);
|
||||
|
@ -64,19 +65,20 @@ function test_bookmark_create() {
|
|||
_("Verify it has been created correctly.");
|
||||
id = store.idForGUID(tbrecord.id);
|
||||
do_check_eq(store.GUIDForId(id), tbrecord.id);
|
||||
do_check_eq(Svc.Bookmark.getItemType(id), Svc.Bookmark.TYPE_BOOKMARK);
|
||||
do_check_true(Svc.Bookmark.getBookmarkURI(id).equals(tburi));
|
||||
do_check_eq(Svc.Bookmark.getItemTitle(id), null);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemType(id),
|
||||
PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_true(PlacesUtils.bookmarks.getBookmarkURI(id).equals(tburi));
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemTitle(id), null);
|
||||
let error;
|
||||
try {
|
||||
Svc.Annos.getItemAnnotation(id, "bookmarkProperties/description");
|
||||
PlacesUtils.annotations.getItemAnnotation(id, "bookmarkProperties/description");
|
||||
} catch(ex) {
|
||||
error = ex;
|
||||
}
|
||||
do_check_eq(error.result, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
do_check_eq(Svc.Bookmark.getFolderIdForItem(id),
|
||||
Svc.Bookmark.toolbarFolder);
|
||||
do_check_eq(Svc.Bookmark.getKeywordForBookmark(id), null);
|
||||
do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(id),
|
||||
PlacesUtils.bookmarks.toolbarFolder);
|
||||
do_check_eq(PlacesUtils.bookmarks.getKeywordForBookmark(id), null);
|
||||
} finally {
|
||||
_("Clean up.");
|
||||
store.wipe();
|
||||
|
@ -86,12 +88,14 @@ function test_bookmark_create() {
|
|||
function test_bookmark_update() {
|
||||
try {
|
||||
_("Create a bookmark whose values we'll change.");
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX,
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder, fxuri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
Svc.Annos.setItemAnnotation(bmk1_id, "bookmarkProperties/description",
|
||||
"Firefox is awesome.", 0, Svc.Annos.EXPIRE_NEVER);
|
||||
Svc.Bookmark.setKeywordForBookmark(bmk1_id, "firefox");
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
bmk1_id, "bookmarkProperties/description", "Firefox is awesome.", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
PlacesUtils.bookmarks.setKeywordForBookmark(bmk1_id, "firefox");
|
||||
let bmk1_guid = store.GUIDForId(bmk1_id);
|
||||
|
||||
_("Update the record with some null values.");
|
||||
|
@ -103,9 +107,12 @@ function test_bookmark_update() {
|
|||
store.applyIncoming(record);
|
||||
|
||||
_("Verify that the values have been cleared.");
|
||||
do_check_throws(function () Svc.Annos.getItemAnnotation(bmk1_id, "bookmarkProperties/description"), Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
do_check_eq(Svc.Bookmark.getItemTitle(bmk1_id), null);
|
||||
do_check_eq(Svc.Bookmark.getKeywordForBookmark(bmk1_id), null);
|
||||
do_check_throws(function () {
|
||||
PlacesUtils.annotations.getItemAnnotation(
|
||||
bmk1_id, "bookmarkProperties/description");
|
||||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemTitle(bmk1_id), null);
|
||||
do_check_eq(PlacesUtils.bookmarks.getKeywordForBookmark(bmk1_id), null);
|
||||
} finally {
|
||||
_("Clean up.");
|
||||
store.wipe();
|
||||
|
@ -115,8 +122,9 @@ function test_bookmark_update() {
|
|||
function test_bookmark_createRecord() {
|
||||
try {
|
||||
_("Create a bookmark without a description or title.");
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX, null);
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder, fxuri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX, null);
|
||||
let bmk1_guid = store.GUIDForId(bmk1_id);
|
||||
|
||||
_("Verify that the record is created accordingly.");
|
||||
|
@ -142,10 +150,11 @@ function test_folder_create() {
|
|||
|
||||
_("Verify it has been created correctly.");
|
||||
let id = store.idForGUID(folder.id);
|
||||
do_check_eq(Svc.Bookmark.getItemType(id), Svc.Bookmark.TYPE_FOLDER);
|
||||
do_check_eq(Svc.Bookmark.getItemTitle(id), folder.title);
|
||||
do_check_eq(Svc.Bookmark.getFolderIdForItem(id),
|
||||
Svc.Bookmark.toolbarFolder);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemType(id),
|
||||
PlacesUtils.bookmarks.TYPE_FOLDER);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemTitle(id), folder.title);
|
||||
do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(id),
|
||||
PlacesUtils.bookmarks.toolbarFolder);
|
||||
|
||||
_("Have the store create a new record object. Verify that it has the same data.");
|
||||
let newrecord = store.createRecord(folder.id);
|
||||
|
@ -164,15 +173,15 @@ function test_folder_create() {
|
|||
function test_folder_createRecord() {
|
||||
try {
|
||||
_("Create a folder.");
|
||||
let folder1_id = Svc.Bookmark.createFolder(
|
||||
Svc.Bookmark.toolbarFolder, "Folder1", 0);
|
||||
let folder1_id = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.toolbarFolder, "Folder1", 0);
|
||||
let folder1_guid = store.GUIDForId(folder1_id);
|
||||
|
||||
_("Create two bookmarks in that folder without assigning them GUIDs.");
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk2_id = Svc.Bookmark.insertBookmark(
|
||||
folder1_id, tburi, Svc.Bookmark.DEFAULT_INDEX, "Get Thunderbird!");
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk2_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder1_id, tburi, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!");
|
||||
|
||||
_("Create a record for the folder and verify basic properties.");
|
||||
let record = store.createRecord(folder1_guid);
|
||||
|
@ -197,9 +206,9 @@ function test_folder_createRecord() {
|
|||
function test_deleted() {
|
||||
try {
|
||||
_("Create a bookmark that will be deleted.");
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder, fxuri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk1_guid = store.GUIDForId(bmk1_id);
|
||||
|
||||
_("Delete the bookmark through the store.");
|
||||
|
@ -210,7 +219,7 @@ function test_deleted() {
|
|||
_("Ensure it has been deleted.");
|
||||
let error;
|
||||
try {
|
||||
Svc.Bookmark.getBookmarkURI(bmk1_id);
|
||||
PlacesUtils.bookmarks.getBookmarkURI(bmk1_id);
|
||||
} catch(ex) {
|
||||
error = ex;
|
||||
}
|
||||
|
@ -228,14 +237,14 @@ function test_deleted() {
|
|||
function test_move_folder() {
|
||||
try {
|
||||
_("Create two folders and a bookmark in one of them.");
|
||||
let folder1_id = Svc.Bookmark.createFolder(
|
||||
Svc.Bookmark.toolbarFolder, "Folder1", 0);
|
||||
let folder1_id = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.toolbarFolder, "Folder1", 0);
|
||||
let folder1_guid = store.GUIDForId(folder1_id);
|
||||
let folder2_id = Svc.Bookmark.createFolder(
|
||||
Svc.Bookmark.toolbarFolder, "Folder2", 0);
|
||||
let folder2_id = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.toolbarFolder, "Folder2", 0);
|
||||
let folder2_guid = store.GUIDForId(folder2_id);
|
||||
let bmk_id = Svc.Bookmark.insertBookmark(
|
||||
folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk_guid = store.GUIDForId(bmk_id);
|
||||
|
||||
_("Get a record, reparent it and apply it to the store.");
|
||||
|
@ -245,7 +254,7 @@ function test_move_folder() {
|
|||
store.applyIncoming(record);
|
||||
|
||||
_("Verify the new parent.");
|
||||
let new_folder_id = Svc.Bookmark.getFolderIdForItem(bmk_id);
|
||||
let new_folder_id = PlacesUtils.bookmarks.getFolderIdForItem(bmk_id);
|
||||
do_check_eq(store.GUIDForId(new_folder_id), folder2_guid);
|
||||
} finally {
|
||||
_("Clean up.");
|
||||
|
@ -258,18 +267,18 @@ function test_move_order() {
|
|||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
try {
|
||||
_("Create two bookmarks");
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder, fxuri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk1_guid = store.GUIDForId(bmk1_id);
|
||||
let bmk2_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, tburi, Svc.Bookmark.DEFAULT_INDEX,
|
||||
"Get Thunderbird!");
|
||||
let bmk2_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder, tburi,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!");
|
||||
let bmk2_guid = store.GUIDForId(bmk2_id);
|
||||
|
||||
_("Verify order.");
|
||||
do_check_eq(Svc.Bookmark.getItemIndex(bmk1_id), 0);
|
||||
do_check_eq(Svc.Bookmark.getItemIndex(bmk2_id), 1);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk1_id), 0);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk2_id), 1);
|
||||
let toolbar = store.createRecord("toolbar");
|
||||
do_check_eq(toolbar.children.length, 2);
|
||||
do_check_eq(toolbar.children[0], bmk1_guid);
|
||||
|
@ -286,8 +295,8 @@ function test_move_order() {
|
|||
delete store._childrenToOrder;
|
||||
|
||||
_("Verify new order.");
|
||||
do_check_eq(Svc.Bookmark.getItemIndex(bmk2_id), 0);
|
||||
do_check_eq(Svc.Bookmark.getItemIndex(bmk1_id), 1);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk2_id), 0);
|
||||
do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk1_id), 1);
|
||||
|
||||
} finally {
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
|
@ -300,14 +309,15 @@ function test_orphan() {
|
|||
try {
|
||||
|
||||
_("Add a new bookmark locally.");
|
||||
let bmk1_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
let bmk1_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder, fxuri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bmk1_guid = store.GUIDForId(bmk1_id);
|
||||
do_check_eq(Svc.Bookmark.getFolderIdForItem(bmk1_id), Svc.Bookmark.toolbarFolder);
|
||||
do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(bmk1_id),
|
||||
PlacesUtils.bookmarks.toolbarFolder);
|
||||
let error;
|
||||
try {
|
||||
Svc.Annos.getItemAnnotation(bmk1_id, PARENT_ANNO);
|
||||
PlacesUtils.annotations.getItemAnnotation(bmk1_id, PARENT_ANNO);
|
||||
} catch(ex) {
|
||||
error = ex;
|
||||
}
|
||||
|
@ -319,8 +329,10 @@ function test_orphan() {
|
|||
store.applyIncoming(record);
|
||||
|
||||
_("Verify that bookmark has been flagged as orphan, has not moved.");
|
||||
do_check_eq(Svc.Bookmark.getFolderIdForItem(bmk1_id), Svc.Bookmark.toolbarFolder);
|
||||
do_check_eq(Svc.Annos.getItemAnnotation(bmk1_id, PARENT_ANNO), "non-existent");
|
||||
do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(bmk1_id),
|
||||
PlacesUtils.bookmarks.toolbarFolder);
|
||||
do_check_eq(PlacesUtils.annotations.getItemAnnotation(bmk1_id, PARENT_ANNO),
|
||||
"non-existent");
|
||||
|
||||
} finally {
|
||||
_("Clean up.");
|
||||
|
@ -330,20 +342,21 @@ function test_orphan() {
|
|||
|
||||
function test_reparentOrphans() {
|
||||
try {
|
||||
let folder1_id = Svc.Bookmark.createFolder(
|
||||
Svc.Bookmark.toolbarFolder, "Folder1", 0);
|
||||
let folder1_id = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.toolbarFolder, "Folder1", 0);
|
||||
let folder1_guid = store.GUIDForId(folder1_id);
|
||||
|
||||
_("Create a bogus orphan record and write the record back to the store to trigger _reparentOrphans.");
|
||||
Svc.Annos.setItemAnnotation(folder1_id, PARENT_ANNO, folder1_guid, 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
folder1_id, PARENT_ANNO, folder1_guid, 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
let record = store.createRecord(folder1_guid);
|
||||
record.title = "New title for Folder 1";
|
||||
store._childrenToOrder = {};
|
||||
store.applyIncoming(record);
|
||||
|
||||
_("Verify that is has been marked as an orphan even though it couldn't be moved into itself.");
|
||||
do_check_eq(Svc.Annos.getItemAnnotation(folder1_id, PARENT_ANNO),
|
||||
do_check_eq(PlacesUtils.annotations.getItemAnnotation(folder1_id, PARENT_ANNO),
|
||||
folder1_guid);
|
||||
|
||||
} finally {
|
||||
|
|
|
@ -13,14 +13,13 @@ function test_tracking() {
|
|||
let tracker = engine._tracker;
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
let folder = Svc.Bookmark.createFolder(Svc.Bookmark.bookmarksMenuFolder,
|
||||
"Test Folder",
|
||||
Svc.Bookmark.DEFAULT_INDEX);
|
||||
let folder = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.bookmarksMenuFolder,
|
||||
"Test Folder", PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
function createBmk() {
|
||||
return Svc.Bookmark.insertBookmark(folder,
|
||||
Utils.makeURI("http://getfirefox.com"),
|
||||
Svc.Bookmark.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
return PlacesUtils.bookmarks.insertBookmark(
|
||||
folder, Utils.makeURI("http://getfirefox.com"),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -69,21 +68,21 @@ function test_onItemChanged() {
|
|||
|
||||
try {
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
let folder = Svc.Bookmark.createFolder(Svc.Bookmark.bookmarksMenuFolder,
|
||||
"Parent",
|
||||
Svc.Bookmark.DEFAULT_INDEX);
|
||||
let folder = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.bookmarksMenuFolder, "Parent",
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
_("Track changes to annos.");
|
||||
let b = Svc.Bookmark.insertBookmark(folder,
|
||||
Utils.makeURI("http://getfirefox.com"),
|
||||
Svc.Bookmark.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
let b = PlacesUtils.bookmarks.insertBookmark(
|
||||
folder, Utils.makeURI("http://getfirefox.com"),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
|
||||
let bGUID = engine._store.GUIDForId(b);
|
||||
_("New item is " + b);
|
||||
_("GUID: " + bGUID);
|
||||
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
Svc.Annos.setItemAnnotation(b, DESCRIPTION_ANNO, "A test description", 0,
|
||||
Svc.Annos.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(
|
||||
b, DESCRIPTION_ANNO, "A test description", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
do_check_true(tracker.changedIDs[bGUID] > 0);
|
||||
|
||||
} finally {
|
||||
|
@ -100,23 +99,24 @@ function test_onItemMoved() {
|
|||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
try {
|
||||
let fx_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.bookmarksMenuFolder,
|
||||
let fx_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.bookmarksMenuFolder,
|
||||
Utils.makeURI("http://getfirefox.com"),
|
||||
Svc.Bookmark.DEFAULT_INDEX,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
let fx_guid = engine._store.GUIDForId(fx_id);
|
||||
let tb_id = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.bookmarksMenuFolder,
|
||||
let tb_id = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.bookmarksMenuFolder,
|
||||
Utils.makeURI("http://getthunderbird.com"),
|
||||
Svc.Bookmark.DEFAULT_INDEX,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"Get Thunderbird!");
|
||||
let tb_guid = engine._store.GUIDForId(tb_id);
|
||||
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
|
||||
// Moving within the folder will just track the folder.
|
||||
Svc.Bookmark.moveItem(tb_id, Svc.Bookmark.bookmarksMenuFolder, 0);
|
||||
PlacesUtils.bookmarks.moveItem(
|
||||
tb_id, PlacesUtils.bookmarks.bookmarksMenuFolder, 0);
|
||||
do_check_true(tracker.changedIDs['menu'] > 0);
|
||||
do_check_eq(tracker.changedIDs['toolbar'], undefined);
|
||||
do_check_eq(tracker.changedIDs[fx_guid], undefined);
|
||||
|
@ -125,8 +125,8 @@ function test_onItemMoved() {
|
|||
|
||||
// Moving a bookmark to a different folder will track the old
|
||||
// folder, the new folder and the bookmark.
|
||||
Svc.Bookmark.moveItem(tb_id, Svc.Bookmark.toolbarFolder,
|
||||
Svc.Bookmark.DEFAULT_INDEX);
|
||||
PlacesUtils.bookmarks.moveItem(tb_id, PlacesUtils.bookmarks.toolbarFolder,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
do_check_true(tracker.changedIDs['menu'] > 0);
|
||||
do_check_true(tracker.changedIDs['toolbar'] > 0);
|
||||
do_check_eq(tracker.changedIDs[fx_guid], undefined);
|
||||
|
|
|
@ -19,7 +19,7 @@ function test_processIncoming_mobile_history_batched() {
|
|||
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
|
||||
Svc.Prefs.set("username", "foo");
|
||||
Svc.Prefs.set("client.type", "mobile");
|
||||
Svc.History.removeAllPages();
|
||||
PlacesUtils.history.removeAllPages();
|
||||
Engines.register(HistoryEngine);
|
||||
|
||||
// A collection that logs each GET
|
||||
|
@ -128,7 +128,7 @@ function test_processIncoming_mobile_history_batched() {
|
|||
}
|
||||
|
||||
} finally {
|
||||
Svc.History.removeAllPages();
|
||||
PlacesUtils.history.removeAllPages();
|
||||
server.stop(do_test_finished);
|
||||
Svc.Prefs.resetBranch("");
|
||||
Records.clearCache();
|
||||
|
|
|
@ -7,9 +7,9 @@ const TIMESTAMP2 = (Date.now() - 6592903) * 1000;
|
|||
const TIMESTAMP3 = (Date.now() - 123894) * 1000;
|
||||
|
||||
function queryPlaces(uri, options) {
|
||||
let query = Svc.History.getNewQuery();
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
query.uri = uri;
|
||||
let res = Svc.History.executeQuery(query, options);
|
||||
let res = PlacesUtils.history.executeQuery(query, options);
|
||||
res.root.containerOpen = true;
|
||||
|
||||
let results = [];
|
||||
|
@ -20,7 +20,7 @@ function queryPlaces(uri, options) {
|
|||
}
|
||||
|
||||
function queryHistoryVisits(uri) {
|
||||
let options = Svc.History.getNewQueryOptions();
|
||||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY;
|
||||
options.resultType = Ci.nsINavHistoryQueryOptions.RESULTS_AS_VISIT;
|
||||
options.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_ASCENDING;
|
||||
|
@ -28,12 +28,12 @@ function queryHistoryVisits(uri) {
|
|||
}
|
||||
|
||||
function onNextTitleChanged(callback) {
|
||||
Svc.History.addObserver({
|
||||
PlacesUtils.history.addObserver({
|
||||
onBeginUpdateBatch: function onBeginUpdateBatch() {},
|
||||
onEndUpdateBatch: function onEndUpdateBatch() {},
|
||||
onPageChanged: function onPageChanged() {},
|
||||
onTitleChanged: function onTitleChanged() {
|
||||
Svc.History.removeObserver(this);
|
||||
PlacesUtils.history.removeObserver(this);
|
||||
Utils.delay(callback, 0, this);
|
||||
},
|
||||
onVisit: function onVisit() {},
|
||||
|
@ -57,7 +57,7 @@ function ensureThrows(func) {
|
|||
try {
|
||||
func.apply(this, arguments);
|
||||
} catch (ex) {
|
||||
Svc.History.removeAllPages();
|
||||
PlacesUtils.history.removeAllPages();
|
||||
do_throw(ex);
|
||||
}
|
||||
};
|
||||
|
@ -81,7 +81,7 @@ add_test(function test_store() {
|
|||
|
||||
_("Let's create an entry in the database.");
|
||||
fxuri = Utils.makeURI("http://getfirefox.com/");
|
||||
Svc.History.addPageWithDetails(fxuri, "Get Firefox!", TIMESTAMP1);
|
||||
PlacesUtils.history.addPageWithDetails(fxuri, "Get Firefox!", TIMESTAMP1);
|
||||
|
||||
_("Verify that the entry exists.");
|
||||
let ids = [id for (id in store.getAllIDs())];
|
||||
|
@ -165,7 +165,7 @@ add_test(function test_invalid_records() {
|
|||
let query = "INSERT INTO moz_places "
|
||||
+ "(url, title, rev_host, visit_count, last_visit_date) "
|
||||
+ "VALUES ('invalid-uri', 'Invalid URI', '.', 1, " + TIMESTAMP3 + ")";
|
||||
let stmt = Svc.History.DBConnection.createAsyncStatement(query);
|
||||
let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(query);
|
||||
let result = Utils.queryAsync(stmt);
|
||||
do_check_eq([id for (id in store.getAllIDs())].length, 4);
|
||||
|
||||
|
@ -264,6 +264,6 @@ add_test(function test_remove() {
|
|||
|
||||
add_test(function cleanup() {
|
||||
_("Clean up.");
|
||||
Svc.History.removeAllPages();
|
||||
PlacesUtils.history.removeAllPages();
|
||||
run_next_test();
|
||||
});
|
||||
|
|
|
@ -20,8 +20,9 @@ let tracker = engine._tracker;
|
|||
|
||||
let _counter = 0;
|
||||
function addVisit() {
|
||||
Svc.History.addVisit(Utils.makeURI("http://getfirefox.com/" + _counter),
|
||||
Date.now() * 1000, null, 1, false, 0);
|
||||
PlacesUtils.history.addVisit(
|
||||
Utils.makeURI("http://getfirefox.com/" + _counter),
|
||||
Date.now() * 1000, null, 1, false, 0);
|
||||
_counter += 1;
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ add_test(function test_track_delete() {
|
|||
do_check_eq([id for (id in tracker.changedIDs)].length, 3);
|
||||
run_next_test();
|
||||
});
|
||||
Svc.History.removePage(uri);
|
||||
PlacesUtils.history.removePage(uri);
|
||||
});
|
||||
|
||||
add_test(function test_stop_tracking() {
|
||||
|
@ -102,6 +103,6 @@ add_test(function test_stop_tracking_twice() {
|
|||
|
||||
add_test(function cleanup() {
|
||||
_("Clean up.");
|
||||
Svc.History.removeAllPages();
|
||||
PlacesUtils.history.removeAllPages();
|
||||
run_next_test();
|
||||
});
|
||||
|
|
|
@ -81,13 +81,18 @@ function test_history_guids() {
|
|||
let engine = new HistoryEngine();
|
||||
let store = engine._store;
|
||||
|
||||
Svc.History.addPageWithDetails(fxuri, "Get Firefox!", Date.now() * 1000);
|
||||
Svc.History.addPageWithDetails(tburi, "Get Thunderbird!", Date.now() * 1000);
|
||||
PlacesUtils.history.addPageWithDetails(fxuri, "Get Firefox!",
|
||||
Date.now() * 1000);
|
||||
PlacesUtils.history.addPageWithDetails(tburi, "Get Thunderbird!",
|
||||
Date.now() * 1000);
|
||||
|
||||
// Hack: flush the places db by adding a random bookmark.
|
||||
let uri = Utils.makeURI("http://mozilla.com/");
|
||||
let fxid = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, uri, Svc.Bookmark.DEFAULT_INDEX, "Mozilla");
|
||||
let fxid = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder,
|
||||
uri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"Mozilla");
|
||||
|
||||
let fxguid = store.GUIDForUri(fxuri, true);
|
||||
let tbguid = store.GUIDForUri(tburi, true);
|
||||
|
@ -95,7 +100,7 @@ function test_history_guids() {
|
|||
dump("tbguid: " + tbguid + "\n");
|
||||
|
||||
_("History: Verify GUIDs are added to the guid column.");
|
||||
let stmt = Svc.History.DBConnection.createAsyncStatement(
|
||||
let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(
|
||||
"SELECT id FROM moz_places WHERE guid = :guid");
|
||||
|
||||
stmt.params.guid = fxguid;
|
||||
|
@ -107,7 +112,7 @@ function test_history_guids() {
|
|||
do_check_eq(result.length, 1);
|
||||
|
||||
_("History: Verify GUIDs weren't added to annotations.");
|
||||
stmt = Svc.History.DBConnection.createAsyncStatement(
|
||||
stmt = PlacesUtils.history.DBConnection.createAsyncStatement(
|
||||
"SELECT a.content AS guid FROM moz_annos a WHERE guid = :guid");
|
||||
|
||||
stmt.params.guid = fxguid;
|
||||
|
@ -123,18 +128,22 @@ function test_bookmark_guids() {
|
|||
let engine = new BookmarksEngine();
|
||||
let store = engine._store;
|
||||
|
||||
let fxid = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX,
|
||||
let fxid = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder,
|
||||
fxuri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
let tbid = Svc.Bookmark.insertBookmark(
|
||||
Svc.Bookmark.toolbarFolder, tburi, Svc.Bookmark.DEFAULT_INDEX,
|
||||
let tbid = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.toolbarFolder,
|
||||
tburi,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"Get Thunderbird!");
|
||||
|
||||
let fxguid = store.GUIDForId(fxid);
|
||||
let tbguid = store.GUIDForId(tbid);
|
||||
|
||||
_("Bookmarks: Verify GUIDs are added to the guid column.");
|
||||
let stmt = Svc.History.DBConnection.createAsyncStatement(
|
||||
let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(
|
||||
"SELECT id FROM moz_bookmarks WHERE guid = :guid");
|
||||
|
||||
stmt.params.guid = fxguid;
|
||||
|
@ -148,7 +157,7 @@ function test_bookmark_guids() {
|
|||
do_check_eq(result[0].id, tbid);
|
||||
|
||||
_("Bookmarks: Verify GUIDs weren't added to annotations.");
|
||||
stmt = Svc.History.DBConnection.createAsyncStatement(
|
||||
stmt = PlacesUtils.history.DBConnection.createAsyncStatement(
|
||||
"SELECT a.content AS guid FROM moz_items_annos a WHERE guid = :guid");
|
||||
|
||||
stmt.params.guid = fxguid;
|
||||
|
|
Загрузка…
Ссылка в новой задаче