Bug 1217876 - nsIXMLHttpRequest must show the authentication prompt correctly when used by addons in e10s, r=mayhemer

This commit is contained in:
Andrea Marchesini 2016-09-25 07:50:44 +02:00
parent eb68349900
commit ff1efcb34a
3 changed files with 20 additions and 16 deletions

View File

@ -22,6 +22,8 @@
#include "nsISerializable.h"
#include "nsIAssociatedContentSecurity.h"
#include "nsIApplicationCacheService.h"
#include "nsIAuthPrompt.h"
#include "nsIAuthPrompt2.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "SerializedLoadContext.h"
@ -31,6 +33,7 @@
#include "mozilla/ipc/BackgroundUtils.h"
#include "nsIOService.h"
#include "nsICachingChannel.h"
#include "nsIPromptFactory.h"
#include "mozilla/LoadInfo.h"
#include "nsQueryObject.h"
#include "mozilla/BasePrincipal.h"
@ -175,6 +178,8 @@ NS_INTERFACE_MAP_END
NS_IMETHODIMP
HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
{
nsresult rv;
if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) ||
aIID.Equals(NS_GET_IID(nsISecureBrowserUI))) {
if (mTabParent) {
@ -189,6 +194,20 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
return NS_OK;
}
// A system XHR can be created without reference to a window, hence mTabParent
// may be null. In that case we want to let the window watcher pick a prompt
// directly.
if (!mTabParent &&
(aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
aIID.Equals(NS_GET_IID(nsIAuthPrompt2)))) {
nsCOMPtr<nsIPromptFactory> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
return wwatch->GetPrompt(nullptr, aIID,
reinterpret_cast<void**>(result));
}
// Only support nsILoadContext if child channel's callbacks did too
if (aIID.Equals(NS_GET_IID(nsILoadContext)) && mLoadContext) {
nsCOMPtr<nsILoadContext> copy = mLoadContext;
@ -202,7 +221,6 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
nsCOMPtr<nsPIDOMWindowOuter> win =frameElement->OwnerDoc()->GetWindow();
NS_ENSURE_TRUE(win, NS_ERROR_UNEXPECTED);
nsresult rv;
nsCOMPtr<nsIWindowWatcher> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);

View File

@ -10,12 +10,9 @@
#include "HttpChannelParentListener.h"
#include "mozilla/net/HttpChannelParent.h"
#include "mozilla/Unused.h"
#include "nsIAuthPrompt.h"
#include "nsIAuthPrompt2.h"
#include "nsIHttpEventSink.h"
#include "nsIHttpHeaderVisitor.h"
#include "nsIRedirectChannelRegistrar.h"
#include "nsIPromptFactory.h"
#include "nsQueryObject.h"
using mozilla::Unused;
@ -135,17 +132,6 @@ HttpChannelParentListener::GetInterface(const nsIID& aIID, void **result)
return ir->GetInterface(aIID, result);
}
if (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
aIID.Equals(NS_GET_IID(nsIAuthPrompt2))) {
nsresult rv;
nsCOMPtr<nsIPromptFactory> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
return wwatch->GetPrompt(nullptr, aIID,
reinterpret_cast<void**>(result));
}
return NS_NOINTERFACE;
}

View File

@ -50,7 +50,7 @@ skip-if = os == "linux" || toolkit == 'android' # Tests desktop prompts
[test_prompt_http.html]
skip-if = os == "linux" || toolkit == 'android' # Tests desktop prompts
[test_prompt_noWindow.html]
skip-if = e10s || toolkit == 'android' # Tests desktop prompts. e10s: bug 1217876
skip-if = toolkit == 'android' # Tests desktop prompts.
[test_prompt_promptAuth.html]
skip-if = os == "linux" || toolkit == 'android' # Tests desktop prompts
[test_prompt_promptAuth_proxy.html]