[HybridWebView] Always serialize the value in JS when invoking#27068
Merged
Conversation
This change just makes adding new tests easier
Contributor
There was a problem hiding this comment.
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
suggested changes
Jan 14, 2025
Eilon
previously approved these changes
Jan 15, 2025
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
undefinedornull, 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