diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/privatebrowsing/test/browser/browser_privatebrowsing_sidebar.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/privatebrowsing/test/browser/browser_privatebrowsing_sidebar.js')
-rw-r--r-- | browser/components/privatebrowsing/test/browser/browser_privatebrowsing_sidebar.js | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_sidebar.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_sidebar.js new file mode 100644 index 0000000000..58a333bfdb --- /dev/null +++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_sidebar.js @@ -0,0 +1,88 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// This test makes sure that Sidebars do not migrate across windows with +// different privacy states + +// See Bug 885054: https://bugzilla.mozilla.org/show_bug.cgi?id=885054 + +function test() { + waitForExplicitFinish(); + + // opens a sidebar + function openSidebar(win) { + return win.SidebarUI.show("viewBookmarksSidebar").then(() => win); + } + + let windowCache = []; + function cacheWindow(w) { + windowCache.push(w); + return w; + } + function closeCachedWindows() { + windowCache.forEach(w => w.close()); + } + + // Part 1: NON PRIVATE WINDOW -> PRIVATE WINDOW + openWindow(window, {}, 1) + .then(cacheWindow) + .then(openSidebar) + .then(win => openWindow(win, { private: true })) + .then(cacheWindow) + .then(function ({ document }) { + let sidebarBox = document.getElementById("sidebar-box"); + is( + sidebarBox.hidden, + true, + "Opening a private window from reg window does not open the sidebar" + ); + }) + .then(closeCachedWindows) + // Part 2: NON PRIVATE WINDOW -> NON PRIVATE WINDOW + .then(() => openWindow(window)) + .then(cacheWindow) + .then(openSidebar) + .then(win => openWindow(win)) + .then(cacheWindow) + .then(function ({ document }) { + let sidebarBox = document.getElementById("sidebar-box"); + is( + sidebarBox.hidden, + false, + "Opening a reg window from reg window does open the sidebar" + ); + }) + .then(closeCachedWindows) + // Part 3: PRIVATE WINDOW -> NON PRIVATE WINDOW + .then(() => openWindow(window, { private: true })) + .then(cacheWindow) + .then(openSidebar) + .then(win => openWindow(win)) + .then(cacheWindow) + .then(function ({ document }) { + let sidebarBox = document.getElementById("sidebar-box"); + is( + sidebarBox.hidden, + true, + "Opening a reg window from a private window does not open the sidebar" + ); + }) + .then(closeCachedWindows) + // Part 4: PRIVATE WINDOW -> PRIVATE WINDOW + .then(() => openWindow(window, { private: true })) + .then(cacheWindow) + .then(openSidebar) + .then(win => openWindow(win, { private: true })) + .then(cacheWindow) + .then(function ({ document }) { + let sidebarBox = document.getElementById("sidebar-box"); + is( + sidebarBox.hidden, + false, + "Opening a private window from private window does open the sidebar" + ); + }) + .then(closeCachedWindows) + .then(finish); +} |