Only disable onbeforeunload if using iframe based webviews

Fixes #122818
上级 3edce10f
......@@ -23,6 +23,7 @@ const isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
const searchParams = new URL(location.toString()).searchParams;
const ID = searchParams.get('id');
const isUsingWebviewTag = searchParams.has('isUsingWebviewTag');
/**
* Use polling to track focus of main webview and iframes within the webview
......@@ -188,6 +189,7 @@ function getVsCodeApiScript(allowMultipleAPIAcquire, useParentPostMessage, state
delete window.top;
delete window.frameElement;
if (!${isUsingWebviewTag}) {
// Try to block webviews from cancelling unloads.
// This blocking is not perfect but should block common patterns
(function() {
......@@ -216,6 +218,7 @@ function getVsCodeApiScript(allowMultipleAPIAcquire, useParentPostMessage, state
}
}
})();
}
`;
}
......
......@@ -156,7 +156,7 @@ export class ElectronWebviewBasedWebview extends BaseWebview<WebviewTag> impleme
// and not the `vscode-file` URI because preload scripts are loaded
// via node.js from the main side and only allow `file:` protocol
this.element!.preload = FileAccess.asFileUri('./pre/electron-index.js', require).toString(true);
this.element!.src = `${Schemas.vscodeWebview}://${this.id}/electron-browser-index.html?platform=electron&id=${this.id}&vscode-resource-origin=${encodeURIComponent(this.webviewResourceEndpoint)}`;
this.element!.src = `${Schemas.vscodeWebview}://${this.id}/electron-browser-index.html?platform=electron&isUsingWebviewTag=true&id=${this.id}&vscode-resource-origin=${encodeURIComponent(this.webviewResourceEndpoint)}`;
}
protected createElement(options: WebviewOptions) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册