summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/favicons/browser_favicon_store.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /browser/base/content/test/favicons/browser_favicon_store.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/favicons/browser_favicon_store.js')
-rw-r--r--browser/base/content/test/favicons/browser_favicon_store.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/browser/base/content/test/favicons/browser_favicon_store.js b/browser/base/content/test/favicons/browser_favicon_store.js
new file mode 100644
index 0000000000..a183effe1a
--- /dev/null
+++ b/browser/base/content/test/favicons/browser_favicon_store.js
@@ -0,0 +1,56 @@
+/* Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Test that favicons are stored.
+
+registerCleanupFunction(async () => {
+ Services.cache2.clear();
+ await PlacesTestUtils.clearFavicons();
+ await PlacesUtils.history.clear();
+});
+
+async function test_icon(pageUrl, iconUrl) {
+ let iconPromise = waitForFaviconMessage(true, iconUrl);
+ let storedIconPromise = PlacesTestUtils.waitForNotification(
+ "favicon-changed",
+ events => events.some(e => e.url == pageUrl)
+ );
+ await BrowserTestUtils.withNewTab(pageUrl, async () => {
+ let { iconURL } = await iconPromise;
+ Assert.equal(iconURL, iconUrl, "Should have seen the expected icon.");
+
+ // Ensure the favicon has been stored.
+ await storedIconPromise;
+ await new Promise((resolve, reject) => {
+ PlacesUtils.favicons.getFaviconURLForPage(
+ Services.io.newURI(pageUrl),
+ foundIconURI => {
+ if (foundIconURI) {
+ Assert.equal(
+ foundIconURI.spec,
+ iconUrl,
+ "Should have stored the expected icon."
+ );
+ resolve();
+ }
+ reject();
+ }
+ );
+ });
+ });
+}
+
+add_task(async function test_icon_stored() {
+ for (let [pageUrl, iconUrl] of [
+ [
+ "https://example.net/browser/browser/base/content/test/favicons/datauri-favicon.html",
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAATklEQVRYhe3SIQ4AIBADwf7/04elBAtrVlSduGnSTDJ7cuT1PQJwwO+Hl7sAGAA07gjAAfgIBeAAoHFHAA7ARygABwCNOwJwAD5CATRgAYXh+kypw86nAAAAAElFTkSuQmCC",
+ ],
+ [
+ "https://example.net/browser/browser/base/content/test/favicons/file_favicon.html",
+ "https://example.net/browser/browser/base/content/test/favicons/file_favicon.png",
+ ],
+ ]) {
+ await test_icon(pageUrl, iconUrl);
+ }
+});