Always require an extension id if you want consistent webview origins (#163711)

This commit is contained in:
Matt Bierner 2022-10-15 12:26:16 -07:00 committed by GitHub
parent cbee57d415
commit 81d2ccccc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -291,7 +291,7 @@ export class WebviewOriginStore {
this.state = this.memento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE);
}
public getOrigin(viewType: string, extId: ExtensionIdentifier | undefined): string {
public getOrigin(viewType: string, extId: ExtensionIdentifier): string {
const key = this.getKey(viewType, extId);
const existing = this.state[key];
@ -305,7 +305,7 @@ export class WebviewOriginStore {
return newOrigin;
}
private getKey(viewType: string, extId: ExtensionIdentifier | undefined): string {
return JSON.stringify({ viewType, extension: extId?.value });
private getKey(viewType: string, extId: ExtensionIdentifier): string {
return JSON.stringify({ viewType, extension: extId.value });
}
}

View file

@ -178,7 +178,7 @@ export class WebviewViewPane extends ViewPane {
this._activated = true;
const webviewId = generateUuid();
const origin = WebviewViewPane.getOriginStore(this.storageService).getOrigin(this.id, this.extensionId);
const origin = this.extensionId ? WebviewViewPane.getOriginStore(this.storageService).getOrigin(this.id, this.extensionId) : undefined;
const webview = this.webviewService.createWebviewOverlay({
id: webviewId,
origin,