Enable ShadowRealm testing for ErrorEvent and queueMicrotask#49325
Open
ptomato wants to merge 4 commits into
Open
Enable ShadowRealm testing for ErrorEvent and queueMicrotask#49325ptomato wants to merge 4 commits into
ptomato wants to merge 4 commits into
Conversation
Mahmoudhpp
approved these changes
Nov 22, 2024
96ee05b to
383a3ce
Compare
Ms2ger
approved these changes
Nov 26, 2024
| // META: title=Microtask checkpoint after ShadowRealm onerror events | ||
| // META: global=shadowrealm | ||
|
|
||
| // Adapted from first part of ./resources/checkpoint-after-error-event.js. |
Contributor
There was a problem hiding this comment.
I have not verified that the expected behavior is correct, but I assume it is if it matches the existing test
Adapt the tests for the onerror event on Worker global scopes to cover ShadowRealm global scopes as well. One of the tests uses setTimeout() directly to fire the global onerror event. Use queueMicrotask() instead, since that is [Exposed=*]. We cannot use t.step_timeout() because that wraps the callback in a t.step_func() which catches the error and fails the test.
This test is similar to window-onerror-runtime-error-throw.html and window-onerror-runtime-error.html, but ensuring that the ShadowRealm global's onerror is triggered and not the Window's onerror. By my reading of the spec, we cannot have a test equivalent to window-onerror-parse-error.html in ShadowRealm because ShadowRealm.prototype.evaluate() will exit early if the given code fails to parse.
reportError seems to be minimally tested. ShadowRealm doesn't have the location exposed, so just assume it will be blank. This may need to be changed depending on what browsers do. It is not specified what the value should be in https://html.spec.whatwg.org/#extract-error: "Set _attributes_[message], _attributes_[filename], _attributes_[lineno], and _attributes_[colno] to implementation-defined values derived from _exception_. NOTE: Browsers implement behavior not specified here or in the JavaScript specification to gather values which are helpful, including in unusual cases (e.g., `eval`). In the future, this might be specified in greater detail. This seems like exactly such an unusual case.
383a3ce to
50fd176
Compare
ptomato
commented
Nov 27, 2024
| @@ -1,4 +1,4 @@ | |||
| // META: global=dedicatedworker-module,sharedworker-module | |||
| // META: global=dedicatedworker-module,sharedworker-module,shadowrealm-in-window,shadowrealm-in-shadowrealm,shadowrealm-in-dedicatedworker,shadowrealm-in-sharedworker | |||
Contributor
Author
There was a problem hiding this comment.
With the improved error reporting in #49387 I realized these didn't run in shadowrealm-in-serviceworker and shadowrealm-in-audioworklet because the fake dynamic import isn't actually module code 😖 I'm not sure how important that is though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adapt the tests for the onerror event on Worker global scopes to cover ShadowRealm global scopes as well.
One of the tests uses setTimeout() directly to fire the global onerror event. Use queueMicrotask() instead, since that is [Exposed=*]. We cannot use t.step_timeout() because that wraps the callback in a t.step_func() which catches the error and fails the test.
Run the microtask evaluation order tests in ShadowRealm scopes.
Add a new test ensuring that the behaviour of wrapping exceptions thrown from outer realm functions in a fresh TypeError extends to the onerror event as well.
(This PR was originally for just ErrorEvent and onerror. I added my queueMicrotask coverage as well, because most of the tests are quite related. EDIT: added reportError coverage as well, pending whatwg/html#9893 (comment))