Bug 1419390 - Searching for bookmarks from the Bookmarks Sidebar works properly r=adw
authorIoana Crisan<icrisan@mozilla.com>
Mon, 04 Dec 2017 17:38:50 +0200
changeset 394994 4bc8cdd5e71658e3954bab1f104c42b370c6ed12
parent 394993 ff9d1a10cb0b1fd91297491ed6c5ae01d4a09a5e
child 394995 6e6e4bd1d151ab89344add22b592b81dea0a1578
push id97989
push usernerli@mozilla.com
push dateTue, 05 Dec 2017 14:14:29 +0000
treeherdermozilla-inbound@4bc8cdd5e716 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1419390
milestone59.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 1419390 - Searching for bookmarks from the Bookmarks Sidebar works properly r=adw
browser/components/places/tests/browser/browser.ini
browser/components/places/tests/browser/browser_bookmarks_sidebar_search.js
--- a/browser/components/places/tests/browser/browser.ini
+++ b/browser/components/places/tests/browser/browser.ini
@@ -10,16 +10,17 @@ support-files =
   frameRight.html
   sidebarpanels_click_test_page.html
   keyword_form.html
 
 [browser_0_library_left_pane_migration.js]
 [browser_addBookmarkForFrame.js]
 [browser_bookmark_folder_moveability.js]
 [browser_bookmarklet_windowOpen.js]
+[browser_bookmarks_sidebar_search.js]
 support-files =
   pageopeningwindow.html
 [browser_bookmarkProperties_addFolderDefaultButton.js]
 [browser_bookmarkProperties_addKeywordForThisSearch.js]
 [browser_bookmarkProperties_addLivemark.js]
 [browser_bookmarkProperties_bookmarkAllTabs.js]
 [browser_bookmarkProperties_cancel.js]
 [browser_bookmarkProperties_editTagContainer.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/places/tests/browser/browser_bookmarks_sidebar_search.js
@@ -0,0 +1,60 @@
+/**
+ *  Test searching for bookmarks (by title and by tag) from the Bookmarks sidebar.
+ */
+"use strict";
+
+let sidebar = document.getElementById("sidebar");
+
+const TEST_URI = "http://example.com/";
+const BOOKMARKS_COUNT = 4;
+
+function assertBookmarks(searchValue) {
+  let found = 0;
+
+  let searchBox = sidebar.contentDocument.getElementById("search-box");
+
+  ok(searchBox, "search box is in context");
+
+  searchBox.value = searchValue;
+  searchBox.doCommand();
+
+  let tree = sidebar.contentDocument.getElementById("bookmarks-view");
+
+  for (let i = 0; i < tree.view.rowCount; i++) {
+    let cellText = tree.view.getCellText(i, tree.columns.getColumnAt(0));
+
+    if (cellText.indexOf("example page") != -1) {
+      found++;
+    }
+  }
+
+  info("Reset the search");
+  searchBox.value = "";
+  searchBox.doCommand();
+
+  is(found, BOOKMARKS_COUNT, "found expected site");
+}
+
+add_task(async function test() {
+  // Add bookmarks and tags.
+  for (let i = 0; i < BOOKMARKS_COUNT; i++) {
+    let url = Services.io.newURI(TEST_URI + i);
+
+    await PlacesUtils.bookmarks.insert({
+      url,
+      title: "example page " + i,
+      parentGuid: PlacesUtils.bookmarks.toolbarGuid
+    });
+    PlacesUtils.tagging.tagURI(url, ["test"]);
+  }
+
+  await withSidebarTree("bookmarks", function() {
+    // Search a bookmark by its title.
+    assertBookmarks("example.com");
+    // Search a bookmark by its tag.
+    assertBookmarks("test");
+  });
+
+  // Cleanup.
+  await PlacesUtils.bookmarks.eraseEverything();
+});