这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
getAllowlistForFeature()
方法在
FeaturePolicy
allows query of the allow list for a specific feature for the current Feature Policy.
const allowlist = FeaturePolicy.getAllowlistForFeature(<feature>)
A specific feature name must be specified.
An Allow list for the specified feature.
The function will raise a warning if the specified Feature Policy directive name is not known. However, it will also return empty array, inditating that no origin is allowed to use the feature.
The followin example prints all the origins that are allowed to use Camera API by the Feature Policy. Please note that Camera API might be restricted by the Permissions API, if the user did not grant the corrsponding permission yet.
// First, get the Feature Policy object
const featurePolicy = document.featurePolicy
// Then query feature for specific
const allowlist = featurePolicy.getAllowlistForFeature("camera")
for (const origin of allowlist){
console.log(origin)
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Feature Policy
The definition of 'getAllowlistForFeature' in that specification. |
编者草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getAllowlistForFeature
|
Chrome
74
|
Edge 79 | Firefox 65 | IE No |
Opera
62
|
Safari No | WebView Android 74 |
Chrome Android
74
|
Firefox Android 65 |
Opera Android
48
Disabled
|
Safari iOS No | Samsung Internet Android 11.0 |
完整支持
不支持
实验。期望将来行为有所改变。
用户必须明确启用此特征。