зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1645234 - Add more warnings to document.requestStorageAccess(). r=annevk,englehardt,baku
The only common failure case that's not being warned about now is when the user rejected the prompt, which I think is expected behavior. Differential Revision: https://phabricator.services.mozilla.com/D79597
This commit is contained in:
Родитель
acc4997769
Коммит
1b47c026a0
|
@ -15858,6 +15858,10 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
|
|||
|
||||
// Step 2. If the document has a null origin, reject.
|
||||
if (NodePrincipal()->GetIsNullPrincipal()) {
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
|
||||
NS_LITERAL_CSTRING("requestStorageAccess"),
|
||||
this, nsContentUtils::eDOM_PROPERTIES,
|
||||
"RequestStorageAccessNullPrincipal");
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -15907,6 +15911,9 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
|
|||
// Step 6. If the sub frame doesn't have the token
|
||||
// "allow-storage-access-by-user-activation", reject.
|
||||
if (StorageAccessSandboxed()) {
|
||||
nsContentUtils::ReportToConsole(
|
||||
nsIScriptError::errorFlag, NS_LITERAL_CSTRING("requestStorageAccess"),
|
||||
this, nsContentUtils::eDOM_PROPERTIES, "RequestStorageAccessSandboxed");
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -15914,12 +15921,19 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
|
|||
// Step 7. If the sub frame's parent frame is not the top frame, reject.
|
||||
RefPtr<BrowsingContext> parentBC = bc->GetParent();
|
||||
if (parentBC && !parentBC->IsTopContent()) {
|
||||
nsContentUtils::ReportToConsole(
|
||||
nsIScriptError::errorFlag, NS_LITERAL_CSTRING("requestStorageAccess"),
|
||||
this, nsContentUtils::eDOM_PROPERTIES, "RequestStorageAccessNested");
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
// Step 8. If the browser is not processing a user gesture, reject.
|
||||
if (!UserActivation::IsHandlingUserInput()) {
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
|
||||
NS_LITERAL_CSTRING("requestStorageAccess"),
|
||||
this, nsContentUtils::eDOM_PROPERTIES,
|
||||
"RequestStorageAccessUserGesture");
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
|
|
@ -394,3 +394,12 @@ UnknownProtocolNavigationPrevented=Prevented navigation to “%1$S” due to an
|
|||
PostMessageSharedMemoryObjectToCrossOriginWarning=Cannot post message containing a shared memory object to a cross-origin window.
|
||||
# LOCALIZATION NOTE: %S is the URL of the resource in question
|
||||
UnusedLinkPreloadPending=The resource at “%S” preloaded with link preload was not used within a few seconds. Make sure all attributes of the preload tag are set correctly.
|
||||
|
||||
# LOCALIZATION NOTE: Do not translate document.requestStorageAccess(), iframe, allow-same-origin and sandbox (though you may translate "sandboxed").
|
||||
RequestStorageAccessNullPrincipal=document.requestStorageAccess() may not be called on a document with an opaque origin, such as a sandboxed iframe without allow-same-origin in its sandbox attribute.
|
||||
# LOCALIZATION NOTE: Do not translate document.requestStorageAccess(), iframe, allow-storage-access-by-user-activation and sandbox (though you may translate "sandboxed").
|
||||
RequestStorageAccessSandboxed=document.requestStorageAccess() may not be called in a sandboxed iframe without allow-storage-access-by-user-activation in its sandbox attribute.
|
||||
# LOCALIZATION NOTE: Do not translate document.requestStorageAccess() and iframe.
|
||||
RequestStorageAccessNested=document.requestStorageAccess() may not be called in a nested iframe.
|
||||
# LOCALIZATION NOTE: Do not translate document.requestStorageAccess(). In some locales it may be preferable to not translate "event handler", either.
|
||||
RequestStorageAccessUserGesture=document.requestStorageAccess() may only be requested from inside a short running user-generated event handler.
|
||||
|
|
Загрузка…
Ссылка в новой задаче