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

[Windows] Remove 2nd WebView used to add base tag when using HtmlWebViewSource #21892

Merged
merged 3 commits into from
Apr 23, 2024

Conversation

Foda
Copy link
Member

@Foda Foda commented Apr 17, 2024

Description of Change

This PR removes the use of a 2nd "hidden" WebView2 that was used to parse and add a HTML base tag to the head tag when setting the HTML source of a WebView to a string.

This was done by appending the base tag script to the start of the user's HTML string, which the WebView then adds into the head element. While this is technically not valid HTML, all current browsers correct this behavior.

This is a work-around for the lack of being able to set the base URL when navigating to a string using WebView2 (MicrosoftEdge/WebView2Feedback#530).

As a bonus, using HtmlWebViewSource should now be 2x faster 😅

Issues Fixed

Fixes #21631

@Foda Foda requested a review from a team as a code owner April 17, 2024 21:51
@dotnet-policy-service dotnet-policy-service bot added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 17, 2024
Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

LGTM but could we include an UITest loading a local html and validating that everything works comparing a snapshot (for example)?

@Foda Foda requested a review from jsuarezruiz April 22, 2024 22:41
@PureWeen PureWeen merged commit 440fa7f into main Apr 23, 2024
49 checks passed
@PureWeen PureWeen deleted the foda/webview2crash branch April 23, 2024 21:57
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[windows] Account for ObjectDisposedException coming from device tests for MauiWebView
5 participants