Bug 1440644 - Fix a typo preventing the bookmark dialog storing a keyword. r=standard8
MozReview-Commit-ID: KULAKtzipxY
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -1067,17 +1067,17 @@ var gEditItemOverlay = {
}
if (!this._paneInfo.isItem || this._paneInfo.itemId != aItemId) {
return;
}
switch (aProperty) {
case "uri":
- let newURI = Services.ui.newURI(aValue);
+ let newURI = Services.io.newURI(aValue);
if (!newURI.equals(this._paneInfo.uri)) {
this._paneInfo.uri = newURI;
if (this._paneInfo.visibleRows.has("locationRow"))
this._initLocationField();
if (this._paneInfo.visibleRows.has("tagsRow")) {
delete this._paneInfo._cachedCommonTags;
this._onTagsChange(aGuid, newURI).catch(Cu.reportError);
--- a/browser/components/places/tests/browser/browser_bookmark_change_location.js
+++ b/browser/components/places/tests/browser/browser_bookmark_change_location.js
@@ -58,20 +58,22 @@ add_task(async function test_change_loca
// Check the initial location.
let locationPicker = dialogWin.document.getElementById("editBMPanel_locationField");
Assert.equal(locationPicker.value, TEST_URL, "The location is the expected one.");
let promiseLocationChange = PlacesTestUtils.waitForNotification("onItemChanged", (id, parentId, index, itemUrl) => itemUrl === TEST_URL2);
// Update the "location" field.
fillBookmarkTextField("editBMPanel_locationField", TEST_URL2, dialogWin, false);
await waitForCondition(() => locationPicker.value === TEST_URL2, "The location is correct after update.");
-
+ locationPicker.blur();
+ await promiseLocationChange;
+ Assert.equal(dialogWin.gEditItemOverlay.uri.spec, TEST_URL2, "The location is the expected one.");
+ locationPicker.focus();
// Confirm and close the dialog.
EventUtils.synthesizeKey("VK_RETURN", {}, dialogWin);
- await promiseLocationChange;
let updatedBm = await PlacesUtils.bookmarks.fetch(toolbarBookmark.guid);
Assert.equal(updatedBm.url, TEST_URL2, "Should have updated the bookmark location in the database.");
}
);
});
add_task(async function test_change_location_from_Sidebar() {
--- a/toolkit/components/places/PlacesTransactions.jsm
+++ b/toolkit/components/places/PlacesTransactions.jsm
@@ -901,19 +901,19 @@ DefineTransaction.verifyInput = function
};
// Update the documentation at the top of this module if you add or
// remove properties.
DefineTransaction.defineInputProps(["url", "feedUrl", "siteUrl"],
DefineTransaction.urlValidate, null);
DefineTransaction.defineInputProps(["guid", "parentGuid", "newParentGuid"],
DefineTransaction.guidValidate);
-DefineTransaction.defineInputProps(["title"],
+DefineTransaction.defineInputProps(["title", "postData"],
DefineTransaction.strOrNullValidate, null);
-DefineTransaction.defineInputProps(["keyword", "oldKeyword", "postData", "tag",
+DefineTransaction.defineInputProps(["keyword", "oldKeyword", "tag",
"excludingAnnotation"],
DefineTransaction.strValidate, "");
DefineTransaction.defineInputProps(["index", "newIndex"],
DefineTransaction.indexValidate,
PlacesUtils.bookmarks.DEFAULT_INDEX);
DefineTransaction.defineInputProps(["annotation"],
DefineTransaction.annotationObjectValidate);
DefineTransaction.defineInputProps(["child"],
--- a/toolkit/components/places/tests/unit/test_async_transactions.js
+++ b/toolkit/components/places/tests/unit/test_async_transactions.js
@@ -1156,16 +1156,60 @@ add_task(async function test_edit_keywor
ensureKeywordChange();
await PT.undo();
ensureItemsRemoved(bm_info);
await PT.clearTransactionsHistory();
ensureUndoState();
});
+add_task(async function test_edit_keyword_null_postData() {
+ let bm_info = { parentGuid: rootGuid,
+ url: NetUtil.newURI("http://test.edit.keyword") };
+ const KEYWORD = "test_keyword";
+ bm_info.guid = await PT.NewBookmark(bm_info).transact();
+ function ensureKeywordChange(aCurrentKeyword = "") {
+ ensureItemsChanged({ guid: bm_info.guid,
+ property: "keyword",
+ newValue: aCurrentKeyword });
+ }
+
+ bm_info.guid = await PT.NewBookmark(bm_info).transact();
+
+ observer.reset();
+ await PT.EditKeyword({ guid: bm_info.guid, keyword: KEYWORD, postData: null }).transact();
+ ensureKeywordChange(KEYWORD);
+ let entry = await PlacesUtils.keywords.fetch(KEYWORD);
+ Assert.equal(entry.url.href, bm_info.url.spec);
+ Assert.equal(entry.postData, null);
+
+ observer.reset();
+ await PT.undo();
+ ensureKeywordChange();
+ entry = await PlacesUtils.keywords.fetch(KEYWORD);
+ Assert.equal(entry, null);
+
+ observer.reset();
+ await PT.redo();
+ ensureKeywordChange(KEYWORD);
+ entry = await PlacesUtils.keywords.fetch(KEYWORD);
+ Assert.equal(entry.url.href, bm_info.url.spec);
+ Assert.equal(entry.postData, null);
+
+ // Cleanup
+ observer.reset();
+ await PT.undo();
+ ensureKeywordChange();
+ await PT.undo();
+ ensureItemsRemoved(bm_info);
+
+ await PT.clearTransactionsHistory();
+ ensureUndoState();
+});
+
add_task(async function test_edit_specific_keyword() {
let bm_info = { parentGuid: rootGuid,
url: NetUtil.newURI("http://test.edit.keyword") };
bm_info.guid = await PT.NewBookmark(bm_info).transact();
function ensureKeywordChange(aCurrentKeyword = "", aPreviousKeyword = "") {
ensureItemsChanged({ guid: bm_info.guid,
property: "keyword",
newValue: aCurrentKeyword