mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1366829 - Fix various 'undefined property' errors raised in places tests. r=mak
MozReview-Commit-ID: FaTSwf5QMnr --HG-- extra : rebase_source : 554ad672bea96fff766187732347ade612ddcc06
This commit is contained in:
parent
0d2d8d0fbe
commit
88e3da2709
@ -640,6 +640,10 @@ var Bookmarks = Object.freeze({
|
||||
throw new Error("It's not possible to remove Places root folders.");
|
||||
}
|
||||
|
||||
if (!("source" in options)) {
|
||||
options.source = Bookmarks.SOURCES.DEFAULT;
|
||||
}
|
||||
|
||||
// Even if we ignore any other unneeded property, we still validate any
|
||||
// known property to reduce likelihood of hidden bugs.
|
||||
let removeInfo = validateBookmarkObject(info);
|
||||
@ -652,14 +656,13 @@ var Bookmarks = Object.freeze({
|
||||
item = await removeBookmark(item, options);
|
||||
|
||||
// Notify onItemRemoved to listeners.
|
||||
let { source = Bookmarks.SOURCES.DEFAULT } = options;
|
||||
let observers = PlacesUtils.bookmarks.getObservers();
|
||||
let uri = item.hasOwnProperty("url") ? PlacesUtils.toURI(item.url) : null;
|
||||
let isUntagging = item._grandParentId == PlacesUtils.tagsFolderId;
|
||||
notify(observers, "onItemRemoved", [ item._id, item._parentId, item.index,
|
||||
item.type, uri, item.guid,
|
||||
item.parentGuid,
|
||||
source ],
|
||||
options.source ],
|
||||
{ isTagging: isUntagging });
|
||||
|
||||
if (isUntagging) {
|
||||
@ -668,7 +671,7 @@ var Bookmarks = Object.freeze({
|
||||
PlacesUtils.toPRTime(entry.lastModified),
|
||||
entry.type, entry._parentId,
|
||||
entry.guid, entry.parentGuid,
|
||||
"", source ]);
|
||||
"", options.source ]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -691,6 +694,10 @@ var Bookmarks = Object.freeze({
|
||||
* @resolves once the removal is complete.
|
||||
*/
|
||||
eraseEverything(options = {}) {
|
||||
if (!options.source) {
|
||||
options.source = Bookmarks.SOURCES.DEFAULT;
|
||||
}
|
||||
|
||||
const folderGuids = [this.toolbarGuid, this.menuGuid, this.unfiledGuid,
|
||||
this.mobileGuid];
|
||||
return PlacesUtils.withConnectionWrapper("Bookmarks.jsm: eraseEverything",
|
||||
@ -778,6 +785,9 @@ var Bookmarks = Object.freeze({
|
||||
* may be overwritten.
|
||||
*/
|
||||
fetch(guidOrInfo, onResult = null, options = {}) {
|
||||
if (!("concurrent" in options)) {
|
||||
options.concurrent = false;
|
||||
}
|
||||
if (onResult && typeof onResult != "function")
|
||||
throw new Error("onResult callback must be a valid function");
|
||||
let info = guidOrInfo;
|
||||
@ -947,6 +957,10 @@ var Bookmarks = Object.freeze({
|
||||
throw new Error("Invalid GUID found in the sorted children array.");
|
||||
}
|
||||
|
||||
if (!("source" in options)) {
|
||||
options.source = Bookmarks.SOURCES.DEFAULT;
|
||||
}
|
||||
|
||||
return (async () => {
|
||||
let parent = await fetchBookmark(info);
|
||||
if (!parent || parent.type != this.TYPE_FOLDER)
|
||||
@ -2158,4 +2172,3 @@ function adjustSeparatorsSyncCounter(db, parentId, startIndex, syncChangeDelta)
|
||||
item_type: Bookmarks.TYPE_SEPARATOR
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -914,7 +914,7 @@ var annotateOrphan = async function(item, requestedParentSyncId) {
|
||||
};
|
||||
|
||||
var reparentOrphans = async function(item) {
|
||||
if (item.kind != BookmarkSyncUtils.KINDS.FOLDER) {
|
||||
if (!item.kind || item.kind != BookmarkSyncUtils.KINDS.FOLDER) {
|
||||
return;
|
||||
}
|
||||
let orphanGuids = await fetchGuidsWithAnno(BookmarkSyncUtils.SYNC_PARENT_ANNO,
|
||||
|
@ -2276,6 +2276,8 @@ var Keywords = {
|
||||
* keyword: non-empty string,
|
||||
* URL: URL or href to associate to the keyword,
|
||||
* postData: optional POST data to associate to the keyword
|
||||
* source: The change source, forwarded to all bookmark observers.
|
||||
* Defaults to nsINavBookmarksService::SOURCE_DEFAULT.
|
||||
* }
|
||||
* @note Do not define a postData property if there isn't any POST data.
|
||||
* @resolves when the addition is complete.
|
||||
@ -2292,8 +2294,11 @@ var Keywords = {
|
||||
throw new Error("Invalid POST data");
|
||||
if (!("url" in keywordEntry))
|
||||
throw new Error("undefined is not a valid URL");
|
||||
let { keyword, url,
|
||||
source = Ci.nsINavBookmarksService.SOURCE_DEFAULT } = keywordEntry;
|
||||
|
||||
if (!("source" in keywordEntry)) {
|
||||
keywordEntry.source = PlacesUtils.bookmarks.SOURCES.DEFAULT;
|
||||
}
|
||||
let { keyword, url, source } = keywordEntry;
|
||||
keyword = keyword.trim().toLowerCase();
|
||||
let postData = keywordEntry.postData || null;
|
||||
// This also checks href for validity
|
||||
@ -2358,8 +2363,12 @@ var Keywords = {
|
||||
* @resolves when the removal is complete.
|
||||
*/
|
||||
remove(keywordOrEntry) {
|
||||
if (typeof(keywordOrEntry) == "string")
|
||||
keywordOrEntry = { keyword: keywordOrEntry };
|
||||
if (typeof(keywordOrEntry) == "string") {
|
||||
keywordOrEntry = {
|
||||
keyword: keywordOrEntry,
|
||||
source: Ci.nsINavBookmarksService.SOURCE_DEFAULT
|
||||
};
|
||||
}
|
||||
|
||||
if (keywordOrEntry === null || typeof(keywordOrEntry) != "object" ||
|
||||
!keywordOrEntry.keyword || typeof keywordOrEntry.keyword != "string")
|
||||
|
@ -197,7 +197,11 @@ function ensureItemsChanged(...items) {
|
||||
let changes = observer.itemsChanged.get(item.guid);
|
||||
do_check_true(changes.has(item.property));
|
||||
let info = changes.get(item.property);
|
||||
do_check_eq(info.isAnnoProperty, Boolean(item.isAnnoProperty));
|
||||
if (!("isAnnoProperty" in item)) {
|
||||
do_check_false(info.isAnnoProperty);
|
||||
} else {
|
||||
do_check_eq(info.isAnnoProperty, Boolean(item.isAnnoProperty));
|
||||
}
|
||||
do_check_eq(info.newValue, item.newValue);
|
||||
if ("url" in item)
|
||||
do_check_true(item.url.equals(info.url));
|
||||
|
@ -84,7 +84,7 @@ add_task(async function test_moz_hosts_update() {
|
||||
let places = [];
|
||||
urls.forEach(function(url) {
|
||||
let place = { uri: url.uri,
|
||||
title: "test for " + url.url,
|
||||
title: "test for " + url.uri.spec,
|
||||
transition: url.typed ? TRANSITION_TYPED : undefined };
|
||||
places.push(place);
|
||||
});
|
||||
|
@ -143,7 +143,7 @@ add_task(async function test_addLivemark_badSiteURI_throws() {
|
||||
add_task(async function test_addLivemark_badGuid_throws() {
|
||||
try {
|
||||
await PlacesUtils.livemarks.addLivemark(
|
||||
{ parentGuid: PlacesUtils.bookmarks.unfileGuid
|
||||
{ parentGuid: PlacesUtils.bookmarks.unfiledGuid
|
||||
, feedURI: FEED_URI
|
||||
, guid: "123456" });
|
||||
do_throw("Invoking addLivemark with a bad guid should throw");
|
||||
|
@ -170,6 +170,10 @@ async function test_promiseBookmarksTreeForEachNode(aNode, aOptions, aExcludedGu
|
||||
let item = await PlacesUtils.promiseBookmarksTree(aNode.bookmarkGuid, aOptions);
|
||||
await compareToNode(item, aNode, true, aExcludedGuids);
|
||||
|
||||
if (!PlacesUtils.nodeIsContainer(aNode)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
for (let i = 0; i < aNode.childCount; i++) {
|
||||
let child = aNode.getChild(i);
|
||||
if (child.itemId != PlacesUtils.tagsFolderId)
|
||||
|
Loading…
Reference in New Issue
Block a user