Skip to content

Commit 0bac1a3

Browse files
authored
chore: fixed webview errors in tests (#724)
1 parent 1bc1d9e commit 0bac1a3

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@
5858
"@semantic-release/git": "^7.0.16",
5959
"@types/glob": "^7.1.1",
6060
"@types/mocha": "^5.2.7",
61-
"@types/node": "8.9.5",
61+
"@types/node": "^12.11.7",
6262
"@types/semver": "^6.0.0",
6363
"@types/tmp": "0.1.0",
64-
"@types/vscode": "1.26.0",
64+
"@types/vscode": "1.40.0",
6565
"@types/xml2js": "^0.4.4",
6666
"@typescript-eslint/eslint-plugin": "^2.5.0",
6767
"@typescript-eslint/parser": "^2.5.0",
@@ -85,8 +85,7 @@
8585
},
8686
"greenkeeper": {
8787
"ignore": [
88-
"@types/node",
89-
"@types/vscode"
88+
"@types/node"
9089
]
9190
},
9291
"contributes": {

src/messages.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ async function showCommitInput(message?: string, filePaths?: string[]) {
4848
}
4949
);
5050

51-
const styleUri = Uri.file(
51+
const stylePathOnDisk = Uri.file(
5252
path.join(__dirname, "..", "css", "commit-message.css")
53-
).with({ scheme: "vscode-resource" });
53+
);
54+
const styleUri = panel.webview.asWebviewUri(stylePathOnDisk);
5455

5556
let beforeForm = "";
5657
if (filePaths && filePaths.length) {
@@ -72,6 +73,13 @@ async function showCommitInput(message?: string, filePaths?: string[]) {
7273
<head>
7374
<meta charset="UTF-8">
7475
<meta name="viewport" content="width=device-width, initial-scale=1.0">
76+
77+
<!--
78+
Use a content security policy to only allow loading images from https or from our extension directory,
79+
and only allow scripts that have a specific nonce.
80+
-->
81+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src ${panel.webview.cspSource} https:; script-src ${panel.webview.cspSource}; style-src ${panel.webview.cspSource};">
82+
7583
<title>Commit Message</title>
7684
<link rel="stylesheet" href="${styleUri}">
7785
</head>

0 commit comments

Comments
 (0)