Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn webview extensions that use the vscode-resource: scheme directly #81685

Closed
mjbvz opened this issue Sep 30, 2019 · 2 comments
Closed

Warn webview extensions that use the vscode-resource: scheme directly #81685

mjbvz opened this issue Sep 30, 2019 · 2 comments
Assignees
Labels
extensions Issues concerning extensions verification-needed Verification of issue is requested verified Verification succeeded webview Webview issues

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Sep 30, 2019

Problem

The webview.asWebviewUri is now the preferred way to load local resources in webview. We really want all webviews to migrate to using this api instead of using vscode-resource uri directly. Reasons:

  • asWebviewUri (mostly) handles some tricky edge cases around network drives on windows
  • asWebviewUri makes it possible to have a webviews that can load a mix of local and remote content.
  • asWebviewUri work much better on the web

Proposal

When developing a webview extension, warn in the console if that extension tries creating a webview that looks like it uses vscode-resource instead of webview.asWebviewUri

@mjbvz mjbvz added the verification-needed Verification of issue is requested label Sep 30, 2019
@mjbvz mjbvz added this to the September 2019 milestone Sep 30, 2019
@mjbvz mjbvz self-assigned this Sep 30, 2019
@mjbvz
Copy link
Collaborator Author

mjbvz commented Sep 30, 2019

For verification, use the cat coding webview sample: https://github.com/Microsoft/vscode-extension-samples/tree/master/webview-sample

Specifically, roll back this change for testing: microsoft/vscode-extension-samples@708bc30#diff-90272a6a871150e841f43e808eccbd84

Test

  1. In development mode, you get a debug console warning when using vscode-resource in the html (such as for loading an image)
  2. Adding any calls to .asWebviewUri suppress the warning
  3. The warning does not show up in non-development mode

@mjbvz mjbvz changed the title Warn webview extensions that use the vscode-resource: scheme Warn webview extensions that use the vscode-resource: scheme directly Sep 30, 2019
@mjbvz mjbvz closed this as completed in e904a5f Sep 30, 2019
@mjbvz mjbvz added extensions Issues concerning extensions webview Webview issues labels Sep 30, 2019
@mjbvz
Copy link
Collaborator Author

mjbvz commented Sep 30, 2019

Note that our check for vscode-resource usage in the html is intentionally pretty simple and easy to get around. It uses the same simple logic we use to rewrite uris for the web but still should catch many common use cases of vscode-resource

@roblourens roblourens added the verified Verification succeeded label Oct 3, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions verification-needed Verification of issue is requested verified Verification succeeded webview Webview issues
Projects
None yet
Development

No branches or pull requests

2 participants