LibWeb: Parse and propagate the iframe sandbox attribute

This commit is contained in:
Luke Wilde 2024-12-06 14:53:03 +00:00 committed by Alexander Kalenik
commit 40bb50ac60
Notes: github-actions[bot] 2025-08-07 17:26:35 +00:00
51 changed files with 1155 additions and 12 deletions

View file

@ -13,6 +13,7 @@
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextGroup.h>
#include <LibWeb/HTML/HTMLDocument.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/HTML/HTMLInputElement.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
@ -487,11 +488,28 @@ bool BrowsingContext::is_familiar_with(BrowsingContext const& other) const
return false;
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#snapshotting-target-snapshot-params
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, GC::Ptr<DOM::Element>)
// https://html.spec.whatwg.org/multipage/browsers.html#determining-the-creation-sandboxing-flags
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const& browsing_context, GC::Ptr<DOM::Element> embedder)
{
// FIXME: Populate this once we have the proper flag sets on BrowsingContext
return {};
// To determine the creation sandboxing flags for a browsing context browsing context, given null or an element
// embedder, return the union of the flags that are present in the following sandboxing flag sets:
SandboxingFlagSet sandboxing_flags {};
// - If embedder is null, then: the flags set on browsing context's popup sandboxing flag set.
if (!embedder) {
sandboxing_flags |= browsing_context.popup_sandboxing_flag_set();
} else {
// - If embedder is an element, then: the flags set on embedder's iframe sandboxing flag set.
if (is<HTMLIFrameElement>(embedder.ptr())) {
auto const& iframe_element = static_cast<HTMLIFrameElement const&>(*embedder);
sandboxing_flags |= iframe_element.iframe_sandboxing_flag_set();
}
// - If embedder is an element, then: the flags set on embedder's node document's active sandboxing flag set.
sandboxing_flags |= embedder->document().active_sandboxing_flag_set();
}
return sandboxing_flags;
}
bool BrowsingContext::has_navigable_been_destroyed() const