summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/browser/browser_bug461710.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/components/places/tests/browser/browser_bug461710.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/places/tests/browser/browser_bug461710.js')
-rw-r--r--toolkit/components/places/tests/browser/browser_bug461710.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/browser/browser_bug461710.js b/toolkit/components/places/tests/browser/browser_bug461710.js
new file mode 100644
index 0000000000..6815860929
--- /dev/null
+++ b/toolkit/components/places/tests/browser/browser_bug461710.js
@@ -0,0 +1,89 @@
+const kRed = "rgb(255, 0, 0)";
+const kBlue = "rgb(0, 0, 255)";
+
+const prefix =
+ "http://example.com/tests/toolkit/components/places/tests/browser/461710_";
+
+add_task(async function () {
+ registerCleanupFunction(PlacesUtils.history.clear);
+ let normalWindow = await BrowserTestUtils.openNewBrowserWindow();
+ let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
+ private: true,
+ });
+ let tests = [
+ {
+ private: false,
+ topic: "uri-visit-saved",
+ subtest: "visited_page.html",
+ },
+ {
+ private: false,
+ subtest: "link_page.html",
+ color: kRed,
+ message: "Visited link coloring should work outside of private mode",
+ },
+ {
+ private: true,
+ subtest: "link_page-2.html",
+ color: kBlue,
+ message: "Visited link coloring should not work inside of private mode",
+ },
+ {
+ private: false,
+ subtest: "link_page-3.html",
+ color: kRed,
+ message: "Visited link coloring should work outside of private mode",
+ },
+ ];
+
+ let uri = Services.io.newURI(prefix + tests[0].subtest);
+ for (let test of tests) {
+ info(test.subtest);
+ let promise = null;
+ if (test.topic) {
+ promise = TestUtils.topicObserved(test.topic, subject =>
+ uri.equals(subject.QueryInterface(Ci.nsIURI))
+ );
+ }
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser: test.private ? privateWindow.gBrowser : normalWindow.gBrowser,
+ url: prefix + test.subtest,
+ },
+ async function (browser) {
+ if (promise) {
+ await promise;
+ }
+
+ if (test.color) {
+ // In e10s waiting for visited-status-resolution is not enough to ensure links
+ // have been updated, because it only tells us that messages to update links
+ // have been dispatched. We must still wait for the actual links to update.
+ await TestUtils.waitForCondition(async function () {
+ let color = await SpecialPowers.spawn(
+ browser,
+ [],
+ async function () {
+ let elem = content.document.getElementById("link");
+ return content.windowUtils.getVisitedDependentComputedStyle(
+ elem,
+ "",
+ "color"
+ );
+ }
+ );
+ return color == test.color;
+ }, test.message);
+ // The harness will consider the test as failed overall if there were no
+ // passes or failures, so record it as a pass.
+ ok(true, test.message);
+ }
+ }
+ );
+ }
+
+ let promisePBExit = TestUtils.topicObserved("last-pb-context-exited");
+ await BrowserTestUtils.closeWindow(privateWindow);
+ await promisePBExit;
+ await BrowserTestUtils.closeWindow(normalWindow);
+});