Bug 739892 - correct type comparison error and typo in 7703db949571 (Bug 739339). a=borkage

This commit is contained in:
Richard Newman 2012-03-27 22:21:22 -07:00
Родитель 4ccb3a4e07
Коммит e291ecde73
2 изменённых файлов: 32 добавлений и 5 удалений

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

@ -808,6 +808,11 @@ BookmarksStore.prototype = {
this.removeById(itemId, record.id); this.removeById(itemId, record.id);
}, },
_taggableTypes: ["bookmark", "microsummary", "query"],
isTaggable: function isTaggable(recordType) {
return this._taggableTypes.indexOf(recordType) != -1;
},
update: function BStore_update(record) { update: function BStore_update(record) {
let itemId = this.idForGUID(record.id); let itemId = this.idForGUID(record.id);
@ -852,9 +857,12 @@ BookmarksStore.prototype = {
PlacesUtils.bookmarks.changeBookmarkURI(itemId, Utils.makeURI(val)); PlacesUtils.bookmarks.changeBookmarkURI(itemId, Utils.makeURI(val));
break; break;
case "tags": case "tags":
if (Array.isArray(val) && if (Array.isArray(val)) {
(remoteRecordType in ["bookmark", "microsummary", "query"])) { if (this.isTaggable(remoteRecordType)) {
this._tagID(itemId, val); this._tagID(itemId, val);
} else {
this._log.debug("Remote record type is invalid for tags: " + remoteRecordType);
}
} }
break; break;
case "keyword": case "keyword":
@ -1230,9 +1238,12 @@ BookmarksStore.prototype = {
} }
try { try {
let u = PlacesUtils.bookmarks.getBookmarkURI(itemId); let u = PlacesUtils.bookmarks.getBookmarkURI(itemID);
_tagURI(u, tags); this._tagURI(u, tags);
} catch (e) { } catch (e) {
this._log.warn("Got exception fetching URI for " + itemID + ": not tagging. " +
Utils.exceptionStr(e));
// I guess it doesn't have a URI. Don't try to tag it. // I guess it doesn't have a URI. Don't try to tag it.
return; return;
} }

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

@ -418,6 +418,22 @@ add_test(function test_bookmark_guidMap_fail() {
server.stop(run_next_test); server.stop(run_next_test);
}); });
add_test(function test_bookmark_is_taggable() {
let engine = new BookmarksEngine();
let store = engine._store;
do_check_true(store.isTaggable("bookmark"));
do_check_true(store.isTaggable("microsummary"));
do_check_true(store.isTaggable("query"));
do_check_false(store.isTaggable("folder"));
do_check_false(store.isTaggable("livemark"));
do_check_false(store.isTaggable(null));
do_check_false(store.isTaggable(undefined));
do_check_false(store.isTaggable(""));
run_next_test();
});
add_test(function test_bookmark_tag_but_no_uri() { add_test(function test_bookmark_tag_but_no_uri() {
_("Ensure that a bookmark record with tags, but no URI, doesn't throw an exception."); _("Ensure that a bookmark record with tags, but no URI, doesn't throw an exception.");