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

Fix HostPromiseRejectionHandler when running script is null #8043

Merged
merged 1 commit into from
Dec 5, 2022

Conversation

domenic
Copy link
Member

@domenic domenic commented Jun 27, 2022

Closes #8041, by falling back to the current settings object instead (similar to what the module-related host hooks do).

This also includes minor editorial updates to HostPromiseRejectionTracker, mostly to link to more Infra terms.

@Lubrsi you review would be appreciated, as well as any ideas on web platform tests we could write.

  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
    • I'm not sure this is testable. In particular I'm not sure whether using testdriver.js to click will have a proper no-running-script setup.
  • Implementation bugs are filed:
    • N/A, everyone already behaves this way

(See WHATWG Working Mode: Changes for more details.)


/webappapis.html ( diff )

Closes #8041, by falling back to the current settings object instead (similar to what the module-related host hooks do).

This also includes minor editorial updates to HostPromiseRejectionTracker, mostly to link to more Infra terms.
@Lubrsi
Copy link

Lubrsi commented Jun 27, 2022

I implemented this in our engine and it works as expected, even reporting unhandled Promise rejections to Sentry:
Screenshot from 2022-06-27 16-25-32
For WPT, my main idea is using the WindowEventHandler event attributes on the body element, for example:

<!DOCTYPE html>
<html>
<head>
</head>
<body onmessage="Promise.reject(new Error('test'))">
<iframe srcdoc="<script>window.parent.postMessage('hello world')</script>">
</iframe>
</body>
</html>

However, in our case, I believe this happened for every unhandled promise rejection, as the promise rejection code is native and is entered from a native function from JavaScript, meaning the running execution context always had a null [[ScriptOrModule]] when running HostPromiseRejectionTracker.In this case, testing unhandled promise rejection anywhere would be sufficient.

I went with WindowEventHandler event attributes above because onmessage will have a null [[ScriptOrModule]] due to being an event handler attribute, and postMessage will queue a task to eventually run the event handler, meaning it will execute in the future with nothing on the JS execution stack initially.

@domenic domenic merged commit 6eaa367 into main Dec 5, 2022
@domenic domenic deleted the hostpromiserejectiontracker branch December 5, 2022 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

"Running script" concept doesn't check if [[ScriptOrModule]] is null
3 participants