Skip to content

Content from iframes is still not fully supported #133

@mflorea

Description

@mflorea

It seems the fix from #126 is not enough to properly support iframes. The root problem is that the realm of the JavaScript interface (e.g. Text) of a DOM node is not always synchronized with the node's owner document. For instance, for a given DOM text node the following is not always true:

textNode instanceof textNode.ownerDocument.defaultView.Text

One such case when this is not true is when a DOM node is adopted. Adopting a DOM node changes its owner document, but it seems it doesn't change its prototype in all browsers. See https://jsfiddle.net/f7pbmue6/2/

  • Firefox (119) updates the prototype
  • Chrome (119) doesn't update the prototype

Judging by https://bugzilla.mozilla.org/show_bug.cgi?id=1470017 my feeling is that Chrome's behavior is the standard one which means the prototype and the owner document doesn't have to be in sync. If that is the case then using instanceof for checking the type of a DOM node becomes very fragile, since the node's prototype can be from any realm (you can imagine having multiple iframes and adopting nodes between them). We would need a way to find the (original) realm in which the DOM node was created, but I'm not sure this is possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions