Bug 1621282 - Fix the issue that CookieJarSettings is not synced to the WindowContext. r=dimi,Ehsan

We sync the CookieJarSettings to the WindowContext in
Document::StartDocumentLoad(). This is incorrect because the inner
window hasn't been set to the document in
Document::StartDocumentLoad(). So, the CookieJarSettings doesn't be
synced properly to the WindowContext.

This patch fixes this issue by changing the place where we do the sync. It
changes it to do the sync at the end of
nsGlobalWindowOuter::SetNewDocument() where the inner window and the
window context are both ready for the document.

Differential Revision: https://phabricator.services.mozilla.com/D66207

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tim Huang 2020-03-10 22:03:03 +00:00
Родитель 6803ec415d
Коммит 6f555fd710
2 изменённых файлов: 12 добавлений и 11 удалений

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

@ -3218,17 +3218,6 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
rv = loadInfo->GetCookieJarSettings(getter_AddRefs(mCookieJarSettings));
NS_ENSURE_SUCCESS(rv, rv);
// Set the cookie jar settings to the window context.
if (nsPIDOMWindowInner* inner = GetInnerWindow()) {
if (WindowGlobalChild* wgc = inner->GetWindowGlobalChild()) {
net::CookieJarSettingsArgs cookieJarSettings;
cookieJarSettings.cookieBehavior() =
mCookieJarSettings->GetCookieBehavior();
wgc->WindowContext()->SetCookieJarSettings(Some(cookieJarSettings));
}
}
return NS_OK;
}

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

@ -109,6 +109,7 @@
#include "PostMessageEvent.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/TabGroup.h"
#include "mozilla/net/CookieJarSettings.h"
// Interfaces Needed
#include "nsIFrame.h"
@ -2471,6 +2472,17 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
ReportLargeAllocStatus();
mLargeAllocStatus = LargeAllocStatus::NONE;
// Set the cookie jar settings to the window context.
if (newInnerWindow) {
net::CookieJarSettingsArgs cookieJarSettings;
net::CookieJarSettings::Cast(aDocument->CookieJarSettings())
->Serialize(cookieJarSettings);
newInnerWindow->GetWindowGlobalChild()
->WindowContext()
->SetCookieJarSettings(Some(cookieJarSettings));
}
mHasStorageAccess = false;
nsIURI* uri = aDocument->GetDocumentURI();
if (newInnerWindow &&