Repository navigation
Conversation
Ms2ger
left a comment
There was a problem hiding this comment.
Thanks for this. Unfortunately you stepped into one of the… less pleasant corners of the web ecosystem.
- I don't have the brain cycles right now to confirm that the current realm is the right choice in principle (lots of history in whatwg/webidl#135).
- Please check the web-api spec as well.
| 1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result. | ||
| If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps. | ||
| 1. Let |instanceObject| be a [=/new=] {{Instance}}. | ||
| 1. Let |instanceObject| be a [=/new=] {{Instance}} in the [=current Realm=]. |
There was a problem hiding this comment.
You don't have a current Realm when running the steps in a queued task, I'm afraid. It's only available when you're being called directly from JS. You'll need to capture the realm at the top of this algorithm (assuming it exists there - check the callers) and use the captured variable within the task.
| 1. If |map|[|memaddr|] [=map/exists=], | ||
| 1. Return |map|[|memaddr|]. | ||
| 1. Let |memory| be a [=/new=] {{Memory}}. | ||
| 1. Let |memory| be a [=/new=] {{Memory}} in the [=current Realm=]. |
There was a problem hiding this comment.
One of the call stacks for this algorithm "create an exports object" → "initialize an instance object" → the bit of "asynchronously instantiate a WebAssembly module" that doesn't have access to the current Realm. So you'll need to pass the realm through explicitly from there.
The WebIDL algorithms,
create a new promiseandcreate a new object implementing the interface, require arealmas their argument:but the specification was lacking it.
This PR supplies the missing realm argument, using the [=current Realm=] notation.
I'm not entirely sure what the exact phrasing should be, though:
there are other call sites of these two algorithms within the WebIDL document itself, and they're not entirely consistent.
Sometimes it uses a simple phrase like
a new Environment Object "in" realm,and sometimes a more verbose one like
a new DOMException "created in" the current realm— and neither quite matches the declaration itself, which uses the preposition
with.For promises, it even elides the realm entirely and just uses
a new promisein a few places (which seems like the same bug of WebIDL document).For now I went with the simplest form, but happy to match whichever phrasing.