mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout 3bcd9a5a33a2 (bug 814247), d9546d42054c & 8b6edf9f6b87 (bug 814638) for failures in test_bug814638.xul and also crashes on a CLOSED TREE
This commit is contained in:
parent
6a73f98f85
commit
d44c70941b
@ -642,16 +642,14 @@ SetTreeOwnerAndChromeEventHandlerOnDocshellTree(nsIDocShellTreeItem* aItem,
|
||||
NS_PRECONDITION(aItem, "Must have item");
|
||||
|
||||
aItem->SetTreeOwner(aOwner);
|
||||
nsCOMPtr<nsIDocShell> shell(do_QueryInterface(aItem));
|
||||
shell->SetChromeEventHandler(aHandler);
|
||||
|
||||
int32_t childCount = 0;
|
||||
aItem->GetChildCount(&childCount);
|
||||
for (int32_t i = 0; i < childCount; ++i) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> item;
|
||||
aItem->GetChildAt(i, getter_AddRefs(item));
|
||||
if (aHandler) {
|
||||
nsCOMPtr<nsIDocShell> shell(do_QueryInterface(item));
|
||||
shell->SetChromeEventHandler(aHandler);
|
||||
}
|
||||
SetTreeOwnerAndChromeEventHandlerOnDocshellTree(item, aOwner, aHandler);
|
||||
}
|
||||
}
|
||||
@ -1058,8 +1056,7 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
}
|
||||
|
||||
// Also make sure that the two docshells are the same type. Otherwise
|
||||
// swapping is certainly not safe. If this needs to be changed then
|
||||
// the code below needs to be audited as it assumes identical types.
|
||||
// swapping is certainly not safe.
|
||||
int32_t ourType = nsIDocShellTreeItem::typeChrome;
|
||||
int32_t otherType = nsIDocShellTreeItem::typeChrome;
|
||||
ourTreeItem->GetItemType(&ourType);
|
||||
@ -1208,15 +1205,11 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
ourParentItem->AddChild(otherTreeItem);
|
||||
otherParentItem->AddChild(ourTreeItem);
|
||||
|
||||
// Restore the correct chrome event handlers.
|
||||
ourDocshell->SetChromeEventHandler(otherChromeEventHandler);
|
||||
otherDocshell->SetChromeEventHandler(ourChromeEventHandler);
|
||||
// Restore the correct treeowners
|
||||
// (and also chrome event handlers for content frames only).
|
||||
SetTreeOwnerAndChromeEventHandlerOnDocshellTree(ourTreeItem, otherOwner,
|
||||
ourType == nsIDocShellTreeItem::typeContent ? otherChromeEventHandler : nullptr);
|
||||
otherChromeEventHandler);
|
||||
SetTreeOwnerAndChromeEventHandlerOnDocshellTree(otherTreeItem, ourOwner,
|
||||
ourType == nsIDocShellTreeItem::typeContent ? ourChromeEventHandler : nullptr);
|
||||
ourChromeEventHandler);
|
||||
|
||||
// Switch the owner content before we start calling AddTreeItemToTreeOwner.
|
||||
// Note that we rely on this to deal with setting mObservingOwnerContent to
|
||||
|
@ -50,9 +50,6 @@ MOCHITEST_CHROME_FILES = \
|
||||
test_bug800386.xul \
|
||||
test_csp_bug773891.html \
|
||||
test_domparsing.xul \
|
||||
test_bug814638.xul \
|
||||
host_bug814638.xul \
|
||||
frame_bug814638.xul \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=814638
|
||||
-->
|
||||
<window title="Mozilla Bug 814638"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<keyset>
|
||||
<key key="T" modifiers="accel" oncommand="receivedKeyEvent()"/>
|
||||
</keyset>
|
||||
|
||||
<iframe flex="1" src="about:"/>
|
||||
|
||||
</window>
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=814638
|
||||
-->
|
||||
<window title="Mozilla Bug 814638"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<iframe flex="1" src="frame_bug814638.xul"/>
|
||||
</window>
|
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=814638
|
||||
-->
|
||||
<window title="Mozilla Bug 814638"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=814638"
|
||||
target="_blank" id="link">Mozilla Bug 814638</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 814638 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function startTest() {
|
||||
let hostURL = "chrome://mochitests/content/chrome/content/base/test/chrome/host_bug814638.xul";
|
||||
let host1 = window.open(hostURL, "_blank", "chrome");
|
||||
let host2 = window.open(hostURL, "_blank", "chrome");
|
||||
|
||||
let isHost1Loaded = isHost2Loaded = false
|
||||
host1.onload = function() {
|
||||
isHost1Loaded = true;
|
||||
if (isHost2Loaded) swapFrames();
|
||||
}
|
||||
host2.onload = function() {
|
||||
isHost2Loaded = true;
|
||||
if (isHost1Loaded) swapFrames();
|
||||
}
|
||||
|
||||
function swapFrames() {
|
||||
let iframe1 = host1.document.querySelector("iframe");
|
||||
let iframe2 = host2.document.querySelector("iframe");
|
||||
iframe2.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
|
||||
iframe2.swapFrameLoaders(iframe1);
|
||||
setTimeout(function() {
|
||||
iframe2.contentWindow.receivedKeyEvent = receivedKeyEvent;
|
||||
let innerIframe2 = iframe2.contentDocument.querySelector("iframe");
|
||||
let e = innerIframe2.contentDocument.createEvent("KeyboardEvent");
|
||||
e.initKeyEvent("keypress", true, true, null, true, false, false, false, 0, "t".charCodeAt(0));
|
||||
innerIframe2.contentDocument.documentElement.dispatchEvent(e);
|
||||
host1.close();
|
||||
host2.close();
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function receivedKeyEvent() {
|
||||
ok(true, "Received key event");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(startTest);
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
@ -40,7 +40,7 @@ function testHttpAuthCancel(e) {
|
||||
iframe.addEventListener("mozbrowsertitlechange", function onTitleChange(e) {
|
||||
iframe.removeEventListener("mozbrowsertitlechange", onTitleChange);
|
||||
iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFail);
|
||||
is(e.detail, 'http auth failed', 'expected authentication to fail');
|
||||
is(e.detail, 'http auth failed');
|
||||
iframe.addEventListener('mozbrowserusernameandpasswordrequired', testHttpAuth);
|
||||
SimpleTest.executeSoon(function() {
|
||||
// Use absolute path because we need to specify host.
|
||||
@ -48,8 +48,8 @@ function testHttpAuthCancel(e) {
|
||||
});
|
||||
});
|
||||
|
||||
is(e.detail.realm, 'http_realm', 'expected realm matches');
|
||||
is(e.detail.host, 'http://test', 'expected host matches');
|
||||
is(e.detail.realm, 'http_realm');
|
||||
is(e.detail.host, 'http://test');
|
||||
e.preventDefault();
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
@ -66,12 +66,12 @@ function testHttpAuth(e) {
|
||||
iframe.addEventListener("mozbrowsertitlechange", function onTitleChange(e) {
|
||||
iframe.removeEventListener("mozbrowsertitlechange", onTitleChange);
|
||||
iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFail);
|
||||
is(e.detail, 'http auth success', 'expect authentication to succeed');
|
||||
SimpleTest.executeSoon(testAuthJarNoInterfere);
|
||||
is(e.detail, 'http auth success');
|
||||
SimpleTest.executeSoon(testFinish);
|
||||
});
|
||||
|
||||
is(e.detail.realm, 'http_realm', 'expected realm matches');
|
||||
is(e.detail.host, 'http://test', 'expected host matches');
|
||||
is(e.detail.realm, 'http_realm');
|
||||
is(e.detail.host, 'http://test');
|
||||
e.preventDefault();
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
@ -79,77 +79,7 @@ function testHttpAuth(e) {
|
||||
});
|
||||
}
|
||||
|
||||
function testAuthJarNoInterfere(e) {
|
||||
var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1']
|
||||
.getService(SpecialPowers.Ci.nsIHttpAuthManager);
|
||||
var secMan = SpecialPowers.Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(SpecialPowers.Ci.nsIScriptSecurityManager);
|
||||
var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIIOService);
|
||||
var uri = ioService.newURI("http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs", null, null);
|
||||
|
||||
// Set a bunch of auth data that should not conflict with the correct auth data already
|
||||
// stored in the cache.
|
||||
var principal = secMan.getAppCodebasePrincipal(uri, 1, false);
|
||||
authMgr.setAuthIdentity('http', 'test', -1, 'basic', 'http_realm',
|
||||
'tests/dom/browser-element/mochitest/file_http_401_response.sjs',
|
||||
'', 'httpuser', 'wrongpass', false, principal);
|
||||
principal = secMan.getAppCodebasePrincipal(uri, 1, true);
|
||||
authMgr.setAuthIdentity('http', 'test', -1, 'basic', 'http_realm',
|
||||
'tests/dom/browser-element/mochitest/file_http_401_response.sjs',
|
||||
'', 'httpuser', 'wrongpass', false, principal);
|
||||
principal = secMan.getAppCodebasePrincipal(uri, secMan.NO_APP_ID, false);
|
||||
authMgr.setAuthIdentity('http', 'test', -1, 'basic', 'http_realm',
|
||||
'tests/dom/browser-element/mochitest/file_http_401_response.sjs',
|
||||
'', 'httpuser', 'wrongpass', false, principal);
|
||||
|
||||
// Will authenticate with correct password, prompt should not be
|
||||
// called again.
|
||||
iframe.addEventListener("mozbrowserusernameandpasswordrequired", testFail);
|
||||
iframe.addEventListener("mozbrowsertitlechange", function onTitleChange(e) {
|
||||
iframe.removeEventListener("mozbrowsertitlechange", onTitleChange);
|
||||
iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFail);
|
||||
is(e.detail, 'http auth success', 'expected authentication success');
|
||||
SimpleTest.executeSoon(testAuthJarInterfere);
|
||||
});
|
||||
|
||||
// Once more with feeling. Ensure that our new auth data doesn't interfere with this mozbrowser's
|
||||
// auth data.
|
||||
iframe.src = 'http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs';
|
||||
}
|
||||
|
||||
function testAuthJarInterfere(e) {
|
||||
var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1']
|
||||
.getService(SpecialPowers.Ci.nsIHttpAuthManager);
|
||||
var secMan = SpecialPowers.Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(SpecialPowers.Ci.nsIScriptSecurityManager);
|
||||
var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIIOService);
|
||||
var uri = ioService.newURI("http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs", null, null);
|
||||
|
||||
// Set some auth data that should overwrite the successful stored details.
|
||||
var principal = secMan.getAppCodebasePrincipal(uri, secMan.NO_APP_ID, true);
|
||||
authMgr.setAuthIdentity('http', 'test', -1, 'basic', 'http_realm',
|
||||
'tests/dom/browser-element/mochitest/file_http_401_response.sjs',
|
||||
'', 'httpuser', 'wrongpass', false, principal);
|
||||
|
||||
// Will authenticate with correct password, prompt should not be
|
||||
// called again.
|
||||
iframe.addEventListener("mozbrowserusernameandpasswordrequired", testFinish);
|
||||
iframe.addEventListener("mozbrowsertitlechange", function onTitleChange(e) {
|
||||
iframe.removeEventListener("mozbrowsertitlechange", onTitleChange);
|
||||
iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFinish);
|
||||
SimpleTest.execute(testFail);
|
||||
});
|
||||
|
||||
// Once more with feeling. Ensure that our new auth data interferes with this mozbrowser's
|
||||
// auth data.
|
||||
iframe.src = 'http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs';
|
||||
}
|
||||
|
||||
function testFinish() {
|
||||
iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFinish);
|
||||
|
||||
// Clear login information stored in password manager.
|
||||
var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1']
|
||||
.getService(SpecialPowers.Ci.nsIHttpAuthManager);
|
||||
|
@ -2771,16 +2771,12 @@ _getauthenticationinfo(NPP instance, const char *protocol, const char *host,
|
||||
bool authPrivate = false;
|
||||
GetPrivacyFromNPP(instance, &authPrivate);
|
||||
|
||||
nsIDocument *doc = GetDocumentFromNPP(instance);
|
||||
NS_ENSURE_TRUE(doc, NPERR_GENERIC_ERROR);
|
||||
nsIPrincipal *principal = doc->NodePrincipal();
|
||||
|
||||
nsAutoString unused, uname16, pwd16;
|
||||
if (NS_FAILED(authManager->GetAuthIdentity(proto, nsDependentCString(host),
|
||||
port, nsDependentCString(scheme),
|
||||
nsDependentCString(realm),
|
||||
EmptyCString(), unused, uname16,
|
||||
pwd16, authPrivate, principal))) {
|
||||
pwd16, authPrivate))) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -9,20 +9,11 @@
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prprf.h"
|
||||
#include "mozIApplicationClearPrivateDataParams.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static inline void
|
||||
GetAuthKey(const char *scheme, const char *host, int32_t port, uint32_t appId, bool inBrowserElement, nsCString &key)
|
||||
GetAuthKey(const char *scheme, const char *host, int32_t port, nsCString &key)
|
||||
{
|
||||
key.Truncate();
|
||||
key.AppendInt(appId);
|
||||
key.Append(':');
|
||||
key.AppendInt(inBrowserElement);
|
||||
key.Append(':');
|
||||
key.Append(scheme);
|
||||
key.Assign(scheme);
|
||||
key.AppendLiteral("://");
|
||||
key.Append(host);
|
||||
key.Append(':');
|
||||
@ -50,23 +41,13 @@ StrEquivalent(const PRUnichar *a, const PRUnichar *b)
|
||||
|
||||
nsHttpAuthCache::nsHttpAuthCache()
|
||||
: mDB(nullptr)
|
||||
, mObserver(new AppDataClearObserver(this))
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
|
||||
if (obsSvc) {
|
||||
obsSvc->AddObserver(mObserver, "webapps-clear-data", false);
|
||||
}
|
||||
}
|
||||
|
||||
nsHttpAuthCache::~nsHttpAuthCache()
|
||||
{
|
||||
if (mDB)
|
||||
ClearAll();
|
||||
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
|
||||
if (obsSvc) {
|
||||
obsSvc->RemoveObserver(mObserver, "webapps-clear-data");
|
||||
mObserver->mOwner = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -90,15 +71,13 @@ nsHttpAuthCache::GetAuthEntryForPath(const char *scheme,
|
||||
const char *host,
|
||||
int32_t port,
|
||||
const char *path,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
nsHttpAuthEntry **entry)
|
||||
{
|
||||
LOG(("nsHttpAuthCache::GetAuthEntryForPath [key=%s://%s:%d path=%s]\n",
|
||||
scheme, host, port, path));
|
||||
|
||||
nsAutoCString key;
|
||||
nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, appId, inBrowserElement, key);
|
||||
nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, key);
|
||||
if (!node)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
@ -111,8 +90,6 @@ nsHttpAuthCache::GetAuthEntryForDomain(const char *scheme,
|
||||
const char *host,
|
||||
int32_t port,
|
||||
const char *realm,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
nsHttpAuthEntry **entry)
|
||||
|
||||
{
|
||||
@ -120,7 +97,7 @@ nsHttpAuthCache::GetAuthEntryForDomain(const char *scheme,
|
||||
scheme, host, port, realm));
|
||||
|
||||
nsAutoCString key;
|
||||
nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, appId, inBrowserElement, key);
|
||||
nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, key);
|
||||
if (!node)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
@ -136,8 +113,6 @@ nsHttpAuthCache::SetAuthEntry(const char *scheme,
|
||||
const char *realm,
|
||||
const char *creds,
|
||||
const char *challenge,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
const nsHttpAuthIdentity *ident,
|
||||
nsISupports *metadata)
|
||||
{
|
||||
@ -152,7 +127,7 @@ nsHttpAuthCache::SetAuthEntry(const char *scheme,
|
||||
}
|
||||
|
||||
nsAutoCString key;
|
||||
nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, appId, inBrowserElement, key);
|
||||
nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, key);
|
||||
|
||||
if (!node) {
|
||||
// create a new entry node and set the given entry
|
||||
@ -174,15 +149,13 @@ void
|
||||
nsHttpAuthCache::ClearAuthEntry(const char *scheme,
|
||||
const char *host,
|
||||
int32_t port,
|
||||
const char *realm,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement)
|
||||
const char *realm)
|
||||
{
|
||||
if (!mDB)
|
||||
return;
|
||||
|
||||
nsAutoCString key;
|
||||
GetAuthKey(scheme, host, port, appId, inBrowserElement, key);
|
||||
GetAuthKey(scheme, host, port, key);
|
||||
PL_HashTableRemove(mDB, key.get());
|
||||
}
|
||||
|
||||
@ -206,14 +179,12 @@ nsHttpAuthNode *
|
||||
nsHttpAuthCache::LookupAuthNode(const char *scheme,
|
||||
const char *host,
|
||||
int32_t port,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
nsCString &key)
|
||||
{
|
||||
if (!mDB)
|
||||
return nullptr;
|
||||
|
||||
GetAuthKey(scheme, host, port, appId, inBrowserElement, key);
|
||||
GetAuthKey(scheme, host, port, key);
|
||||
|
||||
return (nsHttpAuthNode *) PL_HashTableLookup(mDB, key.get());
|
||||
}
|
||||
@ -261,59 +232,6 @@ PLHashAllocOps nsHttpAuthCache::gHashAllocOps =
|
||||
nsHttpAuthCache::FreeEntry
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsHttpAuthCache::AppDataClearObserver, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpAuthCache::AppDataClearObserver::Observe(nsISupports *subject,
|
||||
const char * topic,
|
||||
const PRUnichar * data_unicode)
|
||||
{
|
||||
NS_ENSURE_TRUE(mOwner, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsCOMPtr<mozIApplicationClearPrivateDataParams> params =
|
||||
do_QueryInterface(subject);
|
||||
if (!params) {
|
||||
NS_ERROR("'webapps-clear-data' notification's subject should be a mozIApplicationClearPrivateDataParams");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
uint32_t appId;
|
||||
bool browserOnly;
|
||||
|
||||
nsresult rv = params->GetAppId(&appId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = params->GetBrowserOnly(&browserOnly);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MOZ_ASSERT(appId != NECKO_UNKNOWN_APP_ID);
|
||||
mOwner->ClearAppData(appId, browserOnly);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
RemoveEntriesForApp(PLHashEntry *entry, int32_t number, void *arg)
|
||||
{
|
||||
nsDependentCString key(static_cast<const char*>(entry->key));
|
||||
nsAutoCString* prefix = static_cast<nsAutoCString*>(arg);
|
||||
if (StringBeginsWith(key, *prefix)) {
|
||||
return HT_ENUMERATE_NEXT | HT_ENUMERATE_REMOVE;
|
||||
}
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpAuthCache::ClearAppData(uint32_t appId, bool browserOnly)
|
||||
{
|
||||
nsAutoCString keyPrefix;
|
||||
keyPrefix.AppendInt(appId);
|
||||
keyPrefix.Append(':');
|
||||
if (browserOnly) {
|
||||
keyPrefix.AppendInt(browserOnly);
|
||||
keyPrefix.Append(':');
|
||||
}
|
||||
PL_HashTableEnumerateEntries(mDB, RemoveEntriesForApp, &keyPrefix);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpAuthIdentity
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "plhash.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
|
||||
|
||||
struct nsHttpAuthPath {
|
||||
@ -182,8 +180,6 @@ public:
|
||||
const char *host,
|
||||
int32_t port,
|
||||
const char *path,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
nsHttpAuthEntry **entry);
|
||||
|
||||
// |scheme|, |host|, and |port| are required
|
||||
@ -193,8 +189,6 @@ public:
|
||||
const char *host,
|
||||
int32_t port,
|
||||
const char *realm,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
nsHttpAuthEntry **entry);
|
||||
|
||||
// |scheme|, |host|, and |port| are required
|
||||
@ -209,17 +203,13 @@ public:
|
||||
const char *realm,
|
||||
const char *credentials,
|
||||
const char *challenge,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
const nsHttpAuthIdentity *ident,
|
||||
nsISupports *metadata);
|
||||
|
||||
void ClearAuthEntry(const char *scheme,
|
||||
const char *host,
|
||||
int32_t port,
|
||||
const char *realm,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement);
|
||||
const char *realm);
|
||||
|
||||
// expire all existing auth list entries including proxy auths.
|
||||
nsresult ClearAll();
|
||||
@ -228,8 +218,6 @@ private:
|
||||
nsHttpAuthNode *LookupAuthNode(const char *scheme,
|
||||
const char *host,
|
||||
int32_t port,
|
||||
uint32_t appId,
|
||||
bool inBrowserElement,
|
||||
nsCString &key);
|
||||
|
||||
// hash table allocation functions
|
||||
@ -239,21 +227,9 @@ private:
|
||||
static void FreeEntry(void *, PLHashEntry *he, unsigned flag);
|
||||
|
||||
static PLHashAllocOps gHashAllocOps;
|
||||
|
||||
class AppDataClearObserver : public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
AppDataClearObserver(nsHttpAuthCache* aOwner) : mOwner(aOwner) {}
|
||||
virtual ~AppDataClearObserver() {}
|
||||
nsHttpAuthCache* mOwner;
|
||||
};
|
||||
|
||||
void ClearAppData(uint32_t appId, bool browserOnly);
|
||||
|
||||
private:
|
||||
PLHashTable *mDB; // "host:port" --> nsHttpAuthNode
|
||||
nsRefPtr<AppDataClearObserver> mObserver;
|
||||
};
|
||||
|
||||
#endif // nsHttpAuthCache_h__
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "nsHttpAuthManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsHttpAuthManager, nsIHttpAuthManager)
|
||||
|
||||
@ -57,32 +56,22 @@ nsHttpAuthManager::GetAuthIdentity(const nsACString & aScheme,
|
||||
nsAString & aUserDomain,
|
||||
nsAString & aUserName,
|
||||
nsAString & aUserPassword,
|
||||
bool aIsPrivate,
|
||||
nsIPrincipal* aPrincipal)
|
||||
bool aIsPrivate)
|
||||
{
|
||||
nsHttpAuthCache* auth_cache = aIsPrivate ? mPrivateAuthCache : mAuthCache;
|
||||
nsHttpAuthEntry * entry = nullptr;
|
||||
nsresult rv;
|
||||
uint32_t appId = NECKO_NO_APP_ID;
|
||||
bool inBrowserElement = false;
|
||||
if (aPrincipal) {
|
||||
appId = aPrincipal->GetAppId();
|
||||
inBrowserElement = aPrincipal->GetIsInBrowserElement();
|
||||
}
|
||||
|
||||
if (!aPath.IsEmpty())
|
||||
rv = auth_cache->GetAuthEntryForPath(PromiseFlatCString(aScheme).get(),
|
||||
PromiseFlatCString(aHost).get(),
|
||||
aPort,
|
||||
PromiseFlatCString(aPath).get(),
|
||||
appId, inBrowserElement,
|
||||
&entry);
|
||||
else
|
||||
rv = auth_cache->GetAuthEntryForDomain(PromiseFlatCString(aScheme).get(),
|
||||
PromiseFlatCString(aHost).get(),
|
||||
aPort,
|
||||
PromiseFlatCString(aRealm).get(),
|
||||
appId, inBrowserElement,
|
||||
&entry);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
@ -106,20 +95,12 @@ nsHttpAuthManager::SetAuthIdentity(const nsACString & aScheme,
|
||||
const nsAString & aUserDomain,
|
||||
const nsAString & aUserName,
|
||||
const nsAString & aUserPassword,
|
||||
bool aIsPrivate,
|
||||
nsIPrincipal* aPrincipal)
|
||||
bool aIsPrivate)
|
||||
{
|
||||
nsHttpAuthIdentity ident(PromiseFlatString(aUserDomain).get(),
|
||||
PromiseFlatString(aUserName).get(),
|
||||
PromiseFlatString(aUserPassword).get());
|
||||
|
||||
uint32_t appId = NECKO_NO_APP_ID;
|
||||
bool inBrowserElement = false;
|
||||
if (aPrincipal) {
|
||||
appId = aPrincipal->GetAppId();
|
||||
inBrowserElement = aPrincipal->GetIsInBrowserElement();
|
||||
}
|
||||
|
||||
nsHttpAuthCache* auth_cache = aIsPrivate ? mPrivateAuthCache : mAuthCache;
|
||||
return auth_cache->SetAuthEntry(PromiseFlatCString(aScheme).get(),
|
||||
PromiseFlatCString(aHost).get(),
|
||||
@ -128,7 +109,6 @@ nsHttpAuthManager::SetAuthIdentity(const nsACString & aScheme,
|
||||
PromiseFlatCString(aRealm).get(),
|
||||
nullptr, // credentials
|
||||
nullptr, // challenge
|
||||
appId, inBrowserElement,
|
||||
&ident,
|
||||
nullptr); // metadata
|
||||
}
|
||||
|
@ -20,23 +20,6 @@
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIDNSRecord.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static void
|
||||
GetAppIdAndBrowserStatus(nsIChannel* aChan, uint32_t* aAppId, bool* aInBrowserElem)
|
||||
{
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
if (aChan) {
|
||||
NS_QueryNotificationCallbacks(aChan, loadContext);
|
||||
}
|
||||
if (!loadContext) {
|
||||
*aAppId = NECKO_NO_APP_ID;
|
||||
*aInBrowserElem = false;
|
||||
} else {
|
||||
loadContext->GetAppId(aAppId);
|
||||
loadContext->GetIsInBrowserElement(aInBrowserElem);
|
||||
}
|
||||
}
|
||||
|
||||
nsHttpChannelAuthProvider::nsHttpChannelAuthProvider()
|
||||
: mAuthChannel(nullptr)
|
||||
@ -389,11 +372,6 @@ nsHttpChannelAuthProvider::GenCredsAndSetEntry(nsIHttpAuthenticator *auth,
|
||||
// this getter never fails
|
||||
nsHttpAuthCache *authCache = gHttpHandler->AuthCache(mIsPrivate);
|
||||
|
||||
nsCOMPtr<nsIChannel> chan = do_QueryInterface(mAuthChannel);
|
||||
uint32_t appId;
|
||||
bool isInBrowserElement;
|
||||
GetAppIdAndBrowserStatus(chan, &appId, &isInBrowserElement);
|
||||
|
||||
// create a cache entry. we do this even though we don't yet know that
|
||||
// these credentials are valid b/c we need to avoid prompting the user
|
||||
// more than once in case the credentials are valid.
|
||||
@ -403,7 +381,6 @@ nsHttpChannelAuthProvider::GenCredsAndSetEntry(nsIHttpAuthenticator *auth,
|
||||
rv = authCache->SetAuthEntry(scheme, host, port, directory, realm,
|
||||
saveCreds ? *result : nullptr,
|
||||
saveChallenge ? challenge : nullptr,
|
||||
appId, isInBrowserElement,
|
||||
saveIdentity ? &ident : nullptr,
|
||||
sessionState);
|
||||
return rv;
|
||||
@ -717,11 +694,6 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> chan = do_QueryInterface(mAuthChannel);
|
||||
uint32_t appId;
|
||||
bool isInBrowserElement;
|
||||
GetAppIdAndBrowserStatus(chan, &appId, &isInBrowserElement);
|
||||
|
||||
//
|
||||
// if we already tried some credentials for this transaction, then
|
||||
// we need to possibly clear them from the cache, unless the credentials
|
||||
@ -730,8 +702,7 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
|
||||
//
|
||||
nsHttpAuthEntry *entry = nullptr;
|
||||
authCache->GetAuthEntryForDomain(scheme.get(), host, port,
|
||||
realm.get(), appId,
|
||||
isInBrowserElement, &entry);
|
||||
realm.get(), &entry);
|
||||
|
||||
// hold reference to the auth session state (in case we clear our
|
||||
// reference to the entry).
|
||||
@ -761,8 +732,7 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
|
||||
// ok, we've already tried this user identity, so clear the
|
||||
// corresponding entry from the auth cache.
|
||||
authCache->ClearAuthEntry(scheme.get(), host,
|
||||
port, realm.get(),
|
||||
appId, isInBrowserElement);
|
||||
port, realm.get());
|
||||
entry = nullptr;
|
||||
ident->Clear();
|
||||
}
|
||||
@ -1087,17 +1057,10 @@ NS_IMETHODIMP nsHttpChannelAuthProvider::OnAuthAvailable(nsISupports *aContext,
|
||||
nsAutoCString realm;
|
||||
ParseRealm(mCurrentChallenge.get(), realm);
|
||||
|
||||
nsCOMPtr<nsIChannel> chan = do_QueryInterface(mAuthChannel);
|
||||
uint32_t appId;
|
||||
bool isInBrowserElement;
|
||||
GetAppIdAndBrowserStatus(chan, &appId, &isInBrowserElement);
|
||||
|
||||
nsHttpAuthCache *authCache = gHttpHandler->AuthCache(mIsPrivate);
|
||||
nsHttpAuthEntry *entry = nullptr;
|
||||
authCache->GetAuthEntryForDomain(scheme.get(), host, port,
|
||||
realm.get(), appId,
|
||||
isInBrowserElement,
|
||||
&entry);
|
||||
realm.get(), &entry);
|
||||
|
||||
nsCOMPtr<nsISupports> sessionStateGrip;
|
||||
if (entry)
|
||||
@ -1329,13 +1292,7 @@ nsHttpChannelAuthProvider::SetAuthorizationHeader(nsHttpAuthCache *authCache,
|
||||
continuationState = &mAuthContinuationState;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> chan = do_QueryInterface(mAuthChannel);
|
||||
uint32_t appId;
|
||||
bool isInBrowserElement;
|
||||
GetAppIdAndBrowserStatus(chan, &appId, &isInBrowserElement);
|
||||
|
||||
rv = authCache->GetAuthEntryForPath(scheme, host, port, path,
|
||||
appId, isInBrowserElement, &entry);
|
||||
rv = authCache->GetAuthEntryForPath(scheme, host, port, path, &entry);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// if we are trying to add a header for origin server auth and if the
|
||||
// URL contains an explicit username, then try the given username first.
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIPrincipal;
|
||||
|
||||
/**
|
||||
* nsIHttpAuthManager
|
||||
*
|
||||
@ -21,7 +19,7 @@ interface nsIPrincipal;
|
||||
* Java client fetches content from a HTTP site that the user
|
||||
* has already logged into.
|
||||
*/
|
||||
[scriptable, uuid(54f90444-c52b-4d2d-8916-c59a2bb25938)]
|
||||
[scriptable, uuid(1301b517-ac72-48f6-a781-70c196eaaf3d)]
|
||||
interface nsIHttpAuthManager : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -47,12 +45,6 @@ interface nsIHttpAuthManager : nsISupports
|
||||
* return value containing user name.
|
||||
* @param aUserPassword
|
||||
* return value containing user password.
|
||||
* @param aIsPrivate
|
||||
* whether to look up a private or public identity (they are
|
||||
* stored separately, for use by private browsing)
|
||||
* @param aPrincipal
|
||||
* the principal from which to derive information about which
|
||||
* app/mozbrowser is in use for this request
|
||||
*/
|
||||
void getAuthIdentity(in ACString aScheme,
|
||||
in ACString aHost,
|
||||
@ -63,8 +55,7 @@ interface nsIHttpAuthManager : nsISupports
|
||||
out AString aUserDomain,
|
||||
out AString aUserName,
|
||||
out AString aUserPassword,
|
||||
[optional] in bool aIsPrivate,
|
||||
[optional] in nsIPrincipal aPrincipal);
|
||||
[optional] in bool aIsPrivate);
|
||||
|
||||
/**
|
||||
* Store auth identity.
|
||||
@ -89,12 +80,6 @@ interface nsIHttpAuthManager : nsISupports
|
||||
* optional string containing user name.
|
||||
* @param aUserPassword
|
||||
* optional string containing user password.
|
||||
* @param aIsPrivate
|
||||
* whether to store a private or public identity (they are
|
||||
* stored separately, for use by private browsing)
|
||||
* @param aPrincipal
|
||||
* the principal from which to derive information about which
|
||||
* app/mozbrowser is in use for this request
|
||||
*/
|
||||
void setAuthIdentity(in ACString aScheme,
|
||||
in ACString aHost,
|
||||
@ -105,8 +90,7 @@ interface nsIHttpAuthManager : nsISupports
|
||||
in AString aUserDomain,
|
||||
in AString aUserName,
|
||||
in AString aUserPassword,
|
||||
[optional] in boolean aIsPrivate,
|
||||
[optional] in nsIPrincipal aPrincipal);
|
||||
[optional] in boolean aIsPrivate);
|
||||
|
||||
/**
|
||||
* Clear all auth cache.
|
||||
|
@ -1,52 +0,0 @@
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function createURI(s) {
|
||||
let service = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
return service.newURI(s, null, null);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
|
||||
const kURI1 = "http://example.com";
|
||||
var app1 = secMan.getAppCodebasePrincipal(createURI(kURI1), 1, false);
|
||||
var app10 = secMan.getAppCodebasePrincipal(createURI(kURI1), 10, false);
|
||||
var app1browser = secMan.getAppCodebasePrincipal(createURI(kURI1), 1, true);
|
||||
|
||||
var am = Cc["@mozilla.org/network/http-auth-manager;1"].
|
||||
getService(Ci.nsIHttpAuthManager);
|
||||
am.setAuthIdentity("http", "a.example.com", -1, "basic", "realm", "", "example.com", "user", "pass", false, app1);
|
||||
am.setAuthIdentity("http", "a.example.com", -1, "basic", "realm", "", "example.com", "user3", "pass3", false, app1browser);
|
||||
am.setAuthIdentity("http", "a.example.com", -1, "basic", "realm", "", "example.com", "user2", "pass2", false, app10);
|
||||
|
||||
let subject = {
|
||||
appId: 1,
|
||||
browserOnly: false,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.mozIApplicationClearPrivateDataParams])
|
||||
};
|
||||
Services.obs.notifyObservers(subject, "webapps-clear-data", null);
|
||||
|
||||
var domain = {value: ""}, user = {value: ""}, pass = {value: ""};
|
||||
try {
|
||||
am.getAuthIdentity("http", "a.example.com", -1, "basic", "realm", "", domain, user, pass, false, app1);
|
||||
do_check_false(true); // no identity should be present
|
||||
} catch (x) {
|
||||
do_check_eq(domain.value, "");
|
||||
do_check_eq(user.value, "");
|
||||
do_check_eq(pass.value, "");
|
||||
}
|
||||
|
||||
am.getAuthIdentity("http", "a.example.com", -1, "basic", "realm", "", domain, user, pass, false, app1browser);
|
||||
do_check_eq(domain.value, "example.com");
|
||||
do_check_eq(user.value, "user3");
|
||||
do_check_eq(pass.value, "pass3");
|
||||
|
||||
|
||||
am.getAuthIdentity("http", "a.example.com", -1, "basic", "realm", "", domain, user, pass, false, app10);
|
||||
do_check_eq(domain.value, "example.com");
|
||||
do_check_eq(user.value, "user2");
|
||||
do_check_eq(pass.value, "pass2");
|
||||
}
|
@ -9,7 +9,6 @@ tail =
|
||||
[test_URIs.js]
|
||||
[test_aboutblank.js]
|
||||
[test_assoc.js]
|
||||
[test_auth_jar.js]
|
||||
[test_auth_proxy.js]
|
||||
[test_authentication.js]
|
||||
# Bug 675039: test hangs consistently on Android
|
||||
|
Loading…
Reference in New Issue
Block a user