Closed Bug 1654513 Opened 4 years ago Closed 4 years ago

Move usage of element store from content to parent process

Categories

(Remote Protocol :: Marionette, task, P2)

task

Tracking

(Fission Milestone:M6c, firefox83 fixed)

RESOLVED FIXED
83 Branch
Fission Milestone M6c
Tracking Status
firefox83 --- fixed

People

(Reporter: whimboo, Assigned: impossibus)

References

Details

(Whiteboard: [marionette-fission-mvp][complex])

Attachments

(1 file)

While working on implementing WebDriver:FindElement over on bug 1654454, I noticed that there is a problem when we should raise Stale Element errors but we don't. Given that for each page being loaded we get a new JSWindowActor pair, storing the already found elements there, will always cause an empty list. As such no State Element is raised for already retrieved elements.

The same would most likely be the case for frames, but that's something I cannot test yet because WebDriver:SwitchToFrame hasn't been implemented yet.

When transfering the elements from the client to the parent process we should also include the browsing context (id) the element actually lives within. Similar to what ContentDOMReference.jsm is doing. That way we can make sure to only validate elements from the currently set browsing context.

Maja, do you want to have a look at this over the next 2 weeks?

Flags: needinfo?(mjzffr)

It shouldn't actually block bug 1654454 bug depend on it. Otherwise you won't be able to actually test it.

No longer blocks: 1654454
Depends on: 1654454

Yes

Flags: needinfo?(mjzffr)
Assignee: nobody → mjzffr
Status: NEW → ASSIGNED
Whiteboard: [marionette-fission-mvp]
Fission Milestone: --- → M6c

I'll summarize some recent conversations and investigations about this.

Marionette's element store basically maps a {uuid, element-type} (see WebElement) to a DOM element (weakref) and it's used to detect stale elements, for example. The scope of this bug is the element store used by the MarionetteFrameParent/Child actors. The child actor needs to operate on actual Elements.

Note: If we instantiate the element store in the global scope of MarionetteFrameChild.jsm then it lives in a content process. This actually works fine, even with cross-origin navigation, but that's not enough. If there's any remoteness change (such as navigating to about:robots), we lose any state we stored. If there are cross-origin subframes, they will each see a different element store in their own process, which is not what we want.

So as mentioned before, we want the element store in the parent process, but then we have a lot of IPC: for every element update or look-up in the child actor, we have to send a request to the parent actor.

The two related ideas I have so far are to (1) map from ContentDOMReference identifier to WebElement in global scope of MarionetteFrameParent.jsm alongside an element.Store, and then use only ContentDOMReference in the child actor. And/or (2) refactor Marionette's element.Store as a fork of ContentDOMReference -- some initial investigation was done in Bug 1650800

(In reply to Maja Frydrychowicz :maja_zf (UTC-4) (maja@mozilla.com) from comment #3)

So as mentioned before, we want the element store in the parent process, but then we have a lot of IPC: for every element update or look-up in the child actor, we have to send a request to the parent actor.

Element lookups should only be done by the executing method that lives in the child process (actor). Anything in the parent process wouldn't have to know about that element except its WebElement id. Note that resolving the id would even only be possible within the same process the website actually runs in.

The two related ideas I have so far are to (1) map from ContentDOMReference identifier to WebElement in global scope of MarionetteFrameParent.jsm alongside an element.Store, and then use only ContentDOMReference in the child actor. And/or (2) refactor Marionette's element.Store as a fork of ContentDOMReference -- some initial investigation was done in Bug 1650800

Note that for (1) the parent process exactly would have to know about the type of node (element, window, frame). That information would have to be transferred beside the element's weakref id. And in regards of (2) it would be good if that's something we should do at all or not. If there is a clear statement that it should not be done, we just immediately drop the idea.

In the discussion above, we're considering forking ContentDOMReference.jsm to meet Marionette's requirements for an element store as we move parts of the Marionette protocol to a JSWindowActor implementation. Is ContentDOMReference.jsm expected to change much? Is it expected to be used in the longer term?

Flags: needinfo?(kmaglione+bmo)

Honestly, I'm probably going to replace it with something completely native eventually. The implementation isn't super efficient. But I don't think you should have any issues if you fork it.

That said, I'm not entirely clear on why you need to fork at all. What doesn't ContentDOMReference do that you need, and why can't it just be updated to do it?

Flags: needinfo?(kmaglione+bmo)

In the parent process, ReferenceStore maps from WebElement uuids to
the ElementIdentifier expected by ContentDOMReference and the
WebElement json representation. Thus, the elements retrieved in
MarionetteFrameChild via ContentDOMReference are tracked
across all types of navigation so we can accurately throw errors
when stale elements are used.

The other goal here is take advantage of ContentDOMReference
while keeping other Marionette internals around elements largely
the same.

Blocks: 1662469
Whiteboard: [marionette-fission-mvp] → [marionette-fission-mvp][complex]
Attachment #9175089 - Attachment description: Bug 1654513 - Track seen web content elements in parent process → Bug 1654513 - [marionette] Track seen web content elements in parent process
Pushed by mjzffr@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/7b70f6088f0c
[marionette] Track seen web content elements in parent process r=marionette-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 83 Branch
Regressions: 1671370
No longer regressions: 1671370
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: