mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibWeb: Prevent crash when loading module in worker
The import map is defined for all global objects, not just the window.
This commit is contained in:
parent
fc4a2eeba8
commit
93e2babc64
Notes:
github-actions[bot]
2025-02-28 13:52:18 +00:00
Author: https://github.com/Gingeh Commit: https://github.com/LadybirdBrowser/ladybird/commit/93e2babc64d Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3714 Reviewed-by: https://github.com/awesomekling
4 changed files with 11 additions and 9 deletions
|
@ -317,7 +317,7 @@ ScriptFetchOptions get_descendant_script_fetch_options(ScriptFetchOptions const&
|
|||
String resolve_a_module_integrity_metadata(const URL::URL& url, EnvironmentSettingsObject& settings_object)
|
||||
{
|
||||
// 1. Let map be settingsObject's global object's import map.
|
||||
auto map = as<Window>(settings_object.global_object()).import_map();
|
||||
auto map = as<UniversalGlobalScopeMixin>(settings_object.global_object()).import_map();
|
||||
|
||||
// 2. If map's integrity[url] does not exist, then return the empty string.
|
||||
// 3. Return map's integrity[url].
|
||||
|
|
|
@ -45,6 +45,10 @@ public:
|
|||
|
||||
void notify_about_rejected_promises(Badge<EventLoop>);
|
||||
|
||||
ImportMap& import_map() { return m_import_map; }
|
||||
ImportMap const& import_map() const { return m_import_map; }
|
||||
void set_import_map(ImportMap const& import_map) { m_import_map = import_map; }
|
||||
|
||||
protected:
|
||||
void visit_edges(GC::Cell::Visitor&);
|
||||
|
||||
|
@ -61,6 +65,10 @@ private:
|
|||
// https://html.spec.whatwg.org/multipage/webappapis.html#outstanding-rejected-promises-weak-set
|
||||
// The outstanding rejected promises weak set must not create strong references to any of its members, and implementations are free to limit its size, e.g. by removing old entries from it when new ones are added.
|
||||
Vector<GC::Ptr<JS::Promise>> m_outstanding_rejected_promises_weak_set;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-global-import-map
|
||||
// A global object has an import map, initially an empty import map.
|
||||
ImportMap m_import_map;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -114,10 +114,6 @@ public:
|
|||
|
||||
GC::Ptr<Navigable> navigable() const;
|
||||
|
||||
ImportMap& import_map() { return m_import_map; }
|
||||
ImportMap const& import_map() const { return m_import_map; }
|
||||
void set_import_map(ImportMap const& import_map) { m_import_map = import_map; }
|
||||
|
||||
void append_resolved_module(SpecifierResolution resolution) { m_resolved_module_set.append(move(resolution)); }
|
||||
Vector<SpecifierResolution> const& resolved_module_set() const { return m_resolved_module_set; }
|
||||
|
||||
|
@ -288,10 +284,6 @@ private:
|
|||
|
||||
GC::Ptr<DOM::Event> m_current_event;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-global-import-map
|
||||
// A global object has an import map, initially an empty import map.
|
||||
ImportMap m_import_map;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#resolved-module-set
|
||||
// A global object has a resolved module set, a set of specifier resolution records, initially empty.
|
||||
//
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import "./worker.mjs";
|
||||
|
||||
self.onmessage = ({ data }) => {
|
||||
self.postMessage(`Worker responding to: ${data}`);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue