Skip to content

Truly independent web browser

LibWeb: Base a window's cross-origin isolated capability on its cluster

Shannon Booth5858210967d5
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp
index c7174334ba8..bf06174815e 100644
--- a/Libraries/LibWeb/DOM/Document.cpp
+++ b/Libraries/LibWeb/DOM/Document.cpp
@@ -6886,6 +6886,9 @@ bool Document::is_allowed_to_use_feature(PolicyControlledFeature feature) const
case PolicyControlledFeature::Camera:
// FIXME: Implement allowlist for this.
return true;
+ case PolicyControlledFeature::CrossOriginIsolated:
+ // FIXME: Implement the allow attribute, which a container uses to delegate the feature to another origin.
+ return default_allowlist_enables_feature_in(*this);
case PolicyControlledFeature::FocusWithoutUserActivation:
// FIXME: Implement the allow attribute, which a container uses to delegate the feature to another origin.
return default_allowlist_enables_feature_in(*this);
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h
index bf0f74fc95c..5b432da630f 100644
--- a/Libraries/LibWeb/DOM/Document.h
+++ b/Libraries/LibWeb/DOM/Document.h
@@ -269,6 +269,7 @@ struct DocumentUnloadTimingInfo {
enum class PolicyControlledFeature : u8 {
Autoplay,
Camera,
+ CrossOriginIsolated,
EncryptedMedia,
FocusWithoutUserActivation,
Fullscreen,
diff --git a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
index 5ea8d356465..5d9186bffa1 100644
--- a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
+++ b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
@@ -155,18 +155,16 @@ double WindowEnvironmentSettingsObject::time_origin() const
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:concept-settings-object-cross-origin-isolated-capability
CanUseCrossOriginIsolatedAPIs WindowEnvironmentSettingsObject::cross_origin_isolated_capability() const
{
- // FIXME: Return true if both of the following hold, and false otherwise:
- // 1. realm's agent cluster's cross-origin-isolation mode is "concrete", and
- // 2. window's associated Document is allowed to use the "cross-origin-isolated" feature.
- // AD-HOC: Until we track an agent cluster's cross-origin-isolation mode (point 1) or the "cross-origin-isolated"
- // feature (point 2), we approximate this from the associated Document's cross-origin opener policy: It is
- // "same-origin-plus-COEP" exactly when the document was served (in a secure context) with COOP:same-origin
- // and COEP:require-corp — the condition for cross-origin isolation.
+ // Return true if both of the following hold, and false otherwise:
+ // - realm's agent cluster's cross-origin-isolation mode is "concrete", and
+ // - window's associated Document is allowed to use the "cross-origin-isolated" feature.
// NB: This can be called before the window's document is associated (e.g., via time coarsening during setup) — so,
// we guard against a null document here.
auto document = m_window ? m_window->associated_document_if_any() : nullptr;
- if (document && document->opener_policy().value == OpenerPolicyValue::SameOriginPlusCOEP)
+ if (m_agent_cluster_cross_origin_isolation_mode == CrossOriginIsolationMode::Concrete
+ && document && document->is_allowed_to_use_feature(DOM::PolicyControlledFeature::CrossOriginIsolated)) {
return CanUseCrossOriginIsolatedAPIs::Yes;
+ }
return CanUseCrossOriginIsolatedAPIs::No;
}