Bug 1344017 - Fix an issue where the folder picker in the edit bookmark overlay is not always be updated correctly. r?mak
MozReview-Commit-ID: 7AuIyuFWlGF
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -1116,18 +1116,18 @@ var gEditItemOverlay = {
this._initLoadInSidebar();
break;
}
},
onItemMoved(aItemId, aOldParent, aOldIndex,
aNewParent, aNewIndex, aItemType) {
if (!this._paneInfo.isItem ||
- !this._paneInfo.visibleRows.has("folderPicker") ||
- this._paneInfo.itemId != aItemOd ||
+ !this._paneInfo.visibleRows.has("folderRow") ||
+ this._paneInfo.itemId != aItemId ||
aNewParent == this._getFolderIdFromMenuList()) {
return;
}
// Just setting selectItem _does not_ trigger oncommand, so we don't
// recurse.
this._folderMenuList.selectedItem = this._getFolderMenuItem(aNewParent);
},
--- a/browser/components/places/tests/browser/browser.ini
+++ b/browser/components/places/tests/browser/browser.ini
@@ -17,16 +17,17 @@ subsuite = clipboard
[browser_416459_cut.js]
subsuite = clipboard
[browser_423515.js]
[browser_425884.js]
[browser_435851_copy_query.js]
subsuite = clipboard
[browser_475045.js]
[browser_555547.js]
+[browser_addBookmarkForFrame.js]
[browser_bookmarklet_windowOpen.js]
support-files =
pageopeningwindow.html
[browser_bookmarkProperties_addFolderDefaultButton.js]
[browser_bookmarkProperties_addKeywordForThisSearch.js]
[browser_bookmarkProperties_addLivemark.js]
[browser_bookmarkProperties_editTagContainer.js]
[browser_bookmarkProperties_readOnlyRoot.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/places/tests/browser/browser_addBookmarkForFrame.js
@@ -0,0 +1,81 @@
+/**
+ * Tests that the add bookmark for frame dialog functions correctly.
+ */
+
+const BASE_URL = "http://mochi.test:8888/browser/browser/components/places/tests/browser";
+const PAGE_URL = BASE_URL + "/framedPage.html";
+const LEFT_URL = BASE_URL + "/frameLeft.html";
+const RIGHT_URL = BASE_URL + "/frameRight.html";
+
+function* withAddBookmarkForFrame(taskFn) {
+ // Open a tab and wait for all the subframes to load.
+ let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, PAGE_URL);
+
+ let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
+
+ let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
+ yield BrowserTestUtils.synthesizeMouseAtCenter("#left",
+ { type: "contextmenu", button: 2}, gBrowser.selectedBrowser);
+ yield popupShownPromise;
+
+ yield withBookmarksDialog(true, function() {
+ let frameMenuItem = document.getElementById("frame");
+ frameMenuItem.click();
+
+ let bookmarkFrame = document.getElementById("context-bookmarkframe");
+ bookmarkFrame.click();
+ }, taskFn);
+
+ yield BrowserTestUtils.removeTab(tab);
+}
+
+add_task(function* test_open_add_bookmark_for_frame() {
+ info("Test basic opening of the add bookmark for frame dialog.");
+ yield withAddBookmarkForFrame(function* test(dialogWin) {
+ let namepicker = dialogWin.document.getElementById("editBMPanel_namePicker");
+ Assert.ok(!namepicker.readOnly, "Name field is writable");
+ Assert.equal(namepicker.value, "Left frame", "Name field is correct.");
+
+ let expectedFolderName =
+ PlacesUtils.getString("BookmarksMenuFolderTitle");
+
+ let folderPicker = dialogWin.document.getElementById("editBMPanel_folderMenuList");
+
+ Assert.equal(folderPicker.selectedItem.label,
+ expectedFolderName, "The folder is the expected one.");
+
+ let tagsField = dialogWin.document.getElementById("editBMPanel_tagsField");
+ Assert.equal(tagsField.value, "", "The tags field should be empty");
+ });
+});
+
+add_task(function* test_move_bookmark_whilst_add_bookmark_open() {
+ info("Test moving a bookmark whilst the add bookmark for frame dialog is open.");
+ yield withAddBookmarkForFrame(function* test(dialogWin) {
+ let bookmarksMenuFolderName = PlacesUtils.getString("BookmarksMenuFolderTitle");
+ let toolbarFolderName = PlacesUtils.getString("BookmarksToolbarFolderTitle");
+
+ let url = makeURI(LEFT_URL);
+ let folderPicker = dialogWin.document.getElementById("editBMPanel_folderMenuList");
+
+ // Check the initial state of the folder picker.
+ Assert.equal(folderPicker.selectedItem.label,
+ bookmarksMenuFolderName, "The folder is the expected one.");
+
+ // Check the bookmark has been created as expected.
+ let bookmark = yield PlacesUtils.bookmarks.fetch({url});
+
+ Assert.equal(bookmark.parentGuid,
+ PlacesUtils.bookmarks.menuGuid,
+ "The bookmark should be in the menuGuid folder.");
+
+ // Now move the bookmark and check the folder picker is updated correctly.
+ bookmark.parentGuid = PlacesUtils.bookmarks.toolbarGuid;
+ bookmark.index = PlacesUtils.bookmarks.DEFAULT_INDEX;
+
+ yield PlacesUtils.bookmarks.update(bookmark);
+
+ Assert.equal(folderPicker.selectedItem.label,
+ toolbarFolderName, "The folder picker has changed to the new folder");
+ });
+});
--- a/browser/components/places/tests/browser/framedPage.html
+++ b/browser/components/places/tests/browser/framedPage.html
@@ -1,9 +1,9 @@
<html>
<head>
<title>Framed page</title>
</head>
<frameset cols="*,*">
- <frame name="left" src="frameLeft.html">
- <frame name="right" src="about:mozilla">
+ <frame id="left" name="left" src="frameLeft.html">
+ <frame id="right" name="right" src="about:mozilla">
</frameset>
</html>