mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1184067 P7.7 Allow new Response() to be used in xpcshell tests. r=ehsan
This commit is contained in:
parent
2ffa8b7ffc
commit
f91929acdc
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/dom/ChannelInfo.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
@ -68,6 +69,20 @@ ChannelInfo::InitFromChannel(nsIChannel* aChannel)
|
||||
mInited = true;
|
||||
}
|
||||
|
||||
void
|
||||
ChannelInfo::InitFromChromeGlobal(nsIGlobalObject* aGlobal)
|
||||
{
|
||||
MOZ_ASSERT(!mInited, "Cannot initialize the object twice");
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
MOZ_RELEASE_ASSERT(
|
||||
nsContentUtils::IsSystemPrincipal(aGlobal->PrincipalOrNull()));
|
||||
|
||||
mSecurityInfo.Truncate();
|
||||
mRedirected = false;
|
||||
mInited = true;
|
||||
}
|
||||
|
||||
void
|
||||
ChannelInfo::InitFromIPCChannelInfo(const ipc::IPCChannelInfo& aChannelInfo)
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
class nsIChannel;
|
||||
class nsIDocument;
|
||||
class nsIGlobalObject;
|
||||
class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
@ -69,6 +70,7 @@ public:
|
||||
|
||||
void InitFromDocument(nsIDocument* aDoc);
|
||||
void InitFromChannel(nsIChannel* aChannel);
|
||||
void InitFromChromeGlobal(nsIGlobalObject* aGlobal);
|
||||
void InitFromIPCChannelInfo(const IPCChannelInfo& aChannelInfo);
|
||||
|
||||
// This restores every possible information stored from a previous channel
|
||||
|
@ -162,12 +162,15 @@ Response::Constructor(const GlobalObject& aGlobal,
|
||||
// Grab a valid channel info from the global so this response is 'valid' for
|
||||
// interception.
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global);
|
||||
MOZ_ASSERT(window);
|
||||
nsIDocument* doc = window->GetExtantDoc();
|
||||
MOZ_ASSERT(doc);
|
||||
ChannelInfo info;
|
||||
info.InitFromDocument(doc);
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global);
|
||||
if (window) {
|
||||
nsIDocument* doc = window->GetExtantDoc();
|
||||
MOZ_ASSERT(doc);
|
||||
info.InitFromDocument(doc);
|
||||
} else {
|
||||
info.InitFromChromeGlobal(global);
|
||||
}
|
||||
internalResponse->InitChannelInfo(info);
|
||||
} else {
|
||||
workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
|
||||
|
Loading…
Reference in New Issue
Block a user