document.adoptNode (and others causing it) changes the prototype of the adopted node
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: ksenia, Unassigned)
References
Details
Attachments
(2 files)
We've received a report in https://github.com/webcompat/web-bugs/issues/118350 about the discrepancy between Firefox and Chrome when calling instanceof HTMLElement
for an element within an iframe.
The reporter provided a testcase and mentioned that this is causing issues for them in production since Firefox 109.
It returns false
in Firefox when instanceof HTMLElement
is called. And returns true
when the iframe window (instanceof iframe.contentWindow.HTMLElement
) checked instead. The results in Chrome are exact opposite.
mozregression points to https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=5199ec2d73fa7daf423b72416be41383ac1042dc&tochange=95b6c826ad974a967364cb1f137bd8a766051d0a, so I assume this is related to bug1360715
Reporter | ||
Comment 1•2 years ago
|
||
Setting dom.webidl.crosscontext_hasinstance.enabled
to true makes their testcase pass and Firefox starts matching Chrome, but only for instanceof HTMLElement
, which returns true
. instanceof iframe.contentWindow.HTMLElement
is always false
in Chrome. Wonder which behaviour is correct here?
Hi Kagami, could you please take a look at this?
Comment 2•2 years ago
|
||
Set release status flags based on info from the regressing bug 1360715
Updated•2 years ago
|
Comment 3•2 years ago
•
|
||
This is not a regression from bug 1360715, this is more of the node adoption behavior rather than of the instanceof behavior.
el2 instanceof HTMLElement
is true on Gecko too before el.appendChild(e2)
, but the adoption somehow magically changes el2
's prototype, which is very surprising.
Comment 4•2 years ago
•
|
||
Replaced instanceof
with Object.getPrototypeOf()
, and turns out Gecko has been doing this forever (as version 25 was doing the same thing).
Updated•2 years ago
|
Updated•2 years ago
|
Comment 5•2 years ago
|
||
Seems it's known:
Comment 6•2 years ago
|
||
I moved the webcompat report to the bug, hope it works better!
Reporter | ||
Comment 7•2 years ago
|
||
That's good to know, thanks for investigating!
Comment 8•2 years ago
|
||
It sounds like this is old behavior and not actually a regression.
Updated•2 years ago
|
Description
•