зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1127277
- Default to TYPE_BOOKMARK when no type is given for Bookmarks.insert() r=mak
This commit is contained in:
Родитель
e439c48b38
Коммит
7f5745cc9d
|
@ -140,7 +140,7 @@ let Bookmarks = Object.freeze({
|
|||
// dateAdded may be imposed by the caller.
|
||||
let time = (info && info.dateAdded) || new Date();
|
||||
let insertInfo = validateBookmarkObject(info,
|
||||
{ type: { required: true }
|
||||
{ type: { defaultValue: this.TYPE_BOOKMARK }
|
||||
, index: { defaultValue: this.DEFAULT_INDEX }
|
||||
, url: { requiredIf: b => b.type == this.TYPE_BOOKMARK
|
||||
, validIf: b => b.type == this.TYPE_BOOKMARK }
|
||||
|
@ -1229,7 +1229,7 @@ function validateBookmarkObject(input, behavior={}) {
|
|||
throw new Error(`Invalid value for property '${prop}': ${input[prop]}`);
|
||||
}
|
||||
if (behavior[prop].hasOwnProperty("defaultValue") && input[prop] === undefined) {
|
||||
normalizedInput[prop] = behavior[prop].defaultValue;
|
||||
input[prop] = behavior[prop].defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -248,6 +248,17 @@ add_task(function* create_bookmark_frecency() {
|
|||
Assert.ok(frecencyForUrl(bm.url) > 0, "Check frecency has been updated")
|
||||
});
|
||||
|
||||
add_task(function* create_bookmark_without_type() {
|
||||
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "http://example.com/",
|
||||
title: "a bookmark" });
|
||||
checkBookmarkObject(bm);
|
||||
Assert.equal(bm.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
|
||||
Assert.equal(bm.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
Assert.equal(bm.url.href, "http://example.com/");
|
||||
Assert.equal(bm.title, "a bookmark");
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче