<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[182677] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/182677">182677</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2015-04-12 21:42:53 -0700 (Sun, 12 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Legacy scroll behavior on HTMLBodyElement should only apply to the first body element of a document
https://bugs.webkit.org/show_bug.cgi?id=143651

Source/WebCore:

Reviewed by Sam Weinig.

WebKit has some very weird behaviors for the scroll methods on body. This patch
address the first bug: only the first body element should have the legacy behavior.

The relevant text in spec:
-http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft
-http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop
-http://dev.w3.org/csswg/cssom-view/#dom-element-scrollwidth
-http://dev.w3.org/csswg/cssom-view/#dom-element-scrollheight

Tests: fast/dom/Element/body-scrollHeight-basics-quirks.html
       fast/dom/Element/body-scrollLeft-basics-quirks.html
       fast/dom/Element/body-scrollTop-basics-quirks.html
       fast/dom/Element/body-scrollWidth-basics-quirks.html
       fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html
       fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html

* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::isFirstBodyElementOfDocument):
(WebCore::HTMLBodyElement::scrollLeft):
(WebCore::HTMLBodyElement::setScrollLeft):
(WebCore::HTMLBodyElement::scrollTop):
(WebCore::HTMLBodyElement::setScrollTop):
(WebCore::HTMLBodyElement::scrollHeight):
(WebCore::HTMLBodyElement::scrollWidth):
* html/HTMLBodyElement.h:

LayoutTests:

Patch by Benjamin Poulain  &lt;benjamin@webkit.org&gt; and Diego Perini &lt;diego.perini@gmail.com&gt; on 2015-04-12
Reviewed by Sam Weinig.

* fast/dom/Element/body-scrollHeight-basics-quirks-expected.txt: Added.
* fast/dom/Element/body-scrollHeight-basics-quirks.html: Added.
* fast/dom/Element/body-scrollLeft-basics-quirks-expected.txt: Added.
* fast/dom/Element/body-scrollLeft-basics-quirks.html: Added.
* fast/dom/Element/body-scrollTop-basics-quirks-expected.txt: Added.
* fast/dom/Element/body-scrollTop-basics-quirks.html: Added.
* fast/dom/Element/body-scrollWidth-basics-quirks-expected.txt: Added.
* fast/dom/Element/body-scrollWidth-basics-quirks.html: Added.
Test the various behaviors.

* fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft-expected.txt: Added.
* fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html: Added.
* fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop-expected.txt: Added.
* fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html: Added.
Those tests target specifically the bug.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLBodyElementcpp">trunk/Source/WebCore/html/HTMLBodyElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLBodyElementh">trunk/Source/WebCore/html/HTMLBodyElement.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollHeightbasicsquirksexpectedtxt">trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollHeightbasicsquirkshtml">trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollLeftbasicsquirksexpectedtxt">trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollLeftbasicsquirkshtml">trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollTopbasicsquirksexpectedtxt">trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollTopbasicsquirkshtml">trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollWidthbasicsquirksexpectedtxt">trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomElementbodyscrollWidthbasicsquirkshtml">trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollLeftexpectedtxt">trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollLefthtml">trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html</a></li>
<li><a href="#trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollTopexpectedtxt">trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollTophtml">trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (182676 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-04-13 01:29:59 UTC (rev 182676)
+++ trunk/LayoutTests/ChangeLog        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-04-12  Benjamin Poulain  &lt;benjamin@webkit.org&gt; and Diego Perini  &lt;diego.perini@gmail.com&gt;
+
+        Legacy scroll behavior on HTMLBodyElement should only apply to the first body element of a document
+        https://bugs.webkit.org/show_bug.cgi?id=143651
+
+        Reviewed by Sam Weinig.
+
+        * fast/dom/Element/body-scrollHeight-basics-quirks-expected.txt: Added.
+        * fast/dom/Element/body-scrollHeight-basics-quirks.html: Added.
+        * fast/dom/Element/body-scrollLeft-basics-quirks-expected.txt: Added.
+        * fast/dom/Element/body-scrollLeft-basics-quirks.html: Added.
+        * fast/dom/Element/body-scrollTop-basics-quirks-expected.txt: Added.
+        * fast/dom/Element/body-scrollTop-basics-quirks.html: Added.
+        * fast/dom/Element/body-scrollWidth-basics-quirks-expected.txt: Added.
+        * fast/dom/Element/body-scrollWidth-basics-quirks.html: Added.
+        Test the various behaviors.
+
+        * fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft-expected.txt: Added.
+        * fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html: Added.
+        * fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop-expected.txt: Added.
+        * fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html: Added.
+        Those tests target specifically the bug.
+
</ins><span class="cx"> 2015-04-12  Gyuyoung Kim  &lt;gyuyoung.kim@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Enable Media Source
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollHeightbasicsquirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks-expected.txt (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks-expected.txt        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+Test the &quot;scrollHeight&quot; properties on the body element in quirks mode.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initial values
+PASS document.body.scrollHeight is document.documentElement.scrollHeight
+
+Now we create a body element, it should not have a scrollHeight since it is not the first body element of the document.
+PASS document.body.scrollHeight is document.documentElement.scrollHeight
+PASS floatingBody.scrollHeight is 0
+
+We add a new body element after the first body element, this should have no impact on the state.
+PASS document.body.scrollHeight is document.documentElement.scrollHeight
+PASS secondSiblingBody.scrollHeight is secondSiblingBody.clientHeight
+PASS document.body.scrollHeight is not secondSiblingBody.scrollHeight
+
+We add a new body element inside the first body element, this should have no impact on the state.
+PASS document.body.scrollHeight is document.documentElement.scrollHeight
+PASS bodyChildOfMainBody.scrollHeight is bodyChildOfMainBody.clientHeight
+PASS document.body.scrollHeight is not bodyChildOfMainBody.scrollHeight
+
+Getting the scrollHeight should not require a renderer.
+PASS document.body.style.display = 'none' is 'none'
+PASS document.body.scrollHeight is document.documentElement.scrollHeight
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollHeightbasicsquirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks.html (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollHeight-basics-quirks.html        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            div {
+                height: 9999px;
+                width: 9999px;
+            }
+        &lt;/style&gt;
+        &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            jsTestIsAsync = true;
+
+            function runTest() {
+                description('Test the &quot;scrollHeight&quot; properties on the body element in quirks mode.');
+
+                debug(&quot;Initial values&quot;);
+                shouldBe(&quot;document.body.scrollHeight&quot;, &quot;document.documentElement.scrollHeight&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Now we create a body element, it should not have a scrollHeight since it is not the first body element of the document.&quot;);
+                floatingBody = document.createElement('body');
+                shouldBe(&quot;document.body.scrollHeight&quot;, &quot;document.documentElement.scrollHeight&quot;);
+                shouldBe(&quot;floatingBody.scrollHeight&quot;, &quot;0&quot;);
+
+                secondSiblingBody = document.createElement('body');
+                document.documentElement.appendChild(secondSiblingBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element after the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;document.body.scrollHeight&quot;, &quot;document.documentElement.scrollHeight&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollHeight&quot;, &quot;secondSiblingBody.clientHeight&quot;);
+                shouldNotBe(&quot;document.body.scrollHeight&quot;, &quot;secondSiblingBody.scrollHeight&quot;);
+
+                bodyChildOfMainBody = document.createElement('body');
+                document.body.appendChild(bodyChildOfMainBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element inside the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;document.body.scrollHeight&quot;, &quot;document.documentElement.scrollHeight&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollHeight&quot;, &quot;bodyChildOfMainBody.clientHeight&quot;);
+                shouldNotBe(&quot;document.body.scrollHeight&quot;, &quot;bodyChildOfMainBody.scrollHeight&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Getting the scrollHeight should not require a renderer.&quot;);
+                shouldBe(&quot;document.body.style.display = 'none'&quot;, &quot;'none'&quot;);
+                shouldBe(&quot;document.body.scrollHeight&quot;, &quot;document.documentElement.scrollHeight&quot;);
+
+                // Finally, let's clear the state to make this simpler for manual testing.
+                document.body.style.display = &quot;block&quot;;
+                window.scrollTo(0, 0);
+
+                finishJSTest();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=&quot;runTest()&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;
+        &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollLeftbasicsquirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks-expected.txt (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks-expected.txt        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,134 @@
</span><ins>+Test the &quot;scrollLeft&quot; properties on the body element in quirks mode.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initial values
+PASS document.body.scrollLeft is 0
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 0
+PASS window.scrollY is 0
+
+Let set the scrollLeft value on the main body element (document.body), in quirks mode, this should change the main frame's scroll position.
+PASS document.body.scrollLeft = 42 is 42
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 0
+
+Change scrollX, this should have no effect on the horizontal scrolling
+PASS window.scrollBy(0, 21) is undefined
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+Now we create a body element, completely detached from the DOM tree. This should not change the scroll position in any way.
+PASS floatingBody.scrollLeft is 0
+PASS floatingBody.scrollTop is 0
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+Setting the scroll position on that detached body element should not affect the main frame since it is not the first body element of the document.
+PASS floatingBody.scrollLeft = 654 is 654
+PASS floatingBody.scrollLeft is 0
+PASS floatingBody.scrollTop is 0
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+We add a new body element after the first body element, this should have no impact on the state.
+PASS secondSiblingBody.scrollLeft is 0
+PASS secondSiblingBody.scrollTop is 0
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+Setting a &quot;scrollTop&quot; on secondSiblingBody should not affect the main frame.
+PASS secondSiblingBody.scrollLeft = 987 is 987
+PASS secondSiblingBody.scrollLeft is 0
+PASS secondSiblingBody.scrollTop is 0
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+We add a new body element inside the first body element, this should have no impact on the state.
+PASS bodyChildOfMainBody.scrollLeft is 0
+PASS bodyChildOfMainBody.scrollTop is 0
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+Setting a &quot;scrollTop&quot; on bodyChildOfMainBody should not affect the main frame.
+PASS bodyChildOfMainBody.scrollLeft = 57 is 57
+PASS bodyChildOfMainBody.scrollLeft is 0
+PASS bodyChildOfMainBody.scrollTop is 0
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+Now we insert a new body element *before* the existing one. It will replace the existing element as the first body element of the document.
+PASS document.body === newMainBody is true
+PASS document.body !== oldBodyElement is true
+Since we are in quirks mode, the new body element gets the scroll position from the frame, and the old one lose its scroll position.
+PASS oldBodyElement.scrollLeft is 0
+PASS oldBodyElement.scrollTop is 0
+PASS document.body.scrollLeft is 42
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 42
+PASS window.scrollY is 21
+
+Scrolling that new body should work as expected.
+PASS document.body.scrollLeft = 68 is 68
+PASS oldBodyElement.scrollLeft = 894 is 894
+PASS oldBodyElement.scrollLeft is 0
+PASS oldBodyElement.scrollTop is 0
+PASS document.body.scrollLeft is 68
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 68
+PASS window.scrollY is 21
+
+Scrolling the main frame should not require a renderer.
+PASS document.body.style.display = 'none' is 'none'
+PASS document.body.scrollLeft = 54 is 54
+PASS oldBodyElement.scrollLeft is 0
+PASS oldBodyElement.scrollTop is 0
+PASS document.body.scrollLeft is 54
+PASS document.body.scrollTop is 21
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 54
+PASS window.scrollY is 21
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollLeftbasicsquirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks.html (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollLeft-basics-quirks.html        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,175 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            div {
+                height: 9999px;
+                width: 9999px;
+            }
+        &lt;/style&gt;
+        &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            jsTestIsAsync = true;
+
+            function runTest() {
+                description('Test the &quot;scrollLeft&quot; properties on the body element in quirks mode.');
+
+                debug(&quot;Initial values&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;0&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Let set the scrollLeft value on the main body element (document.body), in quirks mode, this should change the main frame's scroll position.&quot;);
+                shouldBe(&quot;document.body.scrollLeft = 42&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;0&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Change scrollX, this should have no effect on the horizontal scrolling&quot;);
+                shouldBe(&quot;window.scrollBy(0, 21)&quot;, &quot;undefined&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Now we create a body element, completely detached from the DOM tree. This should not change the scroll position in any way.&quot;);
+                floatingBody = document.createElement('body');
+                shouldBe(&quot;floatingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;floatingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting the scroll position on that detached body element should not affect the main frame since it is not the first body element of the document.&quot;);
+                shouldBe(&quot;floatingBody.scrollLeft = 654&quot;, &quot;654&quot;);
+                shouldBe(&quot;floatingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;floatingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                secondSiblingBody = document.createElement('body');
+                document.documentElement.appendChild(secondSiblingBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element after the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting a \&quot;scrollTop\&quot; on secondSiblingBody should not affect the main frame.&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollLeft = 987&quot;, &quot;987&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                bodyChildOfMainBody = document.createElement('body');
+                document.body.appendChild(bodyChildOfMainBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element inside the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting a \&quot;scrollTop\&quot; on bodyChildOfMainBody should not affect the main frame.&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollLeft = 57&quot;, &quot;57&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Now we insert a new body element *before* the existing one. It will replace the existing element as the first body element of the document.&quot;);
+                oldBodyElement = document.body;
+                newMainBody = document.createElement('body');
+                document.documentElement.insertBefore(newMainBody, oldBodyElement);
+                shouldBeTrue(&quot;document.body === newMainBody&quot;);
+                shouldBeTrue(&quot;document.body !== oldBodyElement&quot;);
+
+                debug(&quot;Since we are in quirks mode, the new body element gets the scroll position from the frame, and the old one lose its scroll position.&quot;);
+                shouldBe(&quot;oldBodyElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;oldBodyElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;42&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Scrolling that new body should work as expected.&quot;);
+                shouldBe(&quot;document.body.scrollLeft = 68&quot;, &quot;68&quot;);
+                shouldBe(&quot;oldBodyElement.scrollLeft = 894&quot;, &quot;894&quot;);
+
+                shouldBe(&quot;oldBodyElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;oldBodyElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;68&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;68&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Scrolling the main frame should not require a renderer.&quot;);
+                shouldBe(&quot;document.body.style.display = 'none'&quot;, &quot;'none'&quot;);
+                shouldBe(&quot;document.body.scrollLeft = 54&quot;, &quot;54&quot;);
+                shouldBe(&quot;oldBodyElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;oldBodyElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;54&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;54&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;21&quot;);
+
+                // Finally, let's clear the state to make this simpler for manual testing.
+                newMainBody.parentNode.removeChild(newMainBody);
+                window.scrollTo(0, 0);
+
+                finishJSTest();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=&quot;runTest()&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;
+        &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollTopbasicsquirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks-expected.txt (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks-expected.txt        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,134 @@
</span><ins>+Test the &quot;scrollTop&quot; properties on the body element in quirks mode.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initial values
+PASS document.body.scrollLeft is 0
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 0
+PASS window.scrollY is 0
+
+Let set the scrollTop value on the main body element (document.body), in quirks mode, this should change the main frame's scroll position.
+PASS document.body.scrollTop = 42 is 42
+PASS document.body.scrollLeft is 0
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 0
+PASS window.scrollY is 42
+
+Change scrollX, this should have no effect on the vertical scrolling
+PASS window.scrollBy(21, 0) is undefined
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+Now we create a body element, completely detached from the DOM tree. This should not change the scroll position in any way.
+PASS floatingBody.scrollLeft is 0
+PASS floatingBody.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+Setting the scroll position on that detached body element should not affect the main frame since it is not the first body element of the document.
+PASS floatingBody.scrollTop = 500 is 500
+PASS floatingBody.scrollLeft is 0
+PASS floatingBody.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+We add a new body element after the first body element, this should have no impact on the state.
+PASS secondSiblingBody.scrollLeft is 0
+PASS secondSiblingBody.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+Setting a &quot;scrollTop&quot; on secondSiblingBody should not affect the main frame.
+PASS secondSiblingBody.scrollTop = 321 is 321
+PASS secondSiblingBody.scrollLeft is 0
+PASS secondSiblingBody.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+We add a new body element inside the first body element, this should have no impact on the state.
+PASS bodyChildOfMainBody.scrollLeft is 0
+PASS bodyChildOfMainBody.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+Setting a &quot;scrollTop&quot; on bodyChildOfMainBody should not affect the main frame.
+PASS bodyChildOfMainBody.scrollTop = 57 is 57
+PASS bodyChildOfMainBody.scrollLeft is 0
+PASS bodyChildOfMainBody.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+Now we insert a new body element *before* the existing one. It will replace the existing element as the first body element of the document.
+PASS document.body === newMainBody is true
+PASS document.body !== oldBodyElement is true
+Since we are in quirks mode, the new body element gets the scroll position from the frame, and the old one lose its scroll position.
+PASS oldBodyElement.scrollLeft is 0
+PASS oldBodyElement.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 42
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 42
+
+Scrolling that new body should work as expected.
+PASS document.body.scrollTop = 68 is 68
+PASS oldBodyElement.scrollTop = 894 is 894
+PASS oldBodyElement.scrollLeft is 0
+PASS oldBodyElement.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 68
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 68
+
+Scrolling the main frame should not require a renderer.
+PASS document.body.style.display = 'none' is 'none'
+PASS document.body.scrollTop = 54 is 54
+PASS oldBodyElement.scrollLeft is 0
+PASS oldBodyElement.scrollTop is 0
+PASS document.body.scrollLeft is 21
+PASS document.body.scrollTop is 54
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 21
+PASS window.scrollY is 54
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollTopbasicsquirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks.html (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollTop-basics-quirks.html        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,175 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            div {
+                height: 9999px;
+                width: 9999px;
+            }
+        &lt;/style&gt;
+        &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            jsTestIsAsync = true;
+
+            function runTest() {
+                description('Test the &quot;scrollTop&quot; properties on the body element in quirks mode.');
+
+                debug(&quot;Initial values&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;0&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Let set the scrollTop value on the main body element (document.body), in quirks mode, this should change the main frame's scroll position.&quot;);
+                shouldBe(&quot;document.body.scrollTop = 42&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Change scrollX, this should have no effect on the vertical scrolling&quot;);
+                shouldBe(&quot;window.scrollBy(21, 0)&quot;, &quot;undefined&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Now we create a body element, completely detached from the DOM tree. This should not change the scroll position in any way.&quot;);
+                floatingBody = document.createElement('body');
+                shouldBe(&quot;floatingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;floatingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting the scroll position on that detached body element should not affect the main frame since it is not the first body element of the document.&quot;);
+                shouldBe(&quot;floatingBody.scrollTop = 500&quot;, &quot;500&quot;);
+                shouldBe(&quot;floatingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;floatingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                secondSiblingBody = document.createElement('body');
+                document.documentElement.appendChild(secondSiblingBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element after the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting a \&quot;scrollTop\&quot; on secondSiblingBody should not affect the main frame.&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollTop = 321&quot;, &quot;321&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                bodyChildOfMainBody = document.createElement('body');
+                document.body.appendChild(bodyChildOfMainBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element inside the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting a \&quot;scrollTop\&quot; on bodyChildOfMainBody should not affect the main frame.&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollTop = 57&quot;, &quot;57&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Now we insert a new body element *before* the existing one. It will replace the existing element as the first body element of the document.&quot;);
+                oldBodyElement = document.body;
+                newMainBody = document.createElement('body');
+                document.documentElement.insertBefore(newMainBody, oldBodyElement);
+                shouldBeTrue(&quot;document.body === newMainBody&quot;);
+                shouldBeTrue(&quot;document.body !== oldBodyElement&quot;);
+
+                debug(&quot;Since we are in quirks mode, the new body element gets the scroll position from the frame, and the old one lose its scroll position.&quot;);
+                shouldBe(&quot;oldBodyElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;oldBodyElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;42&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;42&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Scrolling that new body should work as expected.&quot;);
+                shouldBe(&quot;document.body.scrollTop = 68&quot;, &quot;68&quot;);
+                shouldBe(&quot;oldBodyElement.scrollTop = 894&quot;, &quot;894&quot;);
+
+                shouldBe(&quot;oldBodyElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;oldBodyElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;68&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;68&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Scrolling the main frame should not require a renderer.&quot;);
+                shouldBe(&quot;document.body.style.display = 'none'&quot;, &quot;'none'&quot;);
+                shouldBe(&quot;document.body.scrollTop = 54&quot;, &quot;54&quot;);
+                shouldBe(&quot;oldBodyElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;oldBodyElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;21&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;54&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;21&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;54&quot;);
+
+                // Finally, let's clear the state to make this simpler for manual testing.
+                newMainBody.parentNode.removeChild(newMainBody);
+                window.scrollTo(0, 0);
+
+                finishJSTest();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=&quot;runTest()&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;
+        &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollWidthbasicsquirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks-expected.txt (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks-expected.txt        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+Test the &quot;scrollWidth&quot; properties on the body element in quirks mode.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Initial values
+PASS document.body.scrollWidth is document.documentElement.scrollWidth
+
+Now we create a body element, it should not have a scrollWidth since it is not the first body element of the document.
+PASS document.body.scrollWidth is document.documentElement.scrollWidth
+PASS floatingBody.scrollWidth is 0
+
+We add a new body element after the first body element, this should have no impact on the state.
+PASS document.body.scrollWidth is document.documentElement.scrollWidth
+PASS secondSiblingBody.scrollWidth is secondSiblingBody.clientWidth
+PASS document.body.scrollWidth is not secondSiblingBody.scrollWidth
+
+We add a new body element inside the first body element, this should have no impact on the state.
+PASS document.body.scrollWidth is document.documentElement.scrollWidth
+PASS bodyChildOfMainBody.scrollWidth is bodyChildOfMainBody.clientWidth
+PASS document.body.scrollWidth is not bodyChildOfMainBody.scrollWidth
+
+Getting the scrollWidth should not require a renderer.
+PASS document.body.style.display = 'none' is 'none'
+PASS document.body.scrollWidth is document.documentElement.scrollWidth
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementbodyscrollWidthbasicsquirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks.html (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/body-scrollWidth-basics-quirks.html        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            div {
+                height: 9999px;
+                width: 9999px;
+            }
+        &lt;/style&gt;
+        &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            jsTestIsAsync = true;
+
+            function runTest() {
+                description('Test the &quot;scrollWidth&quot; properties on the body element in quirks mode.');
+
+                debug(&quot;Initial values&quot;);
+                shouldBe(&quot;document.body.scrollWidth&quot;, &quot;document.documentElement.scrollWidth&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Now we create a body element, it should not have a scrollWidth since it is not the first body element of the document.&quot;);
+                floatingBody = document.createElement('body');
+                shouldBe(&quot;document.body.scrollWidth&quot;, &quot;document.documentElement.scrollWidth&quot;);
+                shouldBe(&quot;floatingBody.scrollWidth&quot;, &quot;0&quot;);
+
+                secondSiblingBody = document.createElement('body');
+                document.documentElement.appendChild(secondSiblingBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element after the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;document.body.scrollWidth&quot;, &quot;document.documentElement.scrollWidth&quot;);
+                shouldBe(&quot;secondSiblingBody.scrollWidth&quot;, &quot;secondSiblingBody.clientWidth&quot;);
+                shouldNotBe(&quot;document.body.scrollWidth&quot;, &quot;secondSiblingBody.scrollWidth&quot;);
+
+                bodyChildOfMainBody = document.createElement('body');
+                document.body.appendChild(bodyChildOfMainBody);
+                debug(&quot;&quot;);
+                debug(&quot;We add a new body element inside the first body element, this should have no impact on the state.&quot;);
+                shouldBe(&quot;document.body.scrollWidth&quot;, &quot;document.documentElement.scrollWidth&quot;);
+                shouldBe(&quot;bodyChildOfMainBody.scrollWidth&quot;, &quot;bodyChildOfMainBody.clientWidth&quot;);
+                shouldNotBe(&quot;document.body.scrollWidth&quot;, &quot;bodyChildOfMainBody.scrollWidth&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Getting the scrollWidth should not require a renderer.&quot;);
+                shouldBe(&quot;document.body.style.display = 'none'&quot;, &quot;'none'&quot;);
+                shouldBe(&quot;document.body.scrollWidth&quot;, &quot;document.documentElement.scrollWidth&quot;);
+
+                // Finally, let's clear the state to make this simpler for manual testing.
+                document.body.style.display = &quot;block&quot;;
+                window.scrollTo(0, 0);
+
+                finishJSTest();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=&quot;runTest()&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;
+        &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollLeftexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft-expected.txt (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft-expected.txt        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+Tests that, for Quirks mode, changing the scrollTop property of a fake body element does not scroll the viewport
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+Initial state.
+PASS detachedBody.scrollTop is 0
+PASS detachedBody.scrollLeft is 0
+PASS document.body.scrollTop = 0 is 0
+PASS document.body.scrollLeft is 0
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 0
+PASS window.scrollY is 0
+
+Setting scrollTop on the detached body element should not change the main frame's scroll position.
+PASS detachedBody.scrollLeft = 542 is 542
+PASS detachedBody.scrollTop is 0
+PASS detachedBody.scrollLeft is 0
+PASS document.body.scrollTop = 0 is 0
+PASS document.body.scrollLeft is 0
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 0
+PASS window.scrollY is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollLefthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            div {
+                height: 9999px;
+                width: 9999px;
+            }
+        &lt;/style&gt;
+        &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            jsTestIsAsync = true;
+
+            function runTest() {
+                description('Tests that, for Quirks mode, changing the scrollTop property of a fake body element does not scroll the viewport');
+
+                detachedBody = document.createElement('body');
+
+                debug(&quot;&quot;);
+                debug(&quot;Initial state.&quot;);
+                shouldBe(&quot;detachedBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;detachedBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop = 0&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;0&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting scrollTop on the detached body element should not change the main frame's scroll position.&quot;);
+                shouldBe(&quot;detachedBody.scrollLeft = 542&quot;, &quot;542&quot;);
+                shouldBe(&quot;detachedBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;detachedBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop = 0&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;0&quot;);
+
+                finishJSTest();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=&quot;runTest()&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;
+        &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollTopexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop-expected.txt (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop-expected.txt        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+Tests that, for Quirks mode, changing the scrollTop property of a fake body element does not scroll the viewport
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+Initial state.
+PASS detachedBody.scrollTop is 0
+PASS detachedBody.scrollLeft is 0
+PASS document.body.scrollTop = 0 is 0
+PASS document.body.scrollLeft is 0
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 0
+PASS window.scrollY is 0
+
+Setting scrollTop on the detached body element should not change the main frame's scroll position.
+PASS detachedBody.scrollTop = 500 is 500
+PASS document.body.scrollLeft is 0
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollLeft is 0
+PASS document.documentElement.scrollTop is 0
+PASS window.scrollX is 0
+PASS window.scrollY is 0
+PASS detachedBody.scrollTop is 0
+PASS detachedBody.scrollLeft is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomElementdetachedbodyelementdoesnotscrollmainframewithscrollTophtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html (0 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            div {
+                height: 9999px;
+                width: 9999px;
+            }
+        &lt;/style&gt;
+        &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            jsTestIsAsync = true;
+
+            function runTest() {
+                description('Tests that, for Quirks mode, changing the scrollTop property of a fake body element does not scroll the viewport');
+
+                detachedBody = document.createElement('body');
+
+                debug(&quot;&quot;);
+                debug(&quot;Initial state.&quot;);
+                shouldBe(&quot;detachedBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;detachedBody.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop = 0&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;0&quot;);
+
+                debug(&quot;&quot;);
+                debug(&quot;Setting scrollTop on the detached body element should not change the main frame's scroll position.&quot;);
+                shouldBe(&quot;detachedBody.scrollTop = 500&quot;, &quot;500&quot;);
+                shouldBe(&quot;document.body.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.body.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollLeft&quot;, &quot;0&quot;);
+                shouldBe(&quot;document.documentElement.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollX&quot;, &quot;0&quot;);
+                shouldBe(&quot;window.scrollY&quot;, &quot;0&quot;);
+                shouldBe(&quot;detachedBody.scrollTop&quot;, &quot;0&quot;);
+                shouldBe(&quot;detachedBody.scrollLeft&quot;, &quot;0&quot;);
+
+                finishJSTest();
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=&quot;runTest()&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;
+        &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182676 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-13 01:29:59 UTC (rev 182676)
+++ trunk/Source/WebCore/ChangeLog        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-04-12  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Legacy scroll behavior on HTMLBodyElement should only apply to the first body element of a document
+        https://bugs.webkit.org/show_bug.cgi?id=143651
+
+        Reviewed by Sam Weinig.
+
+        WebKit has some very weird behaviors for the scroll methods on body. This patch
+        address the first bug: only the first body element should have the legacy behavior.
+
+        The relevant text in spec:
+        -http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft
+        -http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop
+        -http://dev.w3.org/csswg/cssom-view/#dom-element-scrollwidth
+        -http://dev.w3.org/csswg/cssom-view/#dom-element-scrollheight
+
+        Tests: fast/dom/Element/body-scrollHeight-basics-quirks.html
+               fast/dom/Element/body-scrollLeft-basics-quirks.html
+               fast/dom/Element/body-scrollTop-basics-quirks.html
+               fast/dom/Element/body-scrollWidth-basics-quirks.html
+               fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollLeft.html
+               fast/dom/Element/detached-body-element-does-not-scroll-main-frame-with-scrollTop.html
+
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::isFirstBodyElementOfDocument):
+        (WebCore::HTMLBodyElement::scrollLeft):
+        (WebCore::HTMLBodyElement::setScrollLeft):
+        (WebCore::HTMLBodyElement::scrollTop):
+        (WebCore::HTMLBodyElement::setScrollTop):
+        (WebCore::HTMLBodyElement::scrollHeight):
+        (WebCore::HTMLBodyElement::scrollWidth):
+        * html/HTMLBodyElement.h:
+
</ins><span class="cx"> 2015-04-12  Sungmann Cho  &lt;sungmann.cho@navercorp.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix trival typos related to the word &quot;coordinate&quot;.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLBodyElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (182676 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLBodyElement.cpp        2015-04-13 01:29:59 UTC (rev 182676)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx">  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><span class="cx">  *           (C) 2000 Simon Hausmann (hausmann@kde.org)
</span><span class="cx">  *           (C) 2001 Dirk Mueller (mueller@kde.org)
</span><del>- * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004, 2006-2010, 2015 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -47,6 +47,13 @@
</span><span class="cx">     ASSERT(hasTagName(bodyTag));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool HTMLBodyElement::isFirstBodyElementOfDocument() const
+{
+    // By spec http://dev.w3.org/csswg/cssom-view/#the-html-body-element
+    // &quot;The HTML body element is the first body HTML element child of the root HTML element html.&quot;
+    return document().body() == this;
+}
+
</ins><span class="cx"> Ref&lt;HTMLBodyElement&gt; HTMLBodyElement::create(Document&amp; document)
</span><span class="cx"> {
</span><span class="cx">     return adoptRef(*new HTMLBodyElement(bodyTag, document));
</span><span class="lines">@@ -225,76 +232,94 @@
</span><span class="cx"> 
</span><span class="cx"> int HTMLBodyElement::scrollLeft()
</span><span class="cx"> {
</span><del>-    document().updateLayoutIgnorePendingStylesheets();
-    Frame* frame = document().frame();
-    if (!frame)
-        return 0;
-    FrameView* view = frame-&gt;view();
-    if (!view)
-        return 0;
-    return adjustForZoom(view-&gt;contentsScrollPosition().x(), *frame);
</del><ins>+    if (isFirstBodyElementOfDocument()) {
+        document().updateLayoutIgnorePendingStylesheets();
+        Frame* frame = document().frame();
+        if (!frame)
+            return 0;
+        FrameView* view = frame-&gt;view();
+        if (!view)
+            return 0;
+        return adjustForZoom(view-&gt;contentsScrollPosition().x(), *frame);
+    }
+    return HTMLElement::scrollLeft();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLBodyElement::setScrollLeft(int scrollLeft)
</span><span class="cx"> {
</span><del>-    document().updateLayoutIgnorePendingStylesheets();
-    Frame* frame = document().frame();
-    if (!frame)
-        return;
-    FrameView* view = frame-&gt;view();
-    if (!view)
-        return;
-    view-&gt;setScrollPosition(IntPoint(static_cast&lt;int&gt;(scrollLeft * frame-&gt;pageZoomFactor() * frame-&gt;frameScaleFactor()), view-&gt;scrollY()));
</del><ins>+    if (isFirstBodyElementOfDocument()) {
+        document().updateLayoutIgnorePendingStylesheets();
+        Frame* frame = document().frame();
+        if (!frame)
+            return;
+        FrameView* view = frame-&gt;view();
+        if (!view)
+            return;
+        view-&gt;setScrollPosition(IntPoint(static_cast&lt;int&gt;(scrollLeft * frame-&gt;pageZoomFactor() * frame-&gt;frameScaleFactor()), view-&gt;scrollY()));
+    }
+    HTMLElement::setScrollLeft(scrollLeft);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int HTMLBodyElement::scrollTop()
</span><span class="cx"> {
</span><del>-    document().updateLayoutIgnorePendingStylesheets();
-    Frame* frame = document().frame();
-    if (!frame)
-        return 0;
-    FrameView* view = frame-&gt;view();
-    if (!view)
-        return 0;
-    return adjustForZoom(view-&gt;contentsScrollPosition().y(), *frame);
</del><ins>+    if (isFirstBodyElementOfDocument()) {
+        document().updateLayoutIgnorePendingStylesheets();
+        Frame* frame = document().frame();
+        if (!frame)
+            return 0;
+        FrameView* view = frame-&gt;view();
+        if (!view)
+            return 0;
+        return adjustForZoom(view-&gt;contentsScrollPosition().y(), *frame);
+    }
+    return HTMLElement::scrollTop();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLBodyElement::setScrollTop(int scrollTop)
</span><span class="cx"> {
</span><del>-    document().updateLayoutIgnorePendingStylesheets();
-    Frame* frame = document().frame();
-    if (!frame)
-        return;
-    FrameView* view = frame-&gt;view();
-    if (!view)
-        return;
-    view-&gt;setScrollPosition(IntPoint(view-&gt;scrollX(), static_cast&lt;int&gt;(scrollTop * frame-&gt;pageZoomFactor() * frame-&gt;frameScaleFactor())));
</del><ins>+    if (isFirstBodyElementOfDocument()) {
+        document().updateLayoutIgnorePendingStylesheets();
+        Frame* frame = document().frame();
+        if (!frame)
+            return;
+        FrameView* view = frame-&gt;view();
+        if (!view)
+            return;
+        view-&gt;setScrollPosition(IntPoint(view-&gt;scrollX(), static_cast&lt;int&gt;(scrollTop * frame-&gt;pageZoomFactor() * frame-&gt;frameScaleFactor())));
+    }
+    return HTMLElement::setScrollTop(scrollTop);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int HTMLBodyElement::scrollHeight()
</span><span class="cx"> {
</span><del>-    // Update the document's layout.
-    document().updateLayoutIgnorePendingStylesheets();
-    Frame* frame = document().frame();
-    if (!frame)
-        return 0;
-    FrameView* view = frame-&gt;view();
-    if (!view)
-        return 0;
-    return adjustForZoom(view-&gt;contentsHeight(), *frame);
</del><ins>+    if (isFirstBodyElementOfDocument()) {
+        // Update the document's layout.
+        document().updateLayoutIgnorePendingStylesheets();
+        Frame* frame = document().frame();
+        if (!frame)
+            return 0;
+        FrameView* view = frame-&gt;view();
+        if (!view)
+            return 0;
+        return adjustForZoom(view-&gt;contentsHeight(), *frame);
+    }
+    return HTMLElement::scrollHeight();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int HTMLBodyElement::scrollWidth()
</span><span class="cx"> {
</span><del>-    // Update the document's layout.
-    document().updateLayoutIgnorePendingStylesheets();
-    Frame* frame = document().frame();
-    if (!frame)
-        return 0;
-    FrameView* view = frame-&gt;view();
-    if (!view)
-        return 0;
-    return adjustForZoom(view-&gt;contentsWidth(), *frame);
</del><ins>+    if (isFirstBodyElementOfDocument()) {
+        // Update the document's layout.
+        document().updateLayoutIgnorePendingStylesheets();
+        Frame* frame = document().frame();
+        if (!frame)
+            return 0;
+        FrameView* view = frame-&gt;view();
+        if (!view)
+            return 0;
+        return adjustForZoom(view-&gt;contentsWidth(), *frame);
+    }
+    return HTMLElement::scrollWidth();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet&lt;URL&gt;&amp; urls) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLBodyElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLBodyElement.h (182676 => 182677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLBodyElement.h        2015-04-13 01:29:59 UTC (rev 182676)
+++ trunk/Source/WebCore/html/HTMLBodyElement.h        2015-04-13 04:42:53 UTC (rev 182677)
</span><span class="lines">@@ -39,6 +39,8 @@
</span><span class="cx"> private:
</span><span class="cx">     HTMLBodyElement(const QualifiedName&amp;, Document&amp;);
</span><span class="cx"> 
</span><ins>+    bool isFirstBodyElementOfDocument() const;
+
</ins><span class="cx">     virtual void parseAttribute(const QualifiedName&amp;, const AtomicString&amp;) override;
</span><span class="cx">     virtual bool isPresentationAttribute(const QualifiedName&amp;) const override;
</span><span class="cx">     virtual void collectStyleForPresentationAttribute(const QualifiedName&amp;, const AtomicString&amp;, MutableStyleProperties&amp;) override;
</span></span></pre>
</div>
</div>

</body>
</html>