Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reporting of harness errors in ShadowRealm tests #49387

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

ptomato
Copy link
Contributor

@ptomato ptomato commented Nov 27, 2024

  • Better error reporting when setup code fails or an exception is thrown outside a test
  • ShadowRealm-in-Worker/AudioWorklet tests fail immediately instead of timing out in that case

resources/testharness-shadowrealm-outer.js Outdated Show resolved Hide resolved
tools/serve/serve.py Outdated Show resolved Hide resolved
resources/testharness-shadowrealm-outer.js Outdated Show resolved Hide resolved
In shadowrealm-in-window and shadowrealm-in-shadowrealm contexts, if the
setup code fails, or an exception is thrown outside of a test, make sure
that is detected as a harness error.

Previously the test report would just show the unhelpful error message
"Unhandled rejection". Now it will show the stringified error message from
the ShadowRealm (the actual exception object cannot pass the callable
boundary.)

Use the trick of passing a throwing callback to setup() to achieve this. I
don't think there's any other way to do this outside of the testharness.js
file.
…fail

Previously, in the shadowrealm-in-dedicatedworker,
shadowrealm-in-sharedworker, shadowrealm-in-serviceworker, and
shadowrealm-in-audioworklet contexts, if the setup code failed or an
exception was thrown outside of a test, the harness would time out because
the message signalling completion to the RemoteContext would never be
posted. This is wasteful.

Instead, catch exceptions during the setup code or importing the test
file, and post a synthetic completion message to the message port.

We don't have access to the scope in which TestsStatus is defined, so we
make a fake status object.
This uses the non-standard `stack` property of Error, if it is present, to
provide stack trace information to the caller of shadowRealmEvalAsync().

The stack trace isn't available in shadowrealm-in-serviceworker and
shadowrealm-in-audioworklet contexts, because they implement a fake
dynamic import with ShadowRealm.prototype.evaluate(), which will wrap any
errors from the imported module in a TypeError and clobber any stack info.
We could do it by adding a try/catch around the module text, but that
would mess with line and column numbers; for now, we'll leave it.
@ptomato ptomato force-pushed the shadowrealm-no-timeout branch from dd39d3e to 21bc331 Compare November 27, 2024 19:29
@ptomato ptomato merged commit f3033a7 into web-platform-tests:master Nov 27, 2024
33 checks passed
@ptomato ptomato deleted the shadowrealm-no-timeout branch November 27, 2024 19:57
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.

4 participants