Web IDL specifies that DOM operations must return a reject promise and never throw an exception, however V8 throws a TypeError if the receiver object is not of type of the interface.
https://heycam.github.io/webidl/#dfn-create-operation-function
--------
3.6.7. Operations
To create an operation function
...
And then, if an exception was thrown:
1. If the operation has a return type that is a promise type, then:
1. Let reject be the initial value of %Promise%.reject.
2. Return the result of calling reject with %Promise% as the this object and the exception as the single argument value.
--------
If Blink specified v8::Signature when defining v8::FunctionTemplate for a DOM operation, V8 checks the signature when the function has got called, and then V8 throws a TypeError because of mismatch of the type of |this| object. However, we'd like to return a reject promise created from a TypeError instead.
Should V8 provide a new API to support this situation?
Comment 1 by haraken@chromium.org
, Oct 24 2016