зеркало из https://github.com/mozilla/gecko-dev.git
Bug 753981 - 'XHR in Web Workers bypasses Offline AppCache'. r=smaug.
This commit is contained in:
Родитель
b51b4ca7f7
Коммит
038e0fa5f4
|
@ -465,6 +465,8 @@ nsXMLHttpRequest::Init(nsIPrincipal* aPrincipal,
|
|||
nsPIDOMWindow* aOwnerWindow,
|
||||
nsIURI* aBaseURI)
|
||||
{
|
||||
NS_ASSERTION(!aOwnerWindow || aOwnerWindow->IsOuterWindow(),
|
||||
"Expecting an outer window here!");
|
||||
NS_ENSURE_ARG_POINTER(aPrincipal);
|
||||
Construct(aPrincipal,
|
||||
aOwnerWindow ? aOwnerWindow->GetCurrentInnerWindow() : nullptr,
|
||||
|
|
|
@ -154,12 +154,26 @@ public:
|
|||
NS_ASSERTION(mWorkerPrivate, "Must have a worker here!");
|
||||
|
||||
if (!mXHR) {
|
||||
nsPIDOMWindow* ownerWindow = mWorkerPrivate->GetWindow();
|
||||
if (ownerWindow) {
|
||||
ownerWindow = ownerWindow->GetOuterWindow();
|
||||
if (!ownerWindow) {
|
||||
NS_ERROR("No outer window?!");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsPIDOMWindow* innerWindow = ownerWindow->GetCurrentInnerWindow();
|
||||
if (mWorkerPrivate->GetWindow() != innerWindow) {
|
||||
NS_WARNING("Window has navigated, cannot create XHR here.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
mXHR = new nsXMLHttpRequest();
|
||||
|
||||
if (NS_FAILED(mXHR->Init(mWorkerPrivate->GetPrincipal(),
|
||||
mWorkerPrivate->GetScriptContext(),
|
||||
mWorkerPrivate->GetWindow(),
|
||||
mWorkerPrivate->GetBaseURI()))) {
|
||||
ownerWindow, mWorkerPrivate->GetBaseURI()))) {
|
||||
mXHR = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче