在https iframe中注册Service Worker时出现DOMException [英] DOMException when registering service worker inside an https iframe

查看:72
本文介绍了在https iframe中注册Service Worker时出现DOMException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在http(不安全)站点内的https iframe中注册服务工作者.直到最近,我的代码都没有出现任何问题.从上次chrome更新(44)开始,此代码在iframe中失败:

I'm trying to register a service worker in an https iframe inside an http (unsecured) site. Until lately, my code ran without any issues. From the last chrome update (44) this code fails inside the iframe:

navigator.serviceWorker.register('./service-worker.js');

我在控制台中收到此错误:未捕获(承诺)的DOMException:仅允许安全来源

I get this error in console: Uncaught (in promise) DOMException: Only secure origins are allowed

现在是否有任何更改可以阻止受保护的iframe在不安全的父级中运行时注册服务工作者?

Was there any change that now prevents secured iframes from registering service workers if they are running in an unsecured parent?

推荐答案

最近更改.看来现在仍将保持当前行为-请参阅服务工作者规范存储库中的此讨论.这两个讨论都引用此规范作为政策的基础.

It appears that this did change recently. It also appears that the current behaviour will now be maintained - see this discussion at the service worker spec repository. Both of those discussions cite this specification as the basis for the policy.

这篇关于在https iframe中注册Service Worker时出现DOMException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆