Bug 1848783, part 1 - Add active document check - r=anti-tracking-reviewers,timhuang

Differential Revision: https://phabricator.services.mozilla.com/D186982
This commit is contained in:
Benjamin VanderSloot 2023-09-19 21:03:06 +00:00
Родитель 5005011998
Коммит 09cd45ddba
2 изменённых файлов: 16 добавлений и 0 удалений

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

@ -17234,6 +17234,12 @@ already_AddRefed<mozilla::dom::Promise> Document::HasStorageAccess(
return nullptr;
}
if (!IsCurrentActiveDocument()) {
promise->MaybeRejectWithInvalidStateError(
"hasStorageAccess requires an active document");
return promise.forget();
}
bool hasStorageAccess;
nsresult rv = HasStorageAccessSync(hasStorageAccess);
if (NS_FAILED(rv)) {
@ -17432,6 +17438,12 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
return nullptr;
}
if (!IsCurrentActiveDocument()) {
promise->MaybeRejectWithInvalidStateError(
"requestStorageAccess requires an active document");
return promise.forget();
}
// Get a pointer to the inner window- We need this for convenience sake
RefPtr<nsPIDOMWindowInner> inner = GetInnerWindow();
if (!inner) {

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

@ -845,6 +845,10 @@ Maybe<bool> StorageAccessAPIHelper::CheckCallingContextDecidesStorageAccessAPI(
return Some(true);
}
if (!aDocument->IsCurrentActiveDocument()) {
return Some(false);
}
if (aRequestingStorageAccess) {
// Perform a Permission Policy Request
dom::FeaturePolicy* policy = aDocument->FeaturePolicy();