Bug 297939

Summary: Race condition between module script execution and FrameLoader's document completion check.
Product: WebKit Reporter: Basuke Suzuki <basuke>
Component: New BugsAssignee: Basuke Suzuki <basuke>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Basuke Suzuki
Reported 2025-08-26 17:22:56 PDT
When module scripts access document.readyState during their execution, they incorrectly receive "complete" when they should receive "interactive" according to the HTML specification. DESCRIPTION: Module scripts should execute after DOMContentLoaded but before the load event, at which point document.readyState should be "interactive". However, due to a race condition between JavaScript execution and FrameLoader's readyState control, module scripts see the state as "complete". STEPS TO REPRODUCE: 1. Load a page with a module script that checks document.readyState 2. The module script will see "complete" instead of "interactive" Test case: load-event-timing.html EXPECTED RESULTS: Module scripts should see document.readyState as "interactive" during their execution phase. ACTUAL RESULTS: Module scripts see document.readyState as "complete". Reproducibility is sometimes because it doesn’t happen when script module is simple and there’s no other classic inline script. This tells the fact that this must be dependent on the surrounding situation.
Attachments
Basuke Suzuki
Comment 1 2025-08-26 17:24:34 PDT
Basuke Suzuki
Comment 2 2025-08-26 17:29:32 PDT
EWS
Comment 3 2025-08-28 15:17:53 PDT
Committed 299282@main (f1e55dd8fe6f): <https://commits.webkit.org/299282@main> Reviewed commits have been landed. Closing PR #49910 and removing active labels.
Basuke Suzuki
Comment 4 2025-10-10 09:45:22 PDT
Basuke Suzuki
Comment 5 2025-10-10 10:07:02 PDT
Basuke Suzuki
Comment 6 2025-10-10 10:07:17 PDT
EWS
Comment 7 2025-10-10 21:22:00 PDT
Committed 301345@main (85e09b241c12): <https://commits.webkit.org/301345@main> Reviewed commits have been landed. Closing PR #52127 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.