diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp index dd801120857b..56ee35a66d00 100644 --- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp +++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp @@ -1542,15 +1542,15 @@ void nsHttpChannelAuthProvider::SetAuthorizationHeader( // or a webserver nsISupports **continuationState; + nsAutoCString suffix; if (header == nsHttp::Proxy_Authorization) { continuationState = &mProxyAuthContinuationState; } else { continuationState = &mAuthContinuationState; - } - nsCOMPtr chan = do_QueryInterface(mAuthChannel); - nsAutoCString suffix; - GetOriginAttributesSuffix(chan, suffix); + nsCOMPtr chan = do_QueryInterface(mAuthChannel); + GetOriginAttributesSuffix(chan, suffix); + } rv = authCache->GetAuthEntryForPath(scheme, host, port, path, suffix, &entry); if (NS_SUCCEEDED(rv)) { diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js index 37e9c3962e80..56fbffb66a41 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js @@ -1,5 +1,9 @@ "use strict"; +XPCOMUtils.defineLazyServiceGetter(this, "authManager", + "@mozilla.org/network/http-auth-manager;1", + "nsIHttpAuthManager"); + const proxy = createHttpServer(); // accept proxy connections for mozilla.org @@ -74,6 +78,8 @@ add_task(async function test_webRequest_auth_proxy() { await handlingExt.startup(); await handlingExt.awaitMessage("pac-ready"); + authManager.clearAll(); + let contentPage = await ExtensionTestUtils.loadContentPage(`http://mozilla.org/`); await handlingExt.awaitMessage("done"); @@ -112,12 +118,12 @@ add_task(async function test_webRequest_auth_proxy_system() { xhr.open("GET", url); xhr.onload = () => { resolve(xhr.responseText); }; xhr.onerror = () => { reject(xhr.status); }; - // use a different contextId to avoid auth cache. - xhr.setOriginAttributes({userContextId: 1}); xhr.send(); }); } + authManager.clearAll(); + await Promise.all([ handlingExt.awaitMessage("onAuthRequired"), fetch("http://mozilla.org"), diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_onauthrequired.js b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_onauthrequired.js index 4a5f37d59f96..73fac0d89e92 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_onauthrequired.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_onauthrequired.js @@ -1,5 +1,9 @@ "use strict"; +XPCOMUtils.defineLazyServiceGetter(this, "authManager", + "@mozilla.org/network/http-auth-manager;1", + "nsIHttpAuthManager"); + const proxy = createHttpServer(); // accept proxy connections for mozilla.org @@ -76,6 +80,8 @@ add_task(async function test_webRequest_auth_proxy() { await handlingExt.startup(); await handlingExt.awaitMessage("ready"); + authManager.clearAll(); + let contentPage = await ExtensionTestUtils.loadContentPage(`http://mozilla.org/`); await handlingExt.awaitMessage("done"); @@ -112,6 +118,8 @@ add_task(async function test_webRequest_auth_proxy_system() { await handlingExt.startup(); await handlingExt.awaitMessage("ready"); + authManager.clearAll(); + function fetch(url) { return new Promise((resolve, reject) => { let xhr = new XMLHttpRequest(); @@ -119,8 +127,6 @@ add_task(async function test_webRequest_auth_proxy_system() { xhr.open("GET", url); xhr.onload = () => { resolve(xhr.responseText); }; xhr.onerror = () => { reject(xhr.status); }; - // use a different contextId to avoid auth cache. - xhr.setOriginAttributes({userContextId: 1}); xhr.send(); }); }