Import web modules by file URL in tests

PA
1d ago
+9-7

Four problem loader tests in tests/browser/dom-contract.test.js passed an absolute filesystem path to import(). On Windows the loader reads the drive letter as a URL scheme and throws ERR_UNSUPPORTED_ESM_URL_SCHEME, so the tests fail before any assertion runs. This change converts the path with pathToFileURL(...).href through a small webUrl helper. On Linux that resolves to the same module, so CI behaviour is unchanged. Only this test file changes; nothing under web/ is touched.

Validation on Windows 11, Node v24.20.0:

  • node --test tests/browser/dom-contract.test.js: 38 of 38 pass (34 before).
  • npm test, run before and after in the same environment: 93 failures before and 89 after. The only names that dropped out of the failure list are the four tests above. The other 89 failures on this machine are the same before and after; they are environment related (vendored assets not fetched, no C++ toolchain, Playwright tests that fail on Windows) and unrelated to this change.
  • Prettier and ESLint pass on the changed file.
  • scripts/test.sh and the Rust lanes were not run here.

Closes #322


Summary by cubic

Fixes four problem loader tests in tests/browser/dom-contract.test.js failing on Windows, where the ESM loader reads the drive letter as a URL scheme and throws ERR_UNSUPPORTED_ESM_URL_SCHEME. The tests now convert paths with pathToFileURL(...).href via a small webUrl helper before calling import(). On Linux this resolves to the same module, so CI behavior is unchanged. Closes #322.