Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 206dbc8

Browse files
committed
Bug 1631234 - Part 2: Moving the setting of the 'HasStoragePermission' before the first check of the storage access in nsGlobalWindowOuter::SetNewDocument(). r=baku
Because we would check the storage access permission inside nsGlobalWindowInner::ExecutionReady(), so we need to set the 'HasStoragePermission' flag before we call it in nsGlobalWindowOuter::SetNewDocument(). In addition, we check the assertion in the ClientSource::WindowExecutionReady() back to a diagnostic assertion. Depends on D71564 Differential Revision: https://phabricator.services.mozilla.com/D71565
1 parent 4b821be commit 206dbc8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

dom/base/nsGlobalWindowOuter.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,23 +2406,26 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
24062406
// them into the JS slots. If we nullify them after, the slot values and
24072407
// the objects will be out of sync.
24082408
newInnerWindow->ClearDocumentDependentSlots(cx);
2409-
2410-
// When replacing an initial about:blank document we call
2411-
// ExecutionReady again to update the client creation URL.
2412-
rv = newInnerWindow->ExecutionReady();
2413-
NS_ENSURE_SUCCESS(rv, rv);
24142409
} else {
24152410
newInnerWindow->InitDocumentDependentState(cx);
24162411

24172412
// Initialize DOM classes etc on the inner window.
24182413
JS::Rooted<JSObject*> obj(cx, newInnerGlobal);
24192414
rv = kungFuDeathGrip->InitClasses(obj);
24202415
NS_ENSURE_SUCCESS(rv, rv);
2421-
2422-
rv = newInnerWindow->ExecutionReady();
2423-
NS_ENSURE_SUCCESS(rv, rv);
24242416
}
24252417

2418+
// We would check the storage access in below function, so we need to
2419+
// set the flag before it.
2420+
newInnerWindow->GetWindowGlobalChild()
2421+
->WindowContext()
2422+
->SetHasStoragePermission(aDocument->HasStoragePermission());
2423+
2424+
// When replacing an initial about:blank document we call
2425+
// ExecutionReady again to update the client creation URL.
2426+
rv = newInnerWindow->ExecutionReady();
2427+
NS_ENSURE_SUCCESS(rv, rv);
2428+
24262429
if (mArguments) {
24272430
newInnerWindow->DefineArgumentsProperty(mArguments);
24282431
mArguments = nullptr;
@@ -2513,10 +2516,6 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
25132516
newInnerWindow->GetWindowGlobalChild()
25142517
->WindowContext()
25152518
->SetCookieJarSettings(Some(cookieJarSettings));
2516-
2517-
newInnerWindow->GetWindowGlobalChild()
2518-
->WindowContext()
2519-
->SetHasStoragePermission(aDocument->HasStoragePermission());
25202519
}
25212520

25222521
mHasStorageAccess = false;

dom/clients/manager/ClientSource.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@ nsresult ClientSource::WindowExecutionReady(nsPIDOMWindowInner* aInnerWindow) {
262262
// continue to inherit the SW as well. We need to avoid triggering the
263263
// assertion in this corner case.
264264
if (mController.isSome()) {
265-
MOZ_ASSERT(spec.LowerCaseEqualsLiteral("about:blank") ||
266-
StringBeginsWith(spec, NS_LITERAL_CSTRING("blob:")) ||
267-
StorageAllowedForWindow(aInnerWindow) == StorageAccess::eAllow);
265+
MOZ_DIAGNOSTIC_ASSERT(spec.LowerCaseEqualsLiteral("about:blank") ||
266+
StringBeginsWith(spec, NS_LITERAL_CSTRING("blob:")) ||
267+
StorageAllowedForWindow(aInnerWindow) ==
268+
StorageAccess::eAllow);
268269
}
269270

270271
nsPIDOMWindowOuter* outer = aInnerWindow->GetOuterWindow();

0 commit comments

Comments
 (0)