diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /toolkit/components/places/tests/browser/browser_favicon.js | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/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.js | 74 |
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(); +}); |