ladybird/Libraries/LibWeb/HTML/Scripting
Christoffer Haglund 14ccc87190 LibWeb: Address edge case on async module load
Issue #6294 describes an edge case where the browser crash if the same
module is loaded three times in a document, but all attempts fail.

Failure scenario:
1. Module load 1 set the state to "Fetching"
2. Module load 2 registers a callback to `on_complete` since the
   current state is "Fetching"
3. Module load 1 finish with a failure, invoking the callback for load
   number 2
4. Module load 3 cause a crash. The state is neither "Fetching" or
   "ModuleScript", so we'll reset the state to "Fetching". This invokes
   the callback for module load 2 again, now with an unexpected state
   which will cause an assert violation.

Proposed fix is to remove the condition that invokes `on_complete`
immediately for successfully loaded modules only, the callback should
be invoked regardless of whether the fetch succeeded or failed.

This reveals a separate bug in HTMLScriptElement, where
`mark_as_ready()` can be invoked before
`m_steps_to_run_when_the_result_is_ready` is assigned.
This appears to be a spec bug, reported as
https://github.com/whatwg/html/issues/12073 and addressed by delaying
the callback by a task, similar to the issue was resolved for inline
scripts.
2026-01-13 18:12:38 +01:00
..
Agent.cpp LibWeb: Split out SimilarOriginWindowAgent from HTML::Agent 2025-04-25 14:07:51 +02:00
Agent.h LibJS: Switch Agent [[CanBlock]] slot to a enum member 2025-04-25 14:07:51 +02:00
ClassicScript.cpp LibJS+LibWeb: Port interned bytecode strings to UTF-16 2025-08-14 10:27:08 +02:00
ClassicScript.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Environments.cpp LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
Environments.h LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
EnvironmentSettingsSnapshot.cpp LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
EnvironmentSettingsSnapshot.h LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
ExceptionReporter.cpp LibJS+LibWeb: Port interned bytecode strings to UTF-16 2025-08-14 10:27:08 +02:00
ExceptionReporter.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Fetching.cpp LibWeb: Address edge case on async module load 2026-01-13 18:12:38 +01:00
Fetching.h LibWeb: Remove exception throwing from Fetch 2025-11-07 04:08:30 +01:00
Fetching.idl Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
ImportMap.cpp LibWeb: Check that import map elements are ordered maps (json objects) 2025-11-27 14:15:33 -06:00
ImportMap.h LibJS: Use FlyString in PropertyKey instead of DeprecatedFlyString 2025-03-24 22:27:17 +00:00
ImportMapParseResult.cpp LibJS: Make Completion.[[Value]] non-optional 2025-04-05 11:20:26 +02:00
ImportMapParseResult.h LibGC+Everywhere: Factor out a LibGC from LibJS 2024-11-15 14:49:20 +01:00
ModuleMap.cpp LibGC+Everywhere: Factor out a LibGC from LibJS 2024-11-15 14:49:20 +01:00
ModuleMap.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
ModuleScript.cpp LibWeb/WebIDL: Upgrade QuotaExceededError to its own interface 2025-12-29 17:15:11 +01:00
ModuleScript.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Script.cpp LibWeb: Make base URL of HTML::Script Optional 2025-02-19 08:01:35 -05:00
Script.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
SerializedEnvironmentSettingsObject.cpp LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
SerializedEnvironmentSettingsObject.h LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
SimilarOriginWindowAgent.cpp LibWeb: Change agent's signal_slots into a GC::RootVector 2025-11-24 12:45:22 +00:00
SimilarOriginWindowAgent.h LibWeb: Use weak references in the custom elements reaction stack 2025-12-25 20:21:37 +01:00
SyntheticRealmSettings.cpp LibWeb: Remove underlying realm from SyntheticRealmSettings 2024-11-24 15:29:47 -07:00
SyntheticRealmSettings.h LibWeb: Remove underlying realm from SyntheticRealmSettings 2024-11-24 15:29:47 -07:00
TemporaryExecutionContext.cpp Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
TemporaryExecutionContext.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
WindowEnvironmentSettingsObject.cpp LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
WindowEnvironmentSettingsObject.h LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00
WorkerAgent.cpp LibWeb/HTML: Hook up a WorkerAgent for web workers 2025-04-25 14:07:51 +02:00
WorkerAgent.h LibWeb/HTML: Hook up a WorkerAgent for web workers 2025-04-25 14:07:51 +02:00
WorkerEnvironmentSettingsObject.cpp LibWeb/HTML: Ensure data: URL workers are same-origin with themselves 2026-01-13 16:59:54 +01:00
WorkerEnvironmentSettingsObject.h LibWeb: Remove API URL character encoding 2026-01-13 13:51:32 +00:00