Return "clientWindow" property in "browsingContext.contextCreated" event for window.open on Android and in "browsingContext.contextDestroyed" event
Categories
(Remote Protocol :: WebDriver BiDi, task, P2)
Tracking
(firefox140 fixed)
Tracking | Status | |
---|---|---|
firefox140 | --- | fixed |
People
(Reporter: Sasha, Assigned: ldebeasi)
References
(Blocks 3 open bugs)
Details
(Whiteboard: [webdriver:m16][webdriver:external][webdriver:relnote][wptsync upstream])
Attachments
(3 files)
During the work on bug 1920952, we found out that the way we usually retrieve the window for browsing context by getting first a tab for the browsing context doesn't work in case of "browsingContext.contextCreated" event is sent for a new window (because probably a tab is not attached yet) and in case of "browsingContext.contextDestroyed" event (because probably the tab is gone already).
So we either have to find a different way to retrieve the window for a browsing context (which would work for both cases) or delay sending "browsingContext.contextCreated" event to the moment when a tab is created. In case of delaying the tab creation, we also might be able to save window ID to retrieve it for "browsingContext.contextDestroyed" event.
In the scope of this bug, we also have to update all the remaining wdspec tests to check for clientWindow
field, which were not updated in the scope of bug 1920952 to not increase amount of failures.
Reporter | ||
Updated•4 months ago
|
Comment 1•4 months ago
|
||
Sasha, based on the code as landed via bug 1920952 is browsingContext.created
still affected? Based on your comment and latest suggestion on the Phab revision it doesn't sound like that.
Reporter | ||
Comment 2•4 months ago
•
|
||
(In reply to Henrik Skupin [:whimboo][⌚️UTC+2] from comment #1)
Sasha, based on the code as landed via bug 1920952 is
browsingContext.created
still affected? Based on your comment and latest suggestion on the Phab revision it doesn't sound like that.
"browsingContext.contextCreated" event for window.open on Android is still affected.
I updated the bug title.
Assignee | ||
Comment 3•4 months ago
|
||
I can try to fix this if you'd like! If I'm able to come up with a solution we all like I can also fix the incorrect test in my previous patch too.
If so, any suggestions for what I should try first or things to look out for?
Reporter | ||
Comment 4•3 months ago
|
||
Hi Liam!
Sorry for the delay! Sure, you can take bug :)
I think I would approach it in this way:
- First, update all the remaining test to check for
clientWindow
, run the tests on desktop and android to verify again where the current logic fails; - Explore the
context
object to look for other ways to retrieve the window. Search around: https://searchfox.org/mozilla-central/source/ to see how it's done in other parts of mozilla-central; - In worst case scenario if there is nothing better for
browsingContext.contextDestroyed
, we can do something similar to what we did for browsing context ids, where we have a map to retrieve them differently specifically for this event, see what we do withnavigableIds
map: https://searchfox.org/mozilla-central/source/remote/shared/TabManager.sys.mjs#28-32.
Let me know if you have any questions! (For quicker feedback, you can also join our matrix channel).
Comment 5•3 months ago
|
||
An information which hasn't made it into this bug yet is the potential usage of the topChromeWindow
property of a CanonicalBrowsingContext. Maybe it would help if present in those cases?
Assignee | ||
Comment 6•3 months ago
|
||
Hey there,
I have a fix in place that seems to be working well (Thanks for the tip on using topChromeWindow
, that came in handy!). How would you recommend I update this test in original_opener.py
?
It looks like the context we want in the get_tree
result is not always in the same place depending on the @pytest.mark.parametrize
value used. I was thinking of filtering the get_tree
result to find the context we want and then asserting on that, but I wanted to check in case you had a better idea.
Comment 7•3 months ago
|
||
(In reply to Liam DeBeasi from comment #6)
It looks like the context we want in the
get_tree
result is not always in the same place depending on the@pytest.mark.parametrize
value used. I was thinking of filtering theget_tree
result to find the context we want and then asserting on that, but I wanted to check in case you had a better idea.
Great to hear! This test has actually 3 different parameterizations. Which of those is causing the trouble for you? We seem to only test top-level browsing contexts in that test so I wonder what the actual difference is that you are seeing. Maybe you can add an excerpt from the trace log? Thanks!
Assignee | ||
Comment 9•3 months ago
|
||
Assignee | ||
Comment 10•3 months ago
|
||
Whoops looks like I somehow submitted my comment right after attaching a file. You can ignore the trace log summary at the bottom of my comment as I included the full log as an attachment.
Changing the root in the get_tree
call to get_tree(root=context_info["context"])
that "fixes" the issue, but I don't know if that's the correct way to do it since we're using context_info
as a reference for both sides of the assertion.
Comment 11•3 months ago
|
||
Liam, the attached trace log only contains the actual test assertion details. In the future it will be good to actually get the output as well between sending the command and receiving the response. But lets see...
So when you call get_tree()
you are actually passing in top_level_context["context"]
which is the context of the initially opened window via bidi_session.browsing_context.create
but not by using window.open()
. As you said it is because root=top_level_context["context"]
which will return the first opened window via browsingContext.create()
, but not window.open
. What you want is to assert the clientWindow
field of context_info
against a known value that we need to get via the result
value of bidi_session.script.evaluate()
.
Assignee | ||
Comment 12•3 months ago
|
||
Liam, the attached trace log only contains the actual test assertion details. In the future it will be good to actually get the output as well between sending the command and receiving the response. But lets see...
Oh good to know! I'll make sure to do that next time.
So when you call get_tree() you are actually passing in top_level_context["context"] which is the context of the initially opened window via bidi_session.browsing_context.create but not by using window.open(). As you said it is because root=top_level_context["context"] which will return the first opened window via browsingContext.create(), but not window.open. What you want is to assert the clientWindow field of context_info against a known value that we need to get via the result value of bidi_session.script.evaluate().
Thanks a lot for the help. I was able to get the test fixed. I'll get this code up for review shortly.
Assignee | ||
Comment 13•3 months ago
|
||
Updated•3 months ago
|
Assignee | ||
Comment 14•3 months ago
|
||
Reporter | ||
Updated•2 months ago
|
Comment 15•2 months ago
|
||
Comment 17•2 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/191baf1be3d0
https://hg.mozilla.org/mozilla-central/rev/40f9fe959b19
Reporter | ||
Updated•2 months ago
|
Updated•25 days ago
|
Description
•