Stop using an iframe's id as fallback if its name attribute is not set
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2018 23:18:29 +0000 (23:18 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2018 23:18:29 +0000 (23:18 +0000)
commit0712177fa3b3abb2435b2f782cb326e7a154451e
treeb2e75fcc4ba9088b642f553653dc06d978df4fa4
parent7f29c6bc8b83afdd1e6c6d43b739977aadbef841
Stop using an iframe's id as fallback if its name attribute is not set
https://bugs.webkit.org/show_bug.cgi?id=11388

Reviewed by Geoff Garen.

Source/WebCore:

WebKit had logic to use an iframe's id as fallback name when its name
content attribute is not set. This behavior was not standard and did not
match other browsers:
- https://html.spec.whatwg.org/#attr-iframe-name

Gecko / Trident never behaved this way. Blink was aligned with us until
they started to match the specification in:
- https://bugs.chromium.org/p/chromium/issues/detail?id=347169

This WebKit quirk was causing some Web-compatibility issues because it
would affect the behavior of Window's name property getter when trying
to look up an iframe by id. Because of Window's named property getter
behavior [1], we would return the frame's contentWindow instead of the
iframe element itself.

[1] https://html.spec.whatwg.org/multipage/window-object.html#named-access-on-the-window-object

Test: fast/dom/Window/named-getter-frame-id.html

* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::openURL):
(WebCore::HTMLFrameElementBase::parseAttribute):
(WebCore::HTMLFrameElementBase::didFinishInsertingNode):
* html/HTMLFrameElementBase.h:

LayoutTests:

* fast/dom/Window/named-getter-frame-id-expected.txt: Added.
* fast/dom/Window/named-getter-frame-id.html: Added.
Add layout test coverage.

* fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt:
* fast/dom/Geolocation/srcdoc-watchPosition-expected.txt:
* fast/dom/HTMLAnchorElement/anchor-in-noscroll-iframe-crash.html:
* fast/dom/Window/window-special-properties-expected.txt:
* fast/frames/iframe-no-name-expected.txt:
* fast/frames/iframe-no-name.html:
* fast/layers/prevent-hit-test-during-layout.html:
* fast/xmlhttprequest/xmlhttprequest-no-file-access-expected.txt:
* http/tests/security/clipboard/copy-paste-html-cross-origin-iframe-across-origin.html:
* http/tests/security/contentSecurityPolicy/iframe-blank-url-programmatically-add-external-script-expected.txt:
* http/tests/security/cross-origin-reified-window-property-access.html:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame-expected.txt:
* http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html:
* http/wpt/beacon/keepalive-after-navigation-expected.txt:
* http/wpt/cache-storage/cache-remove-twice.html:
Update some layout tests that relied on our old (non-standard) behavior.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231331 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt
LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt
LayoutTests/fast/dom/HTMLAnchorElement/anchor-in-noscroll-iframe-crash.html
LayoutTests/fast/dom/Window/named-getter-frame-id-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/named-getter-frame-id.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/window-special-properties-expected.txt
LayoutTests/fast/frames/iframe-no-name-expected.txt
LayoutTests/fast/frames/iframe-no-name.html
LayoutTests/fast/layers/prevent-hit-test-during-layout.html
LayoutTests/fast/xmlhttprequest/xmlhttprequest-no-file-access-expected.txt
LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt
LayoutTests/http/tests/quicklook/csp-header-ignored-expected.txt
LayoutTests/http/tests/security/clipboard/copy-paste-html-cross-origin-iframe-across-origin.html
LayoutTests/http/tests/security/contentSecurityPolicy/iframe-blank-url-programmatically-add-external-script-expected.txt
LayoutTests/http/tests/security/cross-origin-reified-window-property-access.html
LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame-expected.txt
LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame-expected.txt
LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html
LayoutTests/http/wpt/beacon/keepalive-after-navigation-expected.txt
LayoutTests/http/wpt/cache-storage/cache-remove-twice.html
LayoutTests/platform/ios/http/tests/quicklook/csp-header-ignored-expected.txt
LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLFrameElementBase.cpp
Source/WebCore/html/HTMLFrameElementBase.h