Bug 1726363 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Say that there is a callback type that returns a promise:

```webidl
interface LockManager {
  Promise<any> request(DOMString name,
                       LockGrantedCallback callback);
};

callback LockGrantedCallback = Promise<any> (Lock? lock);
```

Currently the way to get the result from `aCallback.Call()` for the following each case is all different:

```
locks.request("foo", () => true);
locks.request("foo", () => { throw new Error("error"); });
locks.request("foo", async () => { throw new Error("error"); });
```

1. Call() will return a resolved promise.
2. Call() will pass the exception to its ErrorResult argument and the return value is nullptr.
3. Call() will return a rejected promise.

I don't think there is a good reason to differentiate 2 and 3, and it would be great if Call() always return a promise in this case.
Say that there is a callback type that returns a promise:

```webidl
interface LockManager {
  Promise<any> request(DOMString name,
                       LockGrantedCallback callback);
};

callback LockGrantedCallback = Promise<any> (Lock? lock);
```

Currently the way to get the result from `aCallback.Call()` for the following each case is different:

```
locks.request("foo", () => { throw new Error("error"); });
locks.request("foo", async () => { throw new Error("error"); });
```

1. Call() will pass the exception to its ErrorResult argument and the return value is nullptr.
1. Call() will return a rejected promise.

I don't think there is a good reason to differentiate 1 and 2, and it would be great if Call() always return a promise in this case.
Say that there is a callback type that returns a promise:

```webidl
interface LockManager {
  Promise<any> request(DOMString name,
                       LockGrantedCallback callback);
};

callback LockGrantedCallback = Promise<any> (Lock? lock);
```

Currently the way to get the result from `aCallback.Call()` for the following each case is different:

```
locks.request("foo", () => { throw new Error("error"); });
locks.request("foo", async () => { throw new Error("error"); });
```

1. Call() will pass the exception to its ErrorResult argument and the return value is nullptr.
1. Call() will return a rejected promise.

I don't think there is a good reason to differentiate 1 and 2, and it would be great if Call() always return a promise in this case, just as general return values are always wrapped by a Promise.
Say that there is a callback type that returns a promise:

```webidl
interface LockManager {
  Promise<any> request(DOMString name,
                       LockGrantedCallback callback);
};

callback LockGrantedCallback = Promise<any> (Lock? lock);
```

Currently the way to get the result from `aCallback.Call()` for the following each case is different:

```
locks.request("foo", () => { throw new Error("error"); });
locks.request("foo", async () => { throw new Error("error"); });
```

1. Call() will pass the exception to its ErrorResult argument and the return value is nullptr.
1. Call() will return a rejected promise.

I don't think there is a good reason to differentiate 1 and 2, and it would be great if Call() always return a promise in this case, just as general return values are always wrapped by Promises.

Back to Bug 1726363 Comment 0