Bug 185243 - iframe.contentWindow.document not accessible only on WebKit.
Summary: iframe.contentWindow.document not accessible only on WebKit.
Status: RESOLVED DUPLICATE of bug 11388
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://html.spec.whatwg.org/multipag...
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-03 01:50 PDT by Emilio Cobos Álvarez (:emilio)
Modified: 2018-05-03 13:29 PDT (History)
4 users (show)

See Also:


Attachments
test.html (669 bytes, text/html)
2018-05-03 01:50 PDT, Emilio Cobos Álvarez (:emilio)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Emilio Cobos Álvarez (:emilio) 2018-05-03 01:50:32 PDT
Created attachment 339399 [details]
test.html

See the testcase incoming, which does something useful in every other browser.
Comment 1 Danyao Wang 2018-05-03 07:39:25 PDT
The problem doesn't seem to be with iframe.contentWindow.document. If I just add "var frm = document.getElementById('frm');" at the beginning, WebKit behaves identically to Chrome.

I don't think it's standard to be able to reference HTML element by ID as named variables in JavaScript. I could be wrong.
Comment 2 Ali Juma 2018-05-03 09:10:19 PDT
(In reply to Danyao Wang from comment #1)
> The problem doesn't seem to be with iframe.contentWindow.document. If I just
> add "var frm = document.getElementById('frm');" at the beginning, WebKit
> behaves identically to Chrome.
> 
> I don't think it's standard to be able to reference HTML element by ID as
> named variables in JavaScript. I could be wrong.

See bug 183087; the id becomes a global variable unless it gets shadowed by another explicitly declared global variable. So if adding "var frm = document.getElementById('frm');" changes behavior in this example, that sounds like a bug, since frm should already be referring to that element.
Comment 3 Chris Dumez 2018-05-03 09:27:57 PDT
I believe the issue is that WebKit wrongly uses the iframe's id as the iframe's window name. Because of the ordering of Window's named property getter, we return the iframe's window that matches 'frm' instead of the iframe with id 'frm'.
Comment 4 Chris Dumez 2018-05-03 09:53:08 PDT
(In reply to Chris Dumez from comment #3)
> I believe the issue is that WebKit wrongly uses the iframe's id as the
> iframe's window name. Because of the ordering of Window's named property
> getter, we return the iframe's window that matches 'frm' instead of the
> iframe with id 'frm'.

Ironically, looks like I fixed this in Blink a long time ago :)
https://bugs.chromium.org/p/chromium/issues/detail?id=347169
Comment 5 Chris Dumez 2018-05-03 10:37:07 PDT

*** This bug has been marked as a duplicate of bug 11388 ***
Comment 6 Emilio Cobos Álvarez (:emilio) 2018-05-03 10:45:19 PDT
(In reply to Chris Dumez from comment #4)
> (In reply to Chris Dumez from comment #3)
> > I believe the issue is that WebKit wrongly uses the iframe's id as the
> > iframe's window name. Because of the ordering of Window's named property
> > getter, we return the iframe's window that matches 'frm' instead of the
> > iframe with id 'frm'.
> 
> Ironically, looks like I fixed this in Blink a long time ago :)
> https://bugs.chromium.org/p/chromium/issues/detail?id=347169

Lol.

Ok, thanks a lot, now I can report the CSS bug I really wanted to report :-)