From 74335e9bf3efecdfbbd7af4f2e26a09dc3005ec6 Mon Sep 17 00:00:00 2001 From: Pierre Papin Date: Wed, 14 Oct 2020 23:42:37 +0200 Subject: [PATCH] fix download issues in webviews (#108603) * fix download issues in webviews * also add allow-download in ts src --- src/vs/workbench/contrib/webview/browser/pre/main.js | 2 +- src/vs/workbench/contrib/webview/browser/webviewElement.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/webview/browser/pre/main.js b/src/vs/workbench/contrib/webview/browser/pre/main.js index 0684a7e44d5..690c6855605 100644 --- a/src/vs/workbench/contrib/webview/browser/pre/main.js +++ b/src/vs/workbench/contrib/webview/browser/pre/main.js @@ -492,7 +492,7 @@ const newFrame = document.createElement('iframe'); newFrame.setAttribute('id', 'pending-frame'); newFrame.setAttribute('frameborder', '0'); - newFrame.setAttribute('sandbox', options.allowScripts ? 'allow-scripts allow-forms allow-same-origin allow-pointer-lock' : 'allow-same-origin allow-pointer-lock'); + newFrame.setAttribute('sandbox', options.allowScripts ? 'allow-scripts allow-forms allow-same-origin allow-pointer-lock allow-downloads' : 'allow-same-origin allow-pointer-lock'); if (host.fakeLoad) { // We should just be able to use srcdoc, but I wasn't // seeing the service worker applying properly. diff --git a/src/vs/workbench/contrib/webview/browser/webviewElement.ts b/src/vs/workbench/contrib/webview/browser/webviewElement.ts index c24df8a7a27..f142c2c2172 100644 --- a/src/vs/workbench/contrib/webview/browser/webviewElement.ts +++ b/src/vs/workbench/contrib/webview/browser/webviewElement.ts @@ -67,7 +67,7 @@ export class IFrameWebview extends BaseWebview implements Web // Wait the end of the ctor when all listeners have been hooked up. const element = document.createElement('iframe'); element.className = `webview ${options.customClasses || ''}`; - element.sandbox.add('allow-scripts', 'allow-same-origin', 'allow-forms', 'allow-pointer-lock'); + element.sandbox.add('allow-scripts', 'allow-same-origin', 'allow-forms', 'allow-pointer-lock', 'allow-downloads'); element.style.border = 'none'; element.style.width = '100%'; element.style.height = '100%';