有没有办法serviceWorker
从导航器对象中完全删除该属性?(所以表达式('serviceWorker' in navigator)
是假的。)
delete
不起作用:
delete navigator.serviceWorker;
'serviceWorker' in navigator; // true
分配给undefined
不会做任何事情(即使它已经足够了):
navigator.serviceWorker = null;
'serviceWorker' in navigator; // true
navigator.serviceWorker === null; // false
Object.defineProperty
也不起作用:
Object.defineProperty(navigator, "serviceWorker", {
configurable: true,
value: undefined
});
'serviceWorker' in navigator; // true
navigator.serviceWorker === undefined; // true
(这样做的原因是为了让较新的浏览器在测试等方面表现得更像旧浏览器。)