Bug 1437433 - Add a test for checking that a website can be bookmarked from a private window. r=standard8
authorPaul Silaghi <psilaghi@mozilla.com>
Mon, 12 Feb 2018 09:40:50 +0200
changeset 404601 91b807639ce3
parent 404600 760d011572df
child 404602 2e14ee07de8a
push id33483
push userrgurzau@mozilla.com
push dateWed, 21 Feb 2018 10:01:46 +0000
treeherdermozilla-central@dd6caba14142 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1437433
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 1437433 - Add a test for checking that a website can be bookmarked from a private window. r=standard8
browser/components/places/tests/browser/browser.ini
browser/components/places/tests/browser/browser_bookmark_private_window.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_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]
 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_private_window.js
@@ -0,0 +1,44 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/**
+ * Test that the a website can be bookmarked from a private window.
+ */
+"use strict";
+
+const TEST_URL = "about:buildconfig";
+
+// Cleanup.
+registerCleanupFunction(async () => {
+  await PlacesUtils.bookmarks.eraseEverything();
+});
+
+add_task(async function test_add_bookmark_from_private_window() {
+  let win = await BrowserTestUtils.openNewBrowserWindow({private: true});
+  let tab = await BrowserTestUtils.openNewForegroundTab(win.gBrowser, TEST_URL);
+
+  registerCleanupFunction(async () => {
+    await BrowserTestUtils.removeTab(tab);
+    await BrowserTestUtils.closeWindow(win);
+  });
+
+  // Open the bookmark panel.
+  let bookmarkPanel = win.document.getElementById("editBookmarkPanel");
+  let shownPromise = promisePopupShown(bookmarkPanel);
+  let bookmarkStar = win.BookmarkingUI.star;
+  bookmarkStar.click();
+  await shownPromise;
+
+  // Check if the bookmark star changes its state after click.
+  Assert.equal(bookmarkStar.getAttribute("starred"), "true", "Bookmark star changed its state correctly.");
+
+  // Close the bookmark panel.
+  let hiddenPromise = promisePopupHidden(bookmarkPanel);
+  let doneButton = win.document.getElementById("editBookmarkPanelDoneButton");
+  doneButton.click();
+  await hiddenPromise;
+
+  let bm = await PlacesUtils.bookmarks.fetch({url: TEST_URL});
+  Assert.equal(bm.url, TEST_URL, "The bookmark was successfully saved in the database.");
+});