From d1662d76586de9f7ecb0ea6d42a37efb0b62221b Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 15 Aug 2019 15:13:22 -0500 Subject: [PATCH] Ensure service workers are supported before use Fixes #909. --- scripts/vscode.patch | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index 4d112859..7c94e305 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -757,14 +757,18 @@ index 622bb7889b..66dd4b0bbc 100644 self.addEventListener('message', event => { diff --git a/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts b/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts -index dfda6a1cfb..44a01fb0fb 100644 +index dfda6a1cfb..9bd1aa3e64 100644 --- a/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts +++ b/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts -@@ -24,7 +24,7 @@ const _serviceWorker = new class ServiceWorkerStarter { +@@ -24,7 +24,11 @@ const _serviceWorker = new class ServiceWorkerStarter { private _messageHandler?: (event: ExtendableMessageEvent) => void; constructor() { - navigator.serviceWorker.register(ServiceWorkerStarter._url, { scope: '/' }).then(reg => { ++ if (!navigator.serviceWorker) { ++ console.warn('Service workers are not enabled.'); ++ return; ++ } + navigator.serviceWorker.register(ServiceWorkerStarter._url, { scope: window.location.pathname.replace(/\/+$/, '') }).then(reg => { // console.debug('SW#reg', reg); return reg.update();