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',
command: {
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
+++ b/src/vs/workbench/contrib/webview/browser/pre/index.html
@@ -4,7 +4,7 @@
@ -1117,12 +1117,12 @@ index ac53ce590e..69dbbd859c 100644
<meta charset="UTF-8">
<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' '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 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
index 63585fc25c..f49b63e024 100644
index 63585fc25c..16102b89f1 100644
--- a/src/vs/workbench/contrib/webview/browser/pre/main.js
+++ b/src/vs/workbench/contrib/webview/browser/pre/main.js
@@ -256,7 +256,7 @@
@ -1134,19 +1134,15 @@ index 63585fc25c..f49b63e024 100644
const newDocument = new DOMParser().parseFromString(text, 'text/html');
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?
+ // Without this the document in the iframe appears to simply truncate.
+ newDocument.querySelectorAll('script').forEach(script => {
+ newDocument.body.appendChild(script);
+ });
+
// apply default script
if (options.allowScripts) {
const defaultScript = newDocument.createElement('script');
newFrame.contentWindow.addEventListener('keydown', handleInnerKeydown);
- newFrame.contentWindow.addEventListener('DOMContentLoaded', e => {
+ newFrame.contentWindow.addEventListener('load', e => {
if (host.fakeLoad) {
newFrame.contentDocument.open();
newFrame.contentDocument.write(newDocument);
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
--- 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}>{
".css": "text/css",
".html": "text/html",
".js": "text/javascript",
".js": "application/javascript",
".json": "application/json",
})[extname(filePath)]) || "text/plain";
};