LibWeb/HTML: Add cross-site ancestor flag to environment
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Corresponds to baec061a70
This commit is contained in:
Sam Atkins 2025-08-07 15:03:05 +01:00
commit 4bcfc4bacc
Notes: github-actions[bot] 2025-08-11 11:23:58 +00:00
10 changed files with 73 additions and 16 deletions

View file

@ -110,6 +110,28 @@ URL::Origin WindowEnvironmentSettingsObject::origin() const
return m_window->associated_document().origin();
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#script-settings-for-window-objects:concept-settings-object-has-cross-site-ancestor
bool WindowEnvironmentSettingsObject::has_cross_site_ancestor() const
{
// 1. If window's navigable's parent is null, then return false.
if (m_window->navigable()->parent() == nullptr)
return false;
// 2. Let parentDocument be window's navigable's parent's active document.
auto parent_document = m_window->navigable()->parent()->active_document();
// 3. If parentDocument's relevant settings object's has cross-site ancestor is true, then return true.
if (parent_document->relevant_settings_object().has_cross_site_ancestor())
return true;
// 4. If parentDocument's origin is not same site with window's associated Document's origin, then return true.
if (!parent_document->origin().is_same_site(m_window->associated_document().origin()))
return true;
// 5. Return false.
return false;
}
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:concept-settings-object-policy-container
GC::Ref<PolicyContainer> WindowEnvironmentSettingsObject::policy_container() const
{