diff --git a/src/vs/workbench/contrib/webview/browser/pre/index-no-csp.html b/src/vs/workbench/contrib/webview/browser/pre/index-no-csp.html
index 563b7ee12e100..ae4043e3dbf10 100644
--- a/src/vs/workbench/contrib/webview/browser/pre/index-no-csp.html
+++ b/src/vs/workbench/contrib/webview/browser/pre/index-no-csp.html
@@ -219,7 +219,6 @@
const swPath = `service-worker.js?v=${expectedWorkerVersion}&vscode-resource-base-authority=${searchParams.get('vscode-resource-base-authority')}&remoteAuthority=${searchParams.get('remoteAuthority') ?? ''}`;
navigator.serviceWorker.register(swPath)
- .then(() => navigator.serviceWorker.ready)
.then(async registration => {
/**
* @param {MessageEvent} event
@@ -241,7 +240,6 @@
// `unregister` and `register` here.
return registration.unregister()
.then(() => navigator.serviceWorker.register(swPath))
- .then(() => navigator.serviceWorker.ready)
.finally(() => { resolve(); });
}
};
@@ -434,13 +432,13 @@
};
hostMessaging.onMessage('did-load-resource', (_event, data) => {
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.getRegistration().then(registration => {
assertIsDefined(registration.active).postMessage({ channel: 'did-load-resource', data }, data.data?.buffer ? [data.data.buffer] : []);
});
});
hostMessaging.onMessage('did-load-localhost', (_event, data) => {
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.getRegistration().then(registration => {
assertIsDefined(registration.active).postMessage({ channel: 'did-load-localhost', data });
});
});
diff --git a/src/vs/workbench/contrib/webview/browser/pre/index.html b/src/vs/workbench/contrib/webview/browser/pre/index.html
index 5a512cac9fd83..c709fcbdf51a9 100644
--- a/src/vs/workbench/contrib/webview/browser/pre/index.html
+++ b/src/vs/workbench/contrib/webview/browser/pre/index.html
@@ -5,7 +5,7 @@
+ content="default-src 'none'; script-src 'sha256-PXLLbTxUqUn4p+KvvFj5cqYN1AHAoeOHkHWZwsmuGck=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
navigator.serviceWorker.ready)
.then(async registration => {
/**
* @param {MessageEvent} event
@@ -242,7 +241,6 @@
// `unregister` and `register` here.
return registration.unregister()
.then(() => navigator.serviceWorker.register(swPath))
- .then(() => navigator.serviceWorker.ready)
.finally(() => { resolve(); });
}
};
@@ -435,13 +433,13 @@
};
hostMessaging.onMessage('did-load-resource', (_event, data) => {
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.getRegistration().then(registration => {
assertIsDefined(registration.active).postMessage({ channel: 'did-load-resource', data }, data.data?.buffer ? [data.data.buffer] : []);
});
});
hostMessaging.onMessage('did-load-localhost', (_event, data) => {
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.getRegistration().then(registration => {
assertIsDefined(registration.active).postMessage({ channel: 'did-load-localhost', data });
});
});