Bug 1433900 - Add a test for checking the location of a bookmark can be changed. r=standard8
authorPaul Silaghi <psilaghi@mozilla.com>
Mon, 05 Feb 2018 14:04:03 +0200
changeset 455579 1c858a85df47bb57ba54d4b5cc84cccb1a2350c6
parent 455578 fad3be99f87ee06b4517c9fe532dd3b2ceb7aa01
child 455580 d9da3f3bf43203a0ad3de87adfd8298c5e5e85a2
push id8799
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 16:46:23 +0000
treeherdermozilla-beta@15334014dc67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1433900
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1433900 - Add a test for checking the location of a bookmark can be changed. r=standard8
browser/components/places/tests/browser/browser.ini
browser/components/places/tests/browser/browser_bookmark_change_location.js
--- a/browser/components/places/tests/browser/browser.ini
+++ b/browser/components/places/tests/browser/browser.ini
@@ -10,16 +10,18 @@ support-files =
   frameRight.html
   sidebarpanels_click_test_page.html
   keyword_form.html
 
 [browser_0_library_left_pane_migration.js]
 [browser_addBookmarkForFrame.js]
 [browser_bookmark_add_tags.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
+[browser_bookmark_change_location.js]
+skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_bookmark_folder_moveability.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_bookmark_remove_tags.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_bookmarklet_windowOpen.js]
 [browser_bookmarks_change_title.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_bookmarks_sidebar_search.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/places/tests/browser/browser_bookmark_change_location.js
@@ -0,0 +1,108 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/**
+ * Test that the bookmark location (url) can be changed from the toolbar and the sidebar.
+ */
+"use strict";
+
+const TEST_URL = "about:buildconfig";
+const TEST_URL2 = "about:config";
+const TEST_URL3 = "about:credits";
+
+// Setup.
+add_task(async function setup() {
+  let toolbar = document.getElementById("PersonalToolbar");
+  let wasCollapsed = toolbar.collapsed;
+
+  // Uncollapse the personal toolbar if needed.
+  if (wasCollapsed) {
+    await promiseSetToolbarVisibility(toolbar, true);
+  }
+
+  // Cleanup.
+  registerCleanupFunction(async () => {
+    // Collapse the personal toolbar if needed.
+    if (wasCollapsed) {
+      await promiseSetToolbarVisibility(toolbar, false);
+    }
+    await PlacesUtils.bookmarks.eraseEverything();
+  });
+});
+
+add_task(async function test_change_location_from_Toolbar() {
+  let toolbarBookmark = await PlacesUtils.bookmarks.insert({
+    parentGuid: PlacesUtils.bookmarks.toolbarGuid,
+    title: "",
+    url: TEST_URL
+  });
+
+  let toolbarNode = getToolbarNodeForItemGuid(toolbarBookmark.guid);
+
+  await withBookmarksDialog(
+    false,
+    async function openPropertiesDialog() {
+      let placesContext = document.getElementById("placesContext");
+      let promisePopup = BrowserTestUtils.waitForEvent(placesContext, "popupshown");
+      EventUtils.synthesizeMouseAtCenter(toolbarNode, {
+        button: 2,
+        type: "contextmenu"
+      });
+      await promisePopup;
+
+      let properties = document.getElementById("placesContext_show:info");
+      EventUtils.synthesizeMouseAtCenter(properties, {});
+    },
+    async function test(dialogWin) {
+      // 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.");
+
+      // 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() {
+  let bm = await PlacesUtils.bookmarks.fetch({url: TEST_URL2});
+
+  await withSidebarTree("bookmarks", async function(tree) {
+    tree.selectItems([bm.guid]);
+
+    await withBookmarksDialog(
+      false,
+      function openPropertiesDialog() {
+        tree.controller.doCommand("placesCmd_show:info");
+      },
+      async function test(dialogWin) {
+        // Check the initial location.
+        let locationPicker = dialogWin.document.getElementById("editBMPanel_locationField");
+        Assert.equal(locationPicker.value, TEST_URL2, "The location is the expected one.");
+
+        let promiseLocationChange = PlacesTestUtils.waitForNotification("onItemChanged", (id, parentId, index, itemUrl) => itemUrl === TEST_URL3);
+
+        // Update the "location" field.
+        fillBookmarkTextField("editBMPanel_locationField", TEST_URL3, dialogWin, false);
+        await waitForCondition(() => locationPicker.value === TEST_URL3, "The location is correct after update.");
+
+        // Confirm and close the dialog.
+        EventUtils.synthesizeKey("VK_RETURN", {}, dialogWin);
+        await promiseLocationChange;
+
+        let updatedBm = await PlacesUtils.bookmarks.fetch(bm.guid);
+        Assert.equal(updatedBm.url, TEST_URL3, "Should have updated the bookmark location in the database.");
+      }
+    );
+  });
+});