diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-02-15 20:12:44 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-18 00:52:47 +0100 |
commit | bfc8cbcf3b30940c5e0ef26f9ff27f9a302f82eb (patch) | |
tree | daf740c548cb1ce2978334496e6089b1bfbc3523 /Userland/Libraries | |
parent | 3e834636a633612caa2bee9a4c1bd4eb29d38831 (diff) | |
download | serenity-bfc8cbcf3b30940c5e0ef26f9ff27f9a302f82eb.zip |
LibWeb: Make factory method of HTML::ModuleScript fallible
Diffstat (limited to 'Userland/Libraries')
3 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp index cfb1fea97c..8b78b1ec28 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp @@ -401,7 +401,7 @@ void fetch_single_module_script(AK::URL const& url, EnvironmentSettingsObject&, } if (MimeSniff::is_javascript_mime_type_essence_match(*content_type_header) && module_type == "javascript"sv) { - auto module_script = JavaScriptModuleScript::create(url.basename(), data, module_map_settings_object, url); + auto module_script = JavaScriptModuleScript::create(url.basename(), data, module_map_settings_object, url).release_value_but_fixme_should_propagate_errors(); module_map.set(url, module_type, { ModuleMap::EntryType::ModuleScript, module_script }); on_complete(module_script); return; @@ -448,7 +448,7 @@ void fetch_inline_module_script_graph(DeprecatedString const& filename, Deprecat settings_object.disallow_further_import_maps(); // 2. Let script be the result of creating a JavaScript module script using source text, settings object, base URL, and options. - auto script = JavaScriptModuleScript::create(filename, source_text.view(), settings_object, base_url); + auto script = JavaScriptModuleScript::create(filename, source_text.view(), settings_object, base_url).release_value_but_fixme_should_propagate_errors(); // 3. If script is null, run onComplete given null, and return. if (!script) { diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp index f060ad2c47..7a975a3619 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp @@ -29,7 +29,7 @@ JavaScriptModuleScript::JavaScriptModuleScript(AK::URL base_url, DeprecatedStrin } // https://html.spec.whatwg.org/multipage/webappapis.html#creating-a-javascript-module-script -JS::GCPtr<JavaScriptModuleScript> JavaScriptModuleScript::create(DeprecatedString const& filename, StringView source, EnvironmentSettingsObject& settings_object, AK::URL base_url) +WebIDL::ExceptionOr<JS::GCPtr<JavaScriptModuleScript>> JavaScriptModuleScript::create(DeprecatedString const& filename, StringView source, EnvironmentSettingsObject& settings_object, AK::URL base_url) { // 1. If scripting is disabled for settings, then set source to the empty string. if (settings_object.is_scripting_disabled()) @@ -38,7 +38,7 @@ JS::GCPtr<JavaScriptModuleScript> JavaScriptModuleScript::create(DeprecatedStrin auto& realm = settings_object.realm(); // 2. Let script be a new module script that this algorithm will subsequently initialize. - auto script = realm.heap().allocate<JavaScriptModuleScript>(realm, move(base_url), filename, settings_object).release_allocated_value_but_fixme_should_propagate_errors(); + auto script = MUST_OR_THROW_OOM(realm.heap().allocate<JavaScriptModuleScript>(realm, move(base_url), filename, settings_object)); // 3. Set script's settings object to settings. // NOTE: This was already done when constructing. diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h index e182c185a4..2240e72487 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h @@ -29,7 +29,7 @@ class JavaScriptModuleScript final : public ModuleScript { public: virtual ~JavaScriptModuleScript() override; - static JS::GCPtr<JavaScriptModuleScript> create(DeprecatedString const& filename, StringView source, EnvironmentSettingsObject&, AK::URL base_url); + static WebIDL::ExceptionOr<JS::GCPtr<JavaScriptModuleScript>> create(DeprecatedString const& filename, StringView source, EnvironmentSettingsObject&, AK::URL base_url); enum class PreventErrorReporting { Yes, |