Bug 1517029: Fail favicon requests when encountering an icon that requires credentials. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D15768

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dave Townsend 2019-01-07 17:57:46 +00:00
parent db7545da18
commit 1c728fbeac
6 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>Favicon Test for http auth</title>
<link rel="icon" type="image/png" href="auth_test.png" />
</head>
<body>
Favicon!!
</body>
</html>

View File

@ -0,0 +1,2 @@
HTTP 401 Unauthorized
WWW-Authenticate: Basic realm="Favicon auth"

View File

@ -70,6 +70,11 @@ support-files =
support-files =
large_favicon.html
large.png
[browser_favicon_auth.js]
support-files =
auth_test.html
auth_test.png
auth_test.png^headers^
[browser_favicon_accept.js]
support-files =
accept.html

View File

@ -0,0 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const ROOT = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://mochi.test:8888/");
add_task(async () => {
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, async (browser) => {
let faviconPromise = waitForFaviconMessage(true, `${ROOT}auth_test.png`);
BrowserTestUtils.loadURI(browser, `${ROOT}auth_test.html`);
await BrowserTestUtils.browserLoaded(browser);
await Assert.rejects(faviconPromise, result => {
return result.iconURL == `${ROOT}auth_test.png`;
}, "Should have failed to load the icon.");
});
});

View File

@ -117,6 +117,10 @@ class FaviconLoad {
}
}
if (this.channel instanceof Ci.nsIHttpChannelInternal) {
this.channel.blockAuthPrompt = true;
}
if (Services.prefs.getBoolPref("network.http.tailing.enabled", true) &&
this.channel instanceof Ci.nsIClassOfService) {
this.channel.addClassFlags(Ci.nsIClassOfService.Tail | Ci.nsIClassOfService.Throttleable);