pin*_*yid 7 javascript google-chrome local-storage
如果我从http://localhost提供我的应用程序,在开发控制台中我可以做window.navigator.storage.estimate()。
如果我从http://example.com提供相同的应用程序,其中example.com从我的 /etc/hosts 解析为 127.0.0.1,window.navigator则未定义。
怎么来的?
(铬是 71)
来自 MDN -> https://developer.mozilla.org/en-US/docs/Web/API/StorageEstimate/quota
看来此功能仅在安全上下文中可用,即 https://
但 Chrome 似乎认为 localhost 也是一个安全上下文,因此不需要 https:// 。我认为这是因为 localhost 通常用于开发目的,并且获取本地域的 SSL 证书可能很棘手。
更多信息请访问https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts,该信息确认file://并被localhost认为是安全的。 if (window.isSecureContext)可用于测试状态。
| 归档时间: |
|
| 查看次数: |
1008 次 |
| 最近记录: |