Bug 1437476 - Add a test for checking that a bookmark can be loaded inside the Bookmarks sidebar. r=standard8
authorPaul Silaghi <psilaghi@mozilla.com>
Wed, 28 Feb 2018 15:59:57 +0000
changeset 405926 b0990ecdb2d6
parent 405925 06a197051c96
child 405927 ce41e79ade93
push id60413
push usermbanner@mozilla.com
push dateThu, 01 Mar 2018 12:40:55 +0000
treeherderautoland@b0990ecdb2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1437476
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 1437476 - Add a test for checking that a bookmark can be loaded inside the Bookmarks sidebar. r=standard8 MozReview-Commit-ID: 2UfcC1tF6Eh
browser/components/places/tests/browser/browser.ini
browser/components/places/tests/browser/browser_bookmark_load_in_sidebar.js
--- a/browser/components/places/tests/browser/browser.ini
+++ b/browser/components/places/tests/browser/browser.ini
@@ -14,16 +14,18 @@ support-files =
 [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_load_in_sidebar.js]
+skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_bookmark_private_window.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_bookmark_remove_tags.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_bookmarklet_windowOpen.js]
 support-files =
   bookmarklet_windowOpen_dummy.html
 [browser_bookmarks_change_title.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/places/tests/browser/browser_bookmark_load_in_sidebar.js
@@ -0,0 +1,72 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/**
+ * Test that a bookmark can be loaded inside the Bookmarks sidebar.
+ */
+"use strict";
+
+const TEST_URL = "about:buildconfig";
+
+// Cleanup.
+registerCleanupFunction(async () => {
+  await PlacesUtils.bookmarks.eraseEverything();
+});
+
+add_task(async function test_load_in_sidebar() {
+  let bm = await PlacesUtils.bookmarks.insert({
+    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
+    url: TEST_URL,
+    title: TEST_URL,
+  });
+
+  await withSidebarTree("bookmarks", async function(tree) {
+    tree.selectItems([bm.guid]);
+    await withBookmarksDialog(
+      false,
+      function openPropertiesDialog() {
+        tree.controller.doCommand("placesCmd_show:info");
+      },
+
+      // Check the "Load this bookmark in the sidebar" option.
+      async function test(dialogWin) {
+        let loadInSidebar = dialogWin.document.getElementById("editBMPanel_loadInSidebarCheckbox");
+        let promiseCheckboxChanged = PlacesTestUtils.waitForNotification(
+          "onItemChanged",
+          (id, parentId, checked) => checked === true
+        );
+
+        loadInSidebar.click();
+
+        EventUtils.synthesizeKey("VK_RETURN", {}, dialogWin);
+        await promiseCheckboxChanged;
+      }
+    );
+
+    let sidebar = document.getElementById("sidebar");
+
+    let sidebarLoadedPromise = new Promise(resolve => {
+      sidebar.addEventListener("load", function() {
+        executeSoon(resolve);
+      }, {capture: true, once: true});
+    });
+
+    // Select and open the bookmark in the sidebar.
+    tree.selectItems([bm.guid]);
+    tree.controller.doCommand("placesCmd_open");
+
+    await sidebarLoadedPromise;
+
+    let sidebarTitle = document.getElementById("sidebar-title");
+    let sidebarBrowser = sidebar.contentDocument.getElementById("web-panels-browser");
+
+    await BrowserTestUtils.browserLoaded(sidebarBrowser, false, TEST_URL);
+
+    let h1Elem = sidebarBrowser.contentDocument.getElementsByTagName("h1")[0];
+
+    // Check that the title and the content of the page are loaded successfully.
+    Assert.equal(sidebarTitle.value, TEST_URL, "The sidebar title is successfully loaded.");
+    Assert.equal(h1Elem.textContent, TEST_URL, "The sidebar content is successfully loaded.");
+  });
+});