我在一个应用程序的HTTP头中添加了Feature-Policy。它工作得很好,但我在Chrome上有这样的消息:
Error with Feature-Policy header: Unrecognized feature: 'document-domain'.Chrome无法识别此功能,但Firefox可以识别此功能。此消息会导致应用程序的测试套件出现问题。
我查看了我们可以在Chrome上使用的the list of switches,但没有找到合适的。我知道根据使用的浏览器改变头文件可能是可能的,但这是一件很痛苦的事情。理想的做法是在头文件中添加一些东西。
最好的解决方案是什么?
发布于 2020-08-12 16:32:47
您需要使用正确(较新)版本的Chrome
查看接受https://github.com/w3c/webappsec-permissions-policy/blob/master/features.md的Chrome版本与策略功能的表
我刚刚用当前的Chrome版本进行了测试
标题类似于
feature-policy: autoplay 'self'; camera 'none'; document-domain 'self'; encrypted-media 'self'; fullscreen 'self'; geolocation 'none'; microphone 'none'; midi 'none'; payment 'none'; xr-spatial-tracking 'none';document-domain
如果你不能使用新的Chrome版本,在链接的w3c文档中提到的命令行界面标记应该会帮助你
--enable-blink-features=ExperimentalProductivityFeatures另外,要注意标题的表达方式,一些功能会随着时间的推移而更改名称(例如,vr (old) => xr-spatial-tracking (new))
并且原点必须正确地用单引号括起来
# wrong
Feature-Policy: autoplay self; camera none;
# correct
Feature-Policy: autoplay 'self'; camera 'none';最后但并非最不重要的一点是,Feature-Policy标头似乎将重命名为Permissions-Policy,并且用于声明要素允许的原点的语法也将更改
请参阅以供参考:
发布于 2021-08-09 02:27:51
在Python上,如果只想删除这种警告消息,则添加
chrome_options.add_argument('--log-level=1')更多信息请点击此处List of Chromium Command Line Switches
log-level: Sets the minimum log level.
Valid values are from 0 to 3:
INFO = 0 (default)
WARNING = 1
LOG_ERROR = 2
LOG_FATAL = 3https://stackoverflow.com/questions/57188511
复制相似问题