зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1502312 PlacesUtils.validatePageInfo isn't setting requiredIf for url/guid properly. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D9902 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9a4efbbdcc
Коммит
f7a8f9e64f
|
@ -1105,8 +1105,8 @@ var PlacesUtils = {
|
|||
*/
|
||||
validatePageInfo(pageInfo, validateVisits = true) {
|
||||
return this.validateItemProperties("PageInfo", PAGEINFO_VALIDATORS, pageInfo,
|
||||
{ url: { requiredIf: b => { typeof b.guid != "string"; } },
|
||||
guid: { requiredIf: b => { typeof b.url != "string"; } },
|
||||
{ url: { requiredIf: b => !b.guid },
|
||||
guid: { requiredIf: b => !b.url },
|
||||
visits: { requiredIf: b => validateVisits },
|
||||
});
|
||||
},
|
||||
|
|
|
@ -18,6 +18,13 @@ add_task(async function test_error_cases() {
|
|||
/Error: PageInfo: Input should be/,
|
||||
"passing a null as pageInfo should throw an Error"
|
||||
);
|
||||
Assert.throws(
|
||||
() => PlacesUtils.history.update({
|
||||
description: "Test description",
|
||||
}),
|
||||
/Error: PageInfo: The following properties were expected: url, guid/,
|
||||
"not included a url or a guid should throw"
|
||||
);
|
||||
Assert.throws(
|
||||
() => PlacesUtils.history.update({url: "not a valid url string"}),
|
||||
/Error: PageInfo: Invalid value for property/,
|
||||
|
@ -155,7 +162,7 @@ add_task(async function test_previewImageURL_change_saved() {
|
|||
|
||||
let guid = await PlacesTestUtils.fieldInDB(TEST_URL, "guid");
|
||||
previewImageURL = IMAGE_URL;
|
||||
await PlacesUtils.history.update({ url: TEST_URL, guid, previewImageURL });
|
||||
await PlacesUtils.history.update({ guid, previewImageURL });
|
||||
previewImageURLInDB = await PlacesTestUtils.fieldInDB(TEST_URL, "preview_image_url");
|
||||
Assert.equal(previewImageURL, previewImageURLInDB, "previewImageURL should be updated via GUID as expected");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче