Closed whimboo closed 1 year ago
Note that Document
nodes do not have the full feature set as Element
nodes have, eg. Get Element Attribute
and others will / might not work.
The Browser Testing and Tools Working Group just discussed Should HTMLDocument nodes be serialized as web element reference
.
@sadym-chromium your feedback would be welcome. Thanks.
It looks like the spec tells us throwing "circular reference" exception when document is serialized, because of:
document.doctype
;document.firstChild.ownerDocument
;document.defaultView
.Removing the field id
will be a breaking change, while adding new document-specific fields to serialization seems fine.
@whimboo sorry for the late reply, it required some research.
Thank you @sadym-chromium. I'm going to land my wdspec test change on mozilla-central, which will be synced soon via https://github.com/web-platform-tests/wpt/pull/36619 so that we expect a failure and are compliant with the WebDriver specification.
If it turns out that consumers see regressions we might have to further discuss how to handle documents in detail. Until then I'll leave this issue open and will come to it once Firefox 108 is released and / or we got user feedback.
see also https://github.com/web-platform-tests/wpt/issues/30157 where I seem to have said that ad-hoc testing showed non-element node types were far from interoperable; I was sure there was some issue in this repo but I can't find it
So far I haven't seen any negative feedback about this particular change. As such I would say that we close this issue as done.
Right now the WebDriver specification creates a
web element reference
inJSON clone
when thevalue
is of instanceElement
, which basically maps toElement nodes
in the HTML spec.But when you check the
Node
interface you can see thatElement nodes
have a type of1
andDocument nodes
a type of9
. That means that HTMLDocument nodes are notElements
for WebDriver and as such shouldn't be serialized as such.But recently when investigating a test failure in Firefox I noticed that Chrome is actually passing this test and returns the
HTMLDocument
as web element reference. This is against the WebDriver specification.The question is now if Chrome should fix that broken behavior (not sure if this could cause regressions for existing tests) or if we should allow the serialization of
HTMLDocument
. Maybe the WebDriver BiDi specification could benefit from that as well?CC'ing @sadym-chromium and @jgraham for now, and I'll put it onto our monthly WebDriver agenda for this week.