WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
108537
window[id] evaluates to iframe browsing context instead of element itself
https://bugs.webkit.org/show_bug.cgi?id=108537
Summary
window[id] evaluates to iframe browsing context instead of element itself
Matthew Dempsky
Reported
2013-01-31 15:04:42 PST
If there's an iframe tag like <iframe id='fr'> then according to the HTML spec, window['fr'] should evaluate to the same thing as document.getElementById('fr'). But instead WebKit evaluates it the the iframe's browsing context. The HTML spec allows window['fr'] to evaluate to a browsing context named 'fr', but it says an iframe's browsing context should only be initialized by name attributes, not id attributes. There's a demo URL at
http://shinobi.dempsky.org/~matthew/misc/chrome-iframe-bug.html
. This shows window['fr'] evaluates to a Window object on Chrome and Safari, but on Firefox it correctly evaluates to the HTMLIframeElement. See also
https://code.google.com/p/chromium/issues/detail?id=171873
.
Attachments
Add attachment
proposed patch, testcase, etc.
Matthew Dempsky
Comment 1
2013-01-31 15:18:32 PST
Actually, the bug seems to be that the iframe's browsing context is being set to the iframe element's id attribute, even though the HTML spec explicitly states only the name attribute should be used: """ The name attribute, if present, must be a valid browsing context name. The given value is used to name the nested browsing context. When the browsing context is created, if the attribute is present, the browsing context name must be set to the value of this attribute; otherwise, the browsing context name must be set to the empty string. Whenever the name attribute is set, the nested browsing context's name must be changed to the new value. If the attribute is removed, the browsing context name must be set to the empty string. """ ---
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-iframe-element.html#attr-iframe-name
It's possible to confirm that document.getElementById('fr').contentWindow.name evaluates to 'fr', although document.getElementById('fr').getAttribute('name') evaluates to null. Also, even after executing document.getElementById('fr').setAttribute('name', 'foo'), document.getElementById('fr').contentWindow.name continues to evaluate to 'fr' instead of 'foo', contrary to the quoted spec above.
PhistucK
Comment 2
2017-06-23 00:46:25 PDT
Fixed in Chrome 35. All of the browsers except Safari return [object HTMLIFrameElement] -
https://jsfiddle.net/s9zyt7x9/3/
Ahmad Saleem
Comment 3
2023-11-11 12:58:08 PST
(In reply to PhistucK from
comment #2
)
> Fixed in Chrome 35. > All of the browsers except Safari return [object HTMLIFrameElement] - >
https://jsfiddle.net/s9zyt7x9/3/
Safari 17.2 returns also '[object HTMLIFrameElement]', it seems to be fixed now. Should we mark this as 'RESOLVED CONFIGURATION CHANGED'?
Ahmad Saleem
Comment 4
2024-01-10 13:42:47 PST
Marking this as "RESOLVED CONFIGURATION CHANGED" (Safari 17.2.1). Please reopen if it is still reproducible.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug