mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
Bug 1685475 - Get cross-origin-isolated state from the scope object when it's a data document and thus don't have a browsing context; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D101327
This commit is contained in:
parent
caa9cd4f4d
commit
d7a1ef74c4
@ -4068,8 +4068,7 @@ void Document::AssertDocGroupMatchesKey() const {
|
||||
|
||||
// GetKey() can fail, e.g. after the TLD service has shut down.
|
||||
nsresult rv = mozilla::dom::DocGroup::GetKey(
|
||||
NodePrincipal(), GetBrowsingContext()->CrossOriginIsolated(),
|
||||
docGroupKey);
|
||||
NodePrincipal(), CrossOriginIsolated(), docGroupKey);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
MOZ_ASSERT(mDocGroup->MatchesKey(docGroupKey));
|
||||
}
|
||||
@ -7001,14 +7000,24 @@ nsIGlobalObject* Document::GetScopeObject() const {
|
||||
return scope;
|
||||
}
|
||||
|
||||
bool Document::CrossOriginIsolated() const {
|
||||
// For a data document, it doesn't have a browsing context so that we check
|
||||
// the cross-origin-isolated state from its creator's inner window.
|
||||
if (mLoadedAsData) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetScopeObject());
|
||||
|
||||
return window && window->GetBrowsingContext() &&
|
||||
window->GetBrowsingContext()->CrossOriginIsolated();
|
||||
}
|
||||
|
||||
return GetBrowsingContext() && GetBrowsingContext()->CrossOriginIsolated();
|
||||
}
|
||||
|
||||
DocGroup* Document::GetDocGroupOrCreate() {
|
||||
if (!mDocGroup) {
|
||||
bool crossOriginIsolated = GetBrowsingContext()
|
||||
? GetBrowsingContext()->CrossOriginIsolated()
|
||||
: false;
|
||||
nsAutoCString docGroupKey;
|
||||
nsresult rv = mozilla::dom::DocGroup::GetKey(
|
||||
NodePrincipal(), crossOriginIsolated, docGroupKey);
|
||||
NodePrincipal(), CrossOriginIsolated(), docGroupKey);
|
||||
if (NS_SUCCEEDED(rv) && mDocumentContainer) {
|
||||
BrowsingContextGroup* group = GetBrowsingContext()->Group();
|
||||
if (group) {
|
||||
@ -7031,15 +7040,11 @@ void Document::SetScopeObject(nsIGlobalObject* aGlobal) {
|
||||
BrowsingContextGroup* browsingContextGroup =
|
||||
window->GetBrowsingContextGroup();
|
||||
|
||||
bool crossOriginIsolated = GetBrowsingContext()
|
||||
? GetBrowsingContext()->CrossOriginIsolated()
|
||||
: false;
|
||||
|
||||
// We should already have the principal, and now that we have been added
|
||||
// to a window, we should be able to join a DocGroup!
|
||||
nsAutoCString docGroupKey;
|
||||
nsresult rv = mozilla::dom::DocGroup::GetKey(
|
||||
NodePrincipal(), crossOriginIsolated, docGroupKey);
|
||||
NodePrincipal(), CrossOriginIsolated(), docGroupKey);
|
||||
if (mDocGroup) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
MOZ_RELEASE_ASSERT(mDocGroup->MatchesKey(docGroupKey));
|
||||
@ -8405,9 +8410,7 @@ void Document::SetDomain(const nsAString& aDomain, ErrorResult& rv) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (StaticPrefs::
|
||||
dom_postMessage_sharedArrayBuffer_withCOOP_COEP_AtStartup() &&
|
||||
GetBrowsingContext() && GetBrowsingContext()->CrossOriginIsolated()) {
|
||||
if (CrossOriginIsolated()) {
|
||||
WarnOnceAbout(Document::eDocumentSetDomainNotAllowed);
|
||||
return;
|
||||
}
|
||||
|
@ -1803,6 +1803,12 @@ class Document : public nsINode,
|
||||
nsIGlobalObject* GetScopeObject() const;
|
||||
void SetScopeObject(nsIGlobalObject* aGlobal);
|
||||
|
||||
/**
|
||||
* Return the cross-origin-isolated state from browsing context. If it's a
|
||||
* data document, we get its creator's state.
|
||||
*/
|
||||
bool CrossOriginIsolated() const;
|
||||
|
||||
/**
|
||||
* Return the window containing the document (the outer window).
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user