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

What realm should promises be created in? #384

Closed
domenic opened this issue Jul 19, 2017 · 1 comment
Closed

What realm should promises be created in? #384

domenic opened this issue Jul 19, 2017 · 1 comment

Comments

@domenic
Copy link
Member

domenic commented Jul 19, 2017

There are several cases of interest:

  1. Rejected promises created automatically by the Web IDL spec because of Web IDL-spec thrown exceptions, e.g. security check, bad this value, etc.
  2. Rejected promises created automatically by the Web IDL spec when the operation/attribute description throws an exception and we convert that into a rejection. (Typically this is viewed as a backstop for bad spec-writing.)
  3. Fulfilled promises created automatically by the Web IDL spec by converting the operation/attribute return into a Promise. (Per spec this happens every time, even if the operation/attribute returns a promise. That is a no-op if the promise constructors match, but do they? That's what we're discussing here.)
  4. Promises created by the common phrase a new promise in specs.

In an offline discussion, it was mentioned there are specific issues for cross-origin access here, but I don't quite understand that as none of the safelisted cross-origin properties return promises.

Ideally all of these would be consistent (either current or relevant). Right now the situation is pretty unclear... One reading of the spec would say it should be current (based on ECMAScript defaults). But that isn't great for situations where a promise is cached, e.g. https://w3c.github.io/battery/#dom-navigator-getbattery. That spec specifically goes out of its way to use relevant, which seems fragile to require of all specs.

Another dimension of consistency is that we've decided exception objects should be created in the current realm.

Not sure what the right path is here.

/cc @yuki3 @bzbarsky

@domenic
Copy link
Member Author

domenic commented Mar 19, 2020

I think this is settled. Creating a promise now requires passing a realm explicitly, and this is done in the spec.

@domenic domenic closed this as completed Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant