diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/jsonview/test/browser_jsonview_favicon.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/jsonview/test/browser_jsonview_favicon.js')
-rw-r--r-- | devtools/client/jsonview/test/browser_jsonview_favicon.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/devtools/client/jsonview/test/browser_jsonview_favicon.js b/devtools/client/jsonview/test/browser_jsonview_favicon.js new file mode 100644 index 0000000000..b03bf1a94d --- /dev/null +++ b/devtools/client/jsonview/test/browser_jsonview_favicon.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Check that, if browser.chrome.guess_favicon is enabled, the favicon.ico will +// be loaded for the JSON viewer. The favicon could be prevented from loading +// by a too strict CSP (Bug 1872504). + +const { HttpServer } = ChromeUtils.importESModule( + "resource://testing-common/httpd.sys.mjs" +); + +add_task(async function test_favicon() { + await SpecialPowers.pushPrefEnv({ + set: [["browser.chrome.guess_favicon", true]], + }); + + const httpServer = new HttpServer(); + + httpServer.registerPathHandler("/", (_, response) => { + response.setHeader("Content-Type", "application/json"); + response.write("{}"); + }); + + const faviconPromise = new Promise(resolve => { + httpServer.registerPathHandler("/favicon.ico", () => { + resolve(); + }); + }); + + httpServer.start(-1); + + const tab = await BrowserTestUtils.openNewForegroundTab({ + gBrowser, + url: `http://localhost:${httpServer.identity.primaryPort}/`, + }); + + info("Waiting for favicon request to be received by server"); + await faviconPromise; + ok("Server got request for favicon"); + + BrowserTestUtils.removeTab(tab); + + httpServer.stop(); +}); |