diff --git a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts index 7dc37dd9fa1..57d40fb3cb2 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts @@ -220,9 +220,9 @@ class WebviewEditor extends BaseWebviewEditor { this.contextKey, this.findInputFocusContextKey, { - enableWrappedPostMessage: true - }, - false); + enableWrappedPostMessage: true, + useSameOriginForRoot: false + }); this._webview.onDidClickLink(this.onDidClickLink, this, this._contentDisposables); diff --git a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts index 706eb304bef..e6d5499598a 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts @@ -421,7 +421,7 @@ export class ExtensionEditor extends BaseEditor { .then(body => { const allowedBadgeProviders = this.extensionsWorkbenchService.allowedBadgeProviders; const webViewOptions = allowedBadgeProviders.length > 0 ? { allowScripts: false, allowSvgs: false, svgWhiteList: allowedBadgeProviders } : {}; - this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions, false); + this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions); const removeLayoutParticipant = arrays.insert(this.layoutParticipants, this.activeWebview); this.contentDisposables.push(toDisposable(removeLayoutParticipant)); this.activeWebview.contents = body; diff --git a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts index bc9904993a5..39542505062 100644 --- a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts +++ b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts @@ -97,8 +97,10 @@ export class HtmlPreviewPart extends WebviewEditor { this._contextViewService, this.contextKey, this.findInputFocusContextKey, - webviewOptions, - true); + { + ...webviewOptions, + useSameOriginForRoot: true + }); if (this.input && this.input instanceof HtmlInput) { const state = this.loadViewState(this.input.getResource()); diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index b5a3fa71a3d..1775cad5e66 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -24,6 +24,7 @@ export interface WebviewOptions { readonly allowSvgs?: boolean; readonly svgWhiteList?: string[]; readonly enableWrappedPostMessage?: boolean; + readonly useSameOriginForRoot?: boolean; } export class Webview { @@ -44,8 +45,7 @@ export class Webview { private readonly _contextViewService: IContextViewService, private readonly _contextKey: IContextKey, private readonly _findInputContextKey: IContextKey, - private _options: WebviewOptions, - useSameOriginForRoot: boolean + private _options: WebviewOptions ) { this._webview = document.createElement('webview'); this._webview.setAttribute('partition', this._options.allowSvgs ? 'webview' : `webview${Date.now()}`); @@ -62,7 +62,7 @@ export class Webview { this._webview.style.outline = '0'; this._webview.preload = require.toUrl('./webview-pre.js'); - this._webview.src = useSameOriginForRoot ? require.toUrl('./webview.html') : 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%20lang%3D%22en%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3Chead%3E%0D%0A%09%3Ctitle%3EVirtual%20Document%3C%2Ftitle%3E%0D%0A%3C%2Fhead%3E%0D%0A%3Cbody%20style%3D%22margin%3A%200%3B%20overflow%3A%20hidden%3B%20width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E'; + this._webview.src = this._options.useSameOriginForRoot ? require.toUrl('./webview.html') : 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%20lang%3D%22en%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3Chead%3E%0D%0A%09%3Ctitle%3EVirtual%20Document%3C%2Ftitle%3E%0D%0A%3C%2Fhead%3E%0D%0A%3Cbody%20style%3D%22margin%3A%200%3B%20overflow%3A%20hidden%3B%20width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E'; this._ready = new Promise(resolve => { const subscription = addDisposableListener(this._webview, 'ipc-message', (event) => { @@ -76,7 +76,7 @@ export class Webview { }); }); - if (!useSameOriginForRoot) { + if (!this._options.useSameOriginForRoot) { let loaded = false; this._disposables.push(addDisposableListener(this._webview, 'did-start-loading', () => { if (loaded) { diff --git a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts index a4b84a8f94e..0c81a3376dd 100644 --- a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts +++ b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts @@ -97,8 +97,7 @@ export class ReleaseNotesEditor extends WebviewEditor { this._contextViewService, this.contextKey, this.findInputFocusContextKey, - {}, - false); + {}); if (this.input && this.input instanceof ReleaseNotesInput) { const state = this.loadViewState(this.input.version);