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

Add "arguments" deserialization tests for "script.callFunction" #34830

Merged

Conversation

sadym-chromium
Copy link
Contributor

  • Added tests for arguments deserialization in script.callFunction

@lutien
Copy link
Contributor

lutien commented Jul 13, 2022

Looks perfect to me!
Tagging @whimboo and @juliandescottes, if you also want to have a look

@whimboo whimboo changed the title Add deserialization tests Add "arguments" deserialization tests for "script.callFunction" Jul 15, 2022
)
async def test_primitive_values(bidi_session, top_context, argument):
result = await bidi_session.script.call_function(
function_declaration=f"(arg) => arg",
Copy link
Contributor

Choose a reason for hiding this comment

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

So the problem here is that we actually do not compare the result of the deserialization but a complete round trip including deserialization and serialization. In case of the serialization also be broken we wouldn't detect a failure for the deserialization.

As such we would need an assertion for a type check as part of the function declaration. If that passes the value also needs to be checked. Then the test will pass if no exceptionDetails are part of the return value for the script.callFunction call.

The same actually also applies to the other test.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sadym-chromium fyi whimboo is off for a few weeks, but I agree with his feedback here. Ideally this should only assert deserialization. I received a ping for this review today but I didn't see a new patch. I'm assuming the ping was sent before seeing the comment above.

Copy link
Contributor Author

@sadym-chromium sadym-chromium Jul 19, 2022

Choose a reason for hiding this comment

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

Yeah, I pinged before I saw the comment.

Ideally, we want to test only deserialization, but comparing sets, arrays, maps and objects on the backend is quite messy. So having we tested serialization, I guess it's acceptable trade-off just to check the types of non-pimitives on the server side, and check the "deserialized-serialized" values on the client side. I implemented this approach in the current revision. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@juliandescottes juliandescottes left a comment

Choose a reason for hiding this comment

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

Thanks for the update Maksim! The compromise sounds fine, but asserting arrays, maps, sets (...) in JS would not make the test that hard to follow IMO. Back to you for a few comments, I'll take one last look with those addressed.

webdriver/tests/bidi/script/call_function/arguments.py Outdated Show resolved Hide resolved
webdriver/tests/bidi/script/call_function/arguments.py Outdated Show resolved Hide resolved
webdriver/tests/bidi/script/call_function/arguments.py Outdated Show resolved Hide resolved
webdriver/tests/bidi/script/call_function/arguments.py Outdated Show resolved Hide resolved
Copy link
Contributor

@juliandescottes juliandescottes left a comment

Choose a reason for hiding this comment

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

Thanks!

target=ContextTarget(top_context["context"]),
)

assert result == nan_remote_value
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use recursive compare here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense. Done

@sadym-chromium sadym-chromium dismissed whimboo’s stale review July 22, 2022 11:59

According to @juliandescottes, @whimboo is off for a few weeks

@sadym-chromium sadym-chromium enabled auto-merge (squash) July 22, 2022 12:01
@sadym-chromium sadym-chromium merged commit 073bed0 into web-platform-tests:master Jul 22, 2022
@sadym-chromium sadym-chromium deleted the deserialization branch September 21, 2022 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants