Bug 148787

Summary: Document.body should return the first body / frameset child of the html element
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, kangil.han, kling, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar, WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2
Attachments:
Description Flags
Patch none

Description Chris Dumez 2015-09-03 22:30:00 PDT
Document.body should return the *first* body / frameset child of the html element as per the specification:
https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2

Chrome and Firefox both behave correctly. However, WebKit first looks for a frameset child and returns it if it find one. It then falls back to looking for a body child. document.body thus returns a wrong result in this case:
<html>
  <body></body>
  <frameset></frameset>
</html>

This is covered by the following newly imported W3C test:
http/tests/w3c/html/dom/documents/dom-tree-accessors/document.body-getter.html
Comment 1 Chris Dumez 2015-09-03 22:30:35 PDT
rdar://problem/22566850
Comment 2 Chris Dumez 2015-09-03 22:35:34 PDT
Created attachment 260568 [details]
Patch
Comment 3 WebKit Commit Bot 2015-09-04 10:40:17 PDT
Comment on attachment 260568 [details]
Patch

Clearing flags on attachment: 260568

Committed r189354: <http://trac.webkit.org/changeset/189354>
Comment 4 WebKit Commit Bot 2015-09-04 10:40:21 PDT
All reviewed patches have been landed.  Closing bug.