LibWeb: Adapt the parsing of script elements to accommodate TrustedTypes

This commit is contained in:
Tete17 2025-08-06 15:21:30 +02:00 committed by Jelle Raaijmakers
parent f7c05013c7
commit 82f56e30ed
2 changed files with 6 additions and 0 deletions

View File

@ -76,6 +76,8 @@ public:
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const override; virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const override;
void set_string_text(Utf16String const& value) { m_script_text = value; }
protected: protected:
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#implicitly-potentially-render-blocking // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#implicitly-potentially-render-blocking
virtual bool is_implicitly_potentially_render_blocking() const override; virtual bool is_implicitly_potentially_render_blocking() const override;

View File

@ -3268,6 +3268,10 @@ void HTMLParser::handle_text(HTMLToken& token)
// Increment the parser's script nesting level by one. // Increment the parser's script nesting level by one.
increment_script_nesting_level(); increment_script_nesting_level();
// https://w3c.github.io/trusted-types/dist/spec/#setting-slot-values-from-parser
// Set scripts script text value to its child text content.
script->set_string_text(script->child_text_content());
// If the active speculative HTML parser is null, then prepare the script element script. // If the active speculative HTML parser is null, then prepare the script element script.
// This might cause some script to execute, which might cause new characters to be inserted into the tokenizer, // This might cause some script to execute, which might cause new characters to be inserted into the tokenizer,
// and might cause the tokenizer to output more tokens, resulting in a reentrant invocation of the parser. // and might cause the tokenizer to output more tokens, resulting in a reentrant invocation of the parser.