summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-15 18:37:48 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-15 18:37:48 +0200
commit17d26b92f83741205b91e8d69153e86daa8bd008 (patch)
treeee1843b99bdf7e015561013132403c870b346bbf /Libraries/LibWeb
parent84f8c91a6fa12f845ff81a4ece8d68ec331a0217 (diff)
downloadserenity-17d26b92f83741205b91e8d69153e86daa8bd008.zip
LibWeb: Just ignore <script> elements that failed to load the script
We're never gonna be able to run them if we can't load them so just let it go.
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r--Libraries/LibWeb/DOM/HTMLScriptElement.cpp21
-rw-r--r--Libraries/LibWeb/DOM/HTMLScriptElement.h2
-rw-r--r--Libraries/LibWeb/Parser/HTMLDocumentParser.cpp3
3 files changed, 18 insertions, 8 deletions
diff --git a/Libraries/LibWeb/DOM/HTMLScriptElement.cpp b/Libraries/LibWeb/DOM/HTMLScriptElement.cpp
index 79edb77c45..1aa2968fe6 100644
--- a/Libraries/LibWeb/DOM/HTMLScriptElement.cpp
+++ b/Libraries/LibWeb/DOM/HTMLScriptElement.cpp
@@ -190,14 +190,19 @@ void HTMLScriptElement::prepare_script(Badge<HTMLDocumentParser>)
// FIXME: Check classic vs. module script type
// FIXME: This load should be made asynchronous and the parser should spin an event loop etc.
- ResourceLoader::the().load_sync(url, [this, url](auto& data, auto&) {
- if (data.is_null()) {
- dbg() << "HTMLScriptElement: Failed to load " << url;
- return;
- }
- m_script_source = String::copy(data);
- script_became_ready();
- });
+ ResourceLoader::the().load_sync(
+ url,
+ [this, url](auto& data, auto&) {
+ if (data.is_null()) {
+ dbg() << "HTMLScriptElement: Failed to load " << url;
+ return;
+ }
+ m_script_source = String::copy(data);
+ script_became_ready();
+ },
+ [this](auto&) {
+ m_failed_to_load = true;
+ });
} else {
// FIXME: Check classic vs. module script type
m_script_source = source_text;
diff --git a/Libraries/LibWeb/DOM/HTMLScriptElement.h b/Libraries/LibWeb/DOM/HTMLScriptElement.h
index 55bc9d024f..4c11556f38 100644
--- a/Libraries/LibWeb/DOM/HTMLScriptElement.h
+++ b/Libraries/LibWeb/DOM/HTMLScriptElement.h
@@ -41,6 +41,7 @@ public:
bool is_non_blocking() const { return m_non_blocking; }
bool is_ready_to_be_parser_executed() const { return m_ready_to_be_parser_executed; }
+ bool failed_to_load() const { return m_failed_to_load; }
void set_parser_document(Badge<HTMLDocumentParser>, Document&);
void set_non_blocking(Badge<HTMLDocumentParser>, bool);
@@ -60,6 +61,7 @@ private:
bool m_from_an_external_file { false };
bool m_script_ready { false };
bool m_ready_to_be_parser_executed { false };
+ bool m_failed_to_load { false };
Function<void()> m_script_ready_callback;
diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp
index 839756bb4e..718c8e3ca5 100644
--- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp
+++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp
@@ -1476,6 +1476,9 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
// that is blocking scripts and the script's "ready to be parser-executed"
// flag is set.
+ if (the_script->failed_to_load())
+ return;
+
ASSERT(the_script->is_ready_to_be_parser_executed());
if (m_aborted)