[whatwg/webidl] IDL-level support for permission checks? (Issue #1066)

Not sure if this will work, but thought I'd pitch it... 

Methods defined by various specs will check in a method call is "allowed to use" a particular permission. What might be nice is to have IDL level support for this. I was thinking something like an extended attribute, like: 

```WebIDL
partial interface Navigator {
  [Permission="webshare"] Promise<undefined> share(optional ShareData data = {});
  [Permission="webshare"] boolean canShare(optional ShareData data = {});
};
```

In cases where the return type is a boolean, it would return `false` if not allowed - otherwise, do whatever the steps of the method require.

In other cases, it would throw or reject with a "NotAllowedError" DOMException. 

cc @dontcallmedom @tidoust 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1066

Received on Thursday, 18 November 2021 23:46:08 UTC