summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/browser/browser_favicon.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /toolkit/components/places/tests/browser/browser_favicon.js
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/places/tests/browser/browser_favicon.js')
-rw-r--r--toolkit/components/places/tests/browser/browser_favicon.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/browser/browser_favicon.js b/toolkit/components/places/tests/browser/browser_favicon.js
new file mode 100644
index 0000000000..9b4a1b97fe
--- /dev/null
+++ b/toolkit/components/places/tests/browser/browser_favicon.js
@@ -0,0 +1,74 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const lazy = {};
+ChromeUtils.defineESModuleGetters(lazy, {
+ PlacesTestUtils: "resource://testing-common/PlacesTestUtils.sys.mjs",
+});
+
+const { MockRegistrar } = ChromeUtils.importESModule(
+ "resource://testing-common/MockRegistrar.sys.mjs"
+);
+
+add_task(async function test_userpass() {
+ // Setup the prompt to avoid showing it.
+ let mockPromptService = {
+ firstTimeCalled: false,
+ confirmExBC() {
+ if (!this.firstTimeCalled) {
+ this.firstTimeCalled = true;
+ return 0;
+ }
+
+ return 1;
+ },
+ QueryInterface: ChromeUtils.generateQI(["nsIPromptService"]),
+ };
+ let mockPromptServiceCID = MockRegistrar.register(
+ "@mozilla.org/prompter;1",
+ mockPromptService
+ );
+ registerCleanupFunction(() => {
+ MockRegistrar.unregister(mockPromptServiceCID);
+ });
+
+ const pageUrl =
+ "https://user:pass@example.org/tests/toolkit/components/places/tests/browser/favicon.html";
+ const faviconUrl =
+ "https://user:pass@example.org/tests/toolkit/components/places/tests/browser/favicon-normal32.png";
+ const exposableFaviconUrl =
+ "https://example.org/tests/toolkit/components/places/tests/browser/favicon-normal32.png";
+
+ let faviconPromise = lazy.PlacesTestUtils.waitForNotification(
+ "favicon-changed",
+ async () => {
+ let faviconForExposable = await lazy.PlacesTestUtils.getDatabaseValue(
+ "moz_icons",
+ "icon_url",
+ {
+ icon_url: exposableFaviconUrl,
+ }
+ );
+ Assert.ok(faviconForExposable, "Found the icon for exposable URL");
+
+ let faviconForOriginal = await lazy.PlacesTestUtils.getDatabaseValue(
+ "moz_icons",
+ "icon_url",
+ {
+ icon_url: faviconUrl,
+ }
+ );
+ Assert.ok(!faviconForOriginal, "Not found the icon for the original URL");
+ return true;
+ }
+ );
+
+ await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl);
+ await faviconPromise;
+
+ // Clean up.
+ await PlacesUtils.history.clear();
+ gBrowser.removeCurrentTab();
+});