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
Agent.h
ClassicScript.cpp
ClassicScript.h
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
ExceptionReporter.h
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
ImportMap.cpp LibWeb: Check that import map elements are ordered maps (json objects) 2025-11-27 14:15:33 -06:00
ImportMap.h
ImportMapParseResult.cpp
ImportMapParseResult.h
ModuleMap.cpp
ModuleMap.h
ModuleScript.cpp LibWeb/WebIDL: Upgrade QuotaExceededError to its own interface 2025-12-29 17:15:11 +01:00
ModuleScript.h
Script.cpp
Script.h
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
SyntheticRealmSettings.h
TemporaryExecutionContext.cpp
TemporaryExecutionContext.h
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
WorkerAgent.h
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