From d890be6e0f7db08ab39ba546cb3421b50b687cda Mon Sep 17 00:00:00 2001 From: Maciej Date: Sun, 7 Jul 2024 21:57:01 +0200 Subject: [PATCH] LibWeb: Prepare script when src is set the first time From https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model: When a script element el that is not parser-inserted experiences one of the events listed in the following list, the user agent must immediately prepare the script element el: - [...] - The script element is connected and has a src attribute set where previously the element had no such attribute. --- .../expected/script-src-set-after-insertion.txt | 1 + .../Text/input/script-src-set-after-insertion.html | 13 +++++++++++++ .../Text/input/script-src-set-after-insertion.js | 1 + .../Libraries/LibWeb/HTML/HTMLScriptElement.cpp | 10 ++++++++++ Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h | 2 ++ 5 files changed, 27 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/script-src-set-after-insertion.txt create mode 100644 Tests/LibWeb/Text/input/script-src-set-after-insertion.html create mode 100644 Tests/LibWeb/Text/input/script-src-set-after-insertion.js diff --git a/Tests/LibWeb/Text/expected/script-src-set-after-insertion.txt b/Tests/LibWeb/Text/expected/script-src-set-after-insertion.txt new file mode 100644 index 00000000000..7ef22e9a431 --- /dev/null +++ b/Tests/LibWeb/Text/expected/script-src-set-after-insertion.txt @@ -0,0 +1 @@ +PASS diff --git a/Tests/LibWeb/Text/input/script-src-set-after-insertion.html b/Tests/LibWeb/Text/input/script-src-set-after-insertion.html new file mode 100644 index 00000000000..a30bc14a331 --- /dev/null +++ b/Tests/LibWeb/Text/input/script-src-set-after-insertion.html @@ -0,0 +1,13 @@ + + + + diff --git a/Tests/LibWeb/Text/input/script-src-set-after-insertion.js b/Tests/LibWeb/Text/input/script-src-set-after-insertion.js new file mode 100644 index 00000000000..ab333c9f6ae --- /dev/null +++ b/Tests/LibWeb/Text/input/script-src-set-after-insertion.js @@ -0,0 +1 @@ +println("PASS"); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 1eca1aad78b..cfd6df6125e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -58,6 +58,16 @@ void HTMLScriptElement::attribute_changed(FlyString const& name, Optional m_document_load_event_delayer; size_t m_source_line_number { 1 }; + + bool m_src_is_set = false; }; }