Do not use unsupported feature names in Firefox

This commit is contained in:
Alexandru Dima 2021-06-09 22:02:21 +02:00
parent b1bc7be9d1
commit 7390a8d7a4
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
2 changed files with 12 additions and 2 deletions

View file

@ -23,6 +23,11 @@ const isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
navigator.userAgent.indexOf('CriOS') === -1 &&
navigator.userAgent.indexOf('FxiOS') === -1;
const isFirefox = (
navigator.userAgent &&
navigator.userAgent.indexOf('Firefox') >= 0
);
const searchParams = new URL(location.toString()).searchParams;
const ID = searchParams.get('id');
const expectedWorkerVersion = parseInt(searchParams.get('swVersion'));
@ -674,7 +679,9 @@ export async function createWebviewManager(host) {
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-downloads' : 'allow-same-origin allow-pointer-lock');
newFrame.setAttribute('allow', options.allowScripts ? 'clipboard-read; clipboard-write;' : '');
if (!isFirefox) {
newFrame.setAttribute('allow', options.allowScripts ? 'clipboard-read; clipboard-write;' : '');
}
// We should just be able to use srcdoc, but I wasn't
// seeing the service worker applying properly.
// Fake load an empty on the correct origin and then write real html

View file

@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { isFirefox } from 'vs/base/browser/browser';
import { addDisposableListener } from 'vs/base/browser/dom';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IMenuService } from 'vs/platform/actions/common/actions';
@ -81,7 +82,9 @@ export class IFrameWebview extends BaseWebview<HTMLIFrameElement> implements Web
const element = document.createElement('iframe');
element.className = `webview ${options.customClasses || ''}`;
element.sandbox.add('allow-scripts', 'allow-same-origin', 'allow-forms', 'allow-pointer-lock', 'allow-downloads');
element.setAttribute('allow', 'clipboard-read; clipboard-write;');
if (!isFirefox) {
element.setAttribute('allow', 'clipboard-read; clipboard-write;');
}
element.style.border = 'none';
element.style.width = '100%';
element.style.height = '100%';