Skip to content

fix: load static webview resources with the editor from the same domain - #411

Merged
vitaliy-guliy merged 1 commit into
mainfrom
webview-resources-to-local
Sep 9, 2024
Merged

vitaliy-guliy merged 1 commit into
mainfrom
webview-resources-to-local

Conversation

@vitaliy-guliy

@vitaliy-guliy vitaliy-guliy commented Sep 6, 2024 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Normally, Visual Studio Code loads the webview static resources from a CDN.

After merging this PR the webview static resources in Che-Code ( there are several files https://github.com/che-incubator/che-code/tree/main/code/src/vs/workbench/contrib/webview/browser/pre ) will be loaded from the same location as the editor ( from the same host ).

Before, we added an option for turning this feature on for instances that are behind a proxy.

Probably something related to the cross-domain policy has been changed in the upstream (but I cannot say for sure) and it brought us some isues with handling the webview events. If the webview scripts are loaded from the same host as the editor, the events are not blocked, so loading everything from one place is the cheapest way to fix the problem.

The feature is still configurable. It can be turned off by defining WEBVIEW_LOCAL_RESOURCES=false environment variable for tooling container. But this thing could be discussed. To not confuse the user we can give up using the WEBVIEW_LOCAL_RESOURCES variable at all.

What issues does this PR fix?

eclipse-che/che#22986

How to test this PR?

  1. Any workspace
  • create a workspace using the editor image from this pull request
  • preview any README that has a hyperlink
  • click the link
  1. Ansible sample
  • create a workspace using the ansible sample with applying the editor image from this pull request
  • Openshift welcome page should be opened automatically. Scroll down a bit and click on buttons. Clicking must work.
  • Go to Ansible view, click Get started and in the appeared Ansible content creator tab check that clicking on the links works.

It would be nice to open any walkthrough that has a markdown (display the content on the right) and check that clicking works as well.

Screenshot from 2024-09-09 11-00-45

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

@github-actions

github-actions Bot commented Sep 6, 2024 •

Copy link
Copy Markdown
Contributor

Click here to review and test in web IDE: Contribute

@github-actions

github-actions Bot commented Sep 6, 2024

Copy link
Copy Markdown
Contributor

@vitaliy-guliy
vitaliy-guliy marked this pull request as ready for review September 9, 2024 08:06
@vitaliy-guliy vitaliy-guliy added the made-with-che Changes made with Che-Code label Sep 9, 2024

@azatsarynnyy azatsarynnyy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it on the suggested patch Developer Sandbox instance. Everything works as expected.
See the attached screencast I recorded:

Screen Recording 2024-09-09 at 12 06 47

@azatsarynnyy

Copy link
Copy Markdown
Member

@vitaliy-guliy does it make sense to create an issue for Che-Code currently doesn't support loading from CDN?
In order not to lose this information and make it easy to find for anyone who would be interested in supporting CDN. However, I haven't heard that MS CDN support is required by someone among Che users.

@vitaliy-guliy

Copy link
Copy Markdown
Contributor Author

@vitaliy-guliy does it make sense to create an issue for Che-Code currently doesn't support loading from CDN? In order not to lose this information and make it easy to find for anyone who would be interested in supporting CDN. However, I haven't heard that MS CDN support is required by someone among Che users.

It's difficult to say whether or not using the CDN gives some benefits.
I think cashing is not the main reason why Visual Source Code developers decided to use CDN. I think it could be related as well to some iframe security things, but I do not understand which ones.

FYI, to make it working on our side we patched the html file which is used to initialize the webview iframe.

You can just compare the upstream
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/webview/browser/pre/index.html#L8
with the downstream one where we removed the sha
https://github.com/che-incubator/che-code/blob/main/code/src/vs/workbench/contrib/webview/browser/pre/index.html#L8

@vitaliy-guliy

Copy link
Copy Markdown
Contributor Author

@azatsarynnyy thanks for the review!

@vitaliy-guliy
vitaliy-guliy merged commit e03223c into main Sep 9, 2024
@vitaliy-guliy
vitaliy-guliy deleted the webview-resources-to-local branch September 9, 2024 12:13
@ghost

ghost commented Sep 9, 2024

Copy link
Copy Markdown

Build 3.17 :: code_3.x/1468: Console, Changes, Git Data

@ghost

ghost commented Sep 9, 2024

Copy link
Copy Markdown

@ghost

ghost commented Sep 9, 2024

Copy link
Copy Markdown

@ghost

ghost commented Sep 9, 2024

Copy link
Copy Markdown

Build 3.17 :: get-sources-rhpkg-container-build_3.x/7681: FAILURE

code : 3.x :: Failed in 64065315 : BREW:BUILD/STATUS:UNKNOWN
FAILURE:; copied to quay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

made-with-che Changes made with Che-Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants