Bug 753981 - 'XHR in Web Workers bypasses Offline AppCache'. r=smaug.

This commit is contained in:
Ben Turner 2012-11-01 20:37:55 -07:00
Родитель b51b4ca7f7
Коммит 038e0fa5f4
2 изменённых файлов: 18 добавлений и 2 удалений

Просмотреть файл

@ -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;
}