Archived
1
0

Fix web view sometimes not loading correctly

Fixes #929.
This commit is contained in:
Asher 2019-08-27 13:42:53 -05:00
parent 830ccfe245
commit d33b2d2af9
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 12 additions and 16 deletions

View File

@ -1109,7 +1109,7 @@ index 0d2d53003b..03489411bb 100644
group: '5_update', group: '5_update',
command: { command: {
diff --git a/src/vs/workbench/contrib/webview/browser/pre/index.html b/src/vs/workbench/contrib/webview/browser/pre/index.html diff --git a/src/vs/workbench/contrib/webview/browser/pre/index.html b/src/vs/workbench/contrib/webview/browser/pre/index.html
index ac53ce590e..69dbbd859c 100644 index ac53ce590e..5411601483 100644
--- a/src/vs/workbench/contrib/webview/browser/pre/index.html --- a/src/vs/workbench/contrib/webview/browser/pre/index.html
+++ b/src/vs/workbench/contrib/webview/browser/pre/index.html +++ b/src/vs/workbench/contrib/webview/browser/pre/index.html
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
@ -1117,12 +1117,12 @@ index ac53ce590e..69dbbd859c 100644
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" <meta http-equiv="Content-Security-Policy"
- content="default-src 'none'; script-src 'self'; frame-src 'self'; style-src 'unsafe-inline'; worker-src 'self';" /> - content="default-src 'none'; script-src 'self'; frame-src 'self'; style-src 'unsafe-inline'; worker-src 'self';" />
+ content="default-src 'none'; script-src 'self' 'unsafe-inline'; frame-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'self'; img-src https: data:; font-src 'self';" /> + content="default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; frame-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'self'; img-src https: data:; font-src 'self';" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
diff --git a/src/vs/workbench/contrib/webview/browser/pre/main.js b/src/vs/workbench/contrib/webview/browser/pre/main.js diff --git a/src/vs/workbench/contrib/webview/browser/pre/main.js b/src/vs/workbench/contrib/webview/browser/pre/main.js
index 63585fc25c..f49b63e024 100644 index 63585fc25c..16102b89f1 100644
--- a/src/vs/workbench/contrib/webview/browser/pre/main.js --- a/src/vs/workbench/contrib/webview/browser/pre/main.js
+++ b/src/vs/workbench/contrib/webview/browser/pre/main.js +++ b/src/vs/workbench/contrib/webview/browser/pre/main.js
@@ -256,7 +256,7 @@ @@ -256,7 +256,7 @@
@ -1134,19 +1134,15 @@ index 63585fc25c..f49b63e024 100644
const newDocument = new DOMParser().parseFromString(text, 'text/html'); const newDocument = new DOMParser().parseFromString(text, 'text/html');
newDocument.querySelectorAll('a').forEach(a => { newDocument.querySelectorAll('a').forEach(a => {
@@ -265,6 +265,12 @@ @@ -379,7 +379,7 @@
}
});
+ // REVIEW: Why is it required for scripts to be loaded at the end? newFrame.contentWindow.addEventListener('keydown', handleInnerKeydown);
+ // Without this the document in the iframe appears to simply truncate.
+ newDocument.querySelectorAll('script').forEach(script => { - newFrame.contentWindow.addEventListener('DOMContentLoaded', e => {
+ newDocument.body.appendChild(script); + newFrame.contentWindow.addEventListener('load', e => {
+ }); if (host.fakeLoad) {
+ newFrame.contentDocument.open();
// apply default script newFrame.contentDocument.write(newDocument);
if (options.allowScripts) {
const defaultScript = newDocument.createElement('script');
diff --git a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts b/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts diff --git a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts b/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts
index 7a95ffda9e..fdb14da4ee 100644 index 7a95ffda9e..fdb14da4ee 100644
--- a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts --- a/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts

View File

@ -66,7 +66,7 @@ export const getMediaMime = (filePath?: string): string => {
return filePath && (vsGetMediaMime(filePath) || (<{[index: string]: string}>{ return filePath && (vsGetMediaMime(filePath) || (<{[index: string]: string}>{
".css": "text/css", ".css": "text/css",
".html": "text/html", ".html": "text/html",
".js": "text/javascript", ".js": "application/javascript",
".json": "application/json", ".json": "application/json",
})[extname(filePath)]) || "text/plain"; })[extname(filePath)]) || "text/plain";
}; };