mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-21 15:40:28 +00:00
LibWeb: Extend set_text of HTMLScriptElement to accommodate TrustedTypes
This commit is contained in:
parent
b4df857a57
commit
664a3b536a
Notes:
github-actions[bot]
2025-09-16 08:59:04 +00:00
Author: https://github.com/tete17
Commit: 664a3b536a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6058
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
7 changed files with 46 additions and 3 deletions
|
@ -24,6 +24,8 @@
|
|||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/MimeSniff/MimeType.h>
|
||||
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
|
||||
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -639,6 +641,26 @@ void HTMLScriptElement::unmark_as_parser_inserted(Badge<DOM::Range>)
|
|||
m_parser_document = nullptr;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/trusted-types/#the-text-idl-attribute
|
||||
WebIDL::ExceptionOr<void> HTMLScriptElement::set_text(TrustedTypes::TrustedScriptOrString text)
|
||||
{
|
||||
// 1. Let value be the result of calling Get Trusted Type compliant string with
|
||||
// TrustedScript, this’s relevant global object, the given value, HTMLScriptElement text, and script.
|
||||
auto const value = TRY(get_trusted_type_compliant_string(
|
||||
TrustedTypes::TrustedTypeName::TrustedScript,
|
||||
HTML::relevant_global_object(*this),
|
||||
text,
|
||||
TrustedTypes::InjectionSink::HTMLScriptElementtext,
|
||||
TrustedTypes::Script.to_string()));
|
||||
|
||||
// 2. Set this’s script text value to the given value.
|
||||
m_script_text = value;
|
||||
|
||||
// 3. String replace all with the given value within this.
|
||||
string_replace_all(value);
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-async
|
||||
bool HTMLScriptElement::async() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue