Open Bug 1837925 Opened 2 years ago Updated 3 months ago

Simplify the generation of "seenNodes" by defining serialization and deserialization helper methods within "serialize" and "deserialize"

Categories

(Remote Protocol :: WebDriver BiDi, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: whimboo, Unassigned, Mentored)

References

Details

(Whiteboard: [lang=js])

Attachments

(1 file)

As discussed on: https://phabricator.services.mozilla.com/D177496#inline-1000351

There could be commands and events that return a serialized object containing one or more DOM nodes and where we forgot to process the extra data that is introduced with bug 1830884. That means we won't update the WebDriver session's seenNodes map which can later on cause failures because the node hasn't been seen before.

So the question is if we should better require any command and event that uses WindowGlobalBiDiModule.serialize() to have to pass a seenNodes argument to it.

Alternatively we could have all the serialization and deserialization helpers in RemoteValue living within the serialize and deserialize methods - similar to the code in Marionette (json.sys.mjs). As such we could easily return the list of seen nodes as part of the final result without having it to pass through each function invocation.

Summary: Consider making "seenNodes" a mandatory argument for "WindowGlobalBiDiModule.serialize()" → Define serialization and deserialization helper methods within "serialize" and "deserializeConsider making "seenNodes" a mandatory argument for "WindowGlobalBiDiModule.serialize()"

Similar to json.clone() in Marionette all the helper methods that are needed for serialization and deserialization in the RemoteValue.sys.mjs module should be moved below the entry point. This would allow us to more easily collect extra data like seenNodeIds that one or both commands might have to return.

By doing that no BiDi command would have to explicitly create a new Map first and pass it to WindowGlobalBiDiModule.serialize(), but can rely on the return value to get the wanted data.

Summary: Define serialization and deserialization helper methods within "serialize" and "deserializeConsider making "seenNodes" a mandatory argument for "WindowGlobalBiDiModule.serialize()" → Simplify the generation of "seenNodes" by defining serialization and deserialization helper methods within "serialize" and "deserialize"
Mentor: hskupin
Severity: -- → S3
Priority: -- → P3
Whiteboard: [lang=js]
Assignee: nobody → richard.af.cole

New contributor here - I'm going to take this on as my second patch.

Please note that on bug 1832792 we have ongoing work for re-ordering the arguments for all the deserialize related methods. To not end-up in conflicts it might be better to wait a little bit until you start working on this bug if possible.

Depends on: 1832792

Hi Richard, the depending bug has now been fixed. That means if you are still interested please pull the latest changes before starting with the work. Thanks.

Flags: needinfo?(richard.af.cole)

Hi Henrik, I'll rebase and run all tests and have this for you soon.

Flags: needinfo?(richard.af.cole)

Hi Henrik, I had a chance to re-familiarize myself with the code

My current plan -
Keep the wrapper functions of serialize/deserialize within WindowGlobalBiDiModule.sys.mjs (I had initially thought that these needed to be deleted and replaced. My current understanding is that the definitions from the modules will be moved within the wrapper).
Move the definitions of serialize/deserialize from RemoteValue.sys.mjs inside of the 'wrapper functions'.
Run tests

As first action I would suggest that you are refactoring the RemoteValue.sys.mjs file based on comment 1. It means that any special serialization / deserialization function should be moved below serialize or deserialize. Such a change should not cause any regressions, which you can verify by running the following tests:

Once the above is done you can work on part 2, which should be done in a different revision.

Let me know if you have questions.

WIP submitted - https://phabricator.services.mozilla.com/D203322

I moved the following helpers inside of deserialize

  • deserializeValueList
  • deserializeKeyValueList
  • deserializeSharedReference

and the following within serialize

  • serializeArrayLike
  • serializeList
  • serializeMapping
  • serializeNode

It wasn't clear to me if functions like getHandleForObject or getSharedIdForNode would need to be moved into serialize as well.

The following tests all pass

(In reply to Richard Cole from comment #10)

It wasn't clear to me if functions like getHandleForObject or getSharedIdForNode would need to be moved into serialize as well.

Yes, it's fine to leave those out. They do not recursively call into any serialize / deserialize method.

The following tests all pass

Please make sure to also run the following test:
https://searchfox.org/mozilla-central/source/remote/webdriver-bidi/test/browser/browser_RemoteValue.js

If the test passes as well you can push your patch again by using the --no-wip argument so it will be moved out of the WiP status. Thanks!

Hello Richard, I wanted to check back with you if my last comment was helpful and to unblock you from the next steps. Please let me know if there are still issues / questions that need to be solved first. Thanks.

Flags: needinfo?(richard.af.cole)

Sadly I didn't receive any further response from Richard. So I assume that there is no interest to continue working on this bug. As such I'll unassign and put it back into the pool.

Assignee: richard.af.cole → nobody
Flags: needinfo?(richard.af.cole)
Assignee: nobody → richard.af.cole
Status: NEW → ASSIGNED

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #13)

Sadly I didn't receive any further response from Richard. So I assume that there is no interest to continue working on this bug. As such I'll unassign and put it back into the pool.

I apologize for my absence. All four tests are passing, your comment was very helpful. I've submitted to moz-phab - https://phabricator.services.mozilla.com/D203322

Richard, would you mind submitting the patch with --no-wip? That way it will be put into our review queue so that we can take a look. Thanks!

Flags: needinfo?(richard.af.cole)

Hi Richard, I wanted to check back with you if you are still interested to work on this issue even it takes more time. Maybe you could let us know? Thanks.

Assignee: richard.af.cole → nobody
Status: ASSIGNED → NEW

Clear a needinfo that is pending on an inactive user.

Inactive users most likely will not respond; if the missing information is essential and cannot be collected another way, the bug maybe should be closed as INCOMPLETE.

For more information, please visit BugBot documentation.

Flags: needinfo?(richard.af.cole)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: