[w3c/permissions] Maybe add navigator.permissions.supports()? (#136)

Can't remember if this was raised previously, but was coding something up  and found that I had to wrap the API in a try/catch a little bit annoying when a name of a permission might be potentially unknown. 

```JS
  let permCheck;
  try {
    permCheck = await navigator.permissions.query({ name: "whatever" });
  } catch (err) {
    return; // not supported
  }
```
I wonder if we can either change the name in the dictionary to allow a DOMString, 

```JS
const permCheck = await navigator.permissions.query({ name: "whatever" });
permCheck.state === "unknown"; // or "not-supported"
```

or adds some kind of "navigator.permissions.supports()" method. 


```JS
if (navigator.permissions.supports("whatever")){
    return; // not supported, oh well.  
};
const  permCheck = await navigator.permissions.query({ name: "whatever" });
```

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

Received on Friday, 27 January 2017 07:06:59 UTC