LibWeb: Implement HTMLIFrameElement.sandbox

This commit is contained in:
Shannon Booth 2024-11-18 07:16:26 +13:00 committed by Andreas Kling
parent a4b43cae9a
commit 634823d5b4
Notes: github-actions[bot] 2024-11-17 21:13:47 +00:00
5 changed files with 19 additions and 4 deletions

View file

@ -233,6 +233,7 @@ namespace AttributeNames {
__ENUMERATE_HTML_ATTRIBUTE(rows) \
__ENUMERATE_HTML_ATTRIBUTE(rowspan) \
__ENUMERATE_HTML_ATTRIBUTE(rules) \
__ENUMERATE_HTML_ATTRIBUTE(sandbox) \
__ENUMERATE_HTML_ATTRIBUTE(scheme) \
__ENUMERATE_HTML_ATTRIBUTE(scope) \
__ENUMERATE_HTML_ATTRIBUTE(scrollamount) \

View file

@ -8,6 +8,7 @@
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/HTMLIFrameElementPrototype.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/DOM/DOMTokenList.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/HTML/BrowsingContext.h>
@ -211,10 +212,20 @@ i32 HTMLIFrameElement::default_tab_index_value() const
return 0;
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#dom-iframe-sandbox
GC::Ref<DOM::DOMTokenList> HTMLIFrameElement::sandbox()
{
// The sandbox IDL attribute must reflect the sandbox content attribute.
if (!m_sandbox)
m_sandbox = DOM::DOMTokenList::create(*this, HTML::AttributeNames::sandbox);
return *m_sandbox;
}
void HTMLIFrameElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visit_lazy_loading_element(visitor);
visitor.visit(m_sandbox);
}
void HTMLIFrameElement::set_current_navigation_was_lazy_loaded(bool value)

View file

@ -31,6 +31,8 @@ public:
Optional<HighResolutionTime::DOMHighResTimeStamp> const& pending_resource_start_time() const { return m_pending_resource_start_time; }
void set_pending_resource_start_time(Optional<HighResolutionTime::DOMHighResTimeStamp> time) { m_pending_resource_start_time = time; }
GC::Ref<DOM::DOMTokenList> sandbox();
virtual void visit_edges(Cell::Visitor&) override;
private:
@ -55,6 +57,8 @@ private:
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#iframe-pending-resource-timing-start-time
Optional<HighResolutionTime::DOMHighResTimeStamp> m_pending_resource_start_time = {};
GC::Ptr<DOM::DOMTokenList> m_sandbox;
};
void run_iframe_load_event_steps(HTML::HTMLIFrameElement&);

View file

@ -11,7 +11,7 @@ interface HTMLIFrameElement : HTMLElement {
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString srcdoc;
[CEReactions, Reflect] attribute DOMString name;
[FIXME, SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox;
[SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox;
[CEReactions, Reflect] attribute DOMString allow;
[CEReactions, Reflect=allowfullscreen] attribute boolean allowFullscreen;
[CEReactions, Reflect] attribute DOMString width;

View file

@ -6,8 +6,7 @@ Rerun
Found 175 tests
174 Pass
1 Fail
175 Pass
Details
Result Test Name MessagePass a.classList in http://www.w3.org/1999/xhtml namespace should be DOMTokenList.
Pass area.classList in http://www.w3.org/1999/xhtml namespace should be DOMTokenList.
@ -117,7 +116,7 @@ Pass th.htmlFor in null namespace should be undefined.
Pass a.sandbox in http://www.w3.org/1999/xhtml namespace should be undefined.
Pass area.sandbox in http://www.w3.org/1999/xhtml namespace should be undefined.
Pass link.sandbox in http://www.w3.org/1999/xhtml namespace should be undefined.
Fail iframe.sandbox in http://www.w3.org/1999/xhtml namespace should be DOMTokenList.
Pass iframe.sandbox in http://www.w3.org/1999/xhtml namespace should be DOMTokenList.
Pass output.sandbox in http://www.w3.org/1999/xhtml namespace should be undefined.
Pass td.sandbox in http://www.w3.org/1999/xhtml namespace should be undefined.
Pass th.sandbox in http://www.w3.org/1999/xhtml namespace should be undefined.