-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[HybridWebView] Always serialize the value in JS when invoking #27068
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change just makes adding new tests easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/index.html: Language not supported
- src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/invokedotnettests.html: Language not supported
mattleibow
commented
Jan 10, 2025
This change just makes adding new tests easier
…return # Conflicts: # src/Controls/tests/DeviceTests/Elements/HybridWebView/HybridWebViewTests.cs
…ing-return # Conflicts: # src/Controls/tests/DeviceTests/Elements/HybridWebView/HybridWebViewTests.cs
Eilon
requested changes
Jan 14, 2025
mattleibow
changed the title
Don't deserialize a string from JS into a .NET string, return it directly
[HybridWebView] Don't deserialize a string from JS into a .NET string, return it directly
Jan 15, 2025
Eilon
previously approved these changes
Jan 15, 2025
mattleibow
changed the title
[HybridWebView] Don't deserialize a string from JS into a .NET string, return it directly
[HybridWebView] Always serialize the value from JS when invoking
Jan 17, 2025
mattleibow
changed the title
[HybridWebView] Always serialize the value from JS when invoking
[HybridWebView] Always serialize the value in JS when invoking
Jan 17, 2025
Eilon
approved these changes
Jan 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Previously, there was a special case for calling back into .NET from JavaScript that would not convert a string to JSON. This made sense, a string is already a string, so no need to convert to a JSON string.
But...
This would mean if the response was
undefined
ornull
, then the JS would serialize to"undefined"
or"null"
. Then we would see that the .NET expected a string and say well, return it directly. This would mean that a null in JS would end up a"null"
- string value.We can't add a special logic in .NET to convert
"null"
into anull
, because what would happen if the JS function wanted returned a"null"
string? It would then be converted to null.This PR solves all the issues by removing the special case of string and always serializes to JSON. This means that if the JS function returned the string
"null"
, it would get serialized into a string"\"null\""
(with quotes); but a null string would be serialized into a string"null"
(no quotes). The deserializer in .NET would then basically remove a layer of quotes giving use the correct result:"\"null\""
becomes a string again, but"null"
becomes null.Issues Fixed
Fixes #26765