w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
676 stars 190 forks source link

Refactor "get a known element" and "get a known shadow root" #1712

Closed whimboo closed 1 year ago

whimboo commented 1 year ago

With https://github.com/w3c/webdriver/pull/1707 the browsing context check for an element or shadow root is done after the staleness check. Hereby a staleness check wouldn't be necessary at all if we know that the element's associated browsing context is not the currently selected one. Means moving the content of step 3.1 into step 2 would simplify those two independent checks.

https://w3c.github.io/webdriver/#dfn-get-a-known-element

Example: An element reference from a frame will never be a valid reference within the top-level frame, as such the staleness check will always be false.


Preview | Diff

whimboo commented 1 year ago

As it looks like the proposed changes are not enough. When get a node returns null because an element has been garbage collected, its web element reference is still known and as such step 2 should not throw a no such element error.

whimboo commented 1 year ago

There was one more regression that the most recent update fixes now. Without it we only checked for a node reference is known in case of the element is null. But that's broken and the check has to always be performed. As such we can do that at the very beginning even before get node given that both work independently from each other.

whimboo commented 1 year ago

Related changes should not affect the behavior of current WebDriver classic tests. This can be proven by the wdspec results for my appropriate changes for Firefox in https://bugzilla.mozilla.org/show_bug.cgi?id=1807227.