Skip to content

Conversation

dmvjs
Copy link

@dmvjs dmvjs commented Jul 22, 2025

Add tests for WebKit Bug 242740: simultaneous imports with top-level await

Summary

Adds test cases that reproduce WebKit Bug 242740, where simultaneous imports of a module with top-level await can fail with ReferenceError or resolve prematurely.

Bug Reference

Tests Added

  1. simultaneous-imports-race-condition.js - Tests that simultaneous imports wait for top-level await completion
  2. simultaneous-imports-reference-error.js - Tests that no ReferenceError is thrown during simultaneous imports

Expected Behavior

  • All simultaneous imports should wait for the module's top-level await to complete
  • No ReferenceError should be thrown during the import process
  • All imports should return the same module namespace
  • Module exports should be correctly defined

Affected Browsers

  • Safari (WebKit-based browsers) - will fail these tests
  • Chrome, Firefox, Edge - should pass these tests

…await

- Add simultaneous-imports-race-condition.js to test that simultaneous imports wait for top-level await completion
- Add simultaneous-imports-reference-error.js to test that no ReferenceError is thrown during simultaneous imports
- Both tests will fail in WebKit-based browsers due to the bug
- Tests follow test262 style and reproduce the race condition described in the bug report

Bug: https://bugs.webkit.org/show_bug.cgi?id=242740
@dmvjs dmvjs requested a review from a team as a code owner July 22, 2025 02:41
@dmvjs dmvjs marked this pull request as draft July 22, 2025 02:42
dmvjs added 3 commits July 21, 2025 22:48
…ait modules

Add two test cases to reproduce WebKit Bug 242740 where simultaneous
dynamic imports of a module with top-level await can cause ReferenceError
or race conditions.

- simultaneous-imports-race-condition.js: Tests that all simultaneous
  imports wait for module evaluation to complete
- simultaneous-imports-reference-error.js: Tests that no ReferenceError
  is thrown during simultaneous imports

Both tests use the standard test262 pattern with top-level await and
() for completion.
Remove redundant reference-error test, keeping only the race-condition
test which covers the core issue. This provides a cleaner, more focused
PR that clearly exposes the WebKit bug with minimal scope.
@dmvjs dmvjs marked this pull request as ready for review July 22, 2025 11:28
@nicolo-ribaudo
Copy link
Member

Is this behaviour already covered by https://github.com/tc39/test262/blob/main/test/language/module-code/top-level-await/dynamic-import-of-waiting-module.js? Maybe just add the namespace check to that test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants