Skip to content

Commit

Permalink
Specify that returned Promises are created in the relevant realm
Browse files Browse the repository at this point in the history
Note that these semantics differ from JavaScript async functions, which
create a Promise in the current Realm.

Verified in Chromium and Firefox that HTMLImageElement.decode and
CustomElementsRegistry.whenDefined return Promise instances from
the relevant realm.

(I'm not sure what's the preferred way to typeset "this", or if it would
be preferred to thread it explicitly through the algorithm. Also, it's
not quite necessary to use the relevant Promise.resolve function, since
resolve effectively uses the relevant realm of its receiver(!))

Resolves part of whatwg#135
  • Loading branch information
littledan committed Dec 12, 2018
1 parent 5a20e34 commit 688df8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.bs
Expand Up @@ -7855,11 +7855,15 @@ objects.
An ECMAScript value |V| is [=converted to an IDL value|converted=]
to an IDL <a interface lt="Promise">Promise<var ignore>T</var></a> value as follows:

1. Let |promise| be [=!=] <a abstract-op>Call</a>({{%Promise_resolve%}}, {{%Promise%}}, «|V|»).
1. Let |realm| be the [=relevant Realm=] of the |this| value that led to the execution of this algorithm.
1. Let |promise| be [=!=] <a abstract-op>Call</a>(|realm|.\[[Intrinsics]].[[{{%Promise_resolve%}}]], |realm|.\[[Intrinsics]].[[{{%Promise%}}]], «|V|»).
1. Return the IDL [=promise type=] value that is a reference to the
same object as |promise|.
</div>

Issue: The relevant |this| value is not always well-defined; see
<a href="https://github.com/heycam/webidl/issues/135">#135</a> for discussion.

<p id="promise-to-es">
The result of [=converted to an ECMAScript value|converting=]
an IDL [=promise type=] value to an ECMAScript
Expand Down

0 comments on commit 688df8c

Please sign in to comment.