Bug 1490228 [wpt PR 12944] - Use document.scrollingElement to access scroll properties of the view…, a=testonly
authorFrédéric Wang <fwang@igalia.com>
Mon, 04 Nov 2019 11:11:23 +0000
changeset 564746 b2cef7ebf770ed8e108b7f471737e16b095e2a0b
parent 564745 3ee76345e9a807f60c43c056b7098e9effa0a486
child 564747 180f1175a6fe47a5f7001eb2e0a4b853d7088e66
push id12351
push userffxbld-merge
push dateMon, 02 Dec 2019 11:32:26 +0000
treeherdermozilla-beta@dba4410526a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1490228, 12944
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1490228 [wpt PR 12944] - Use document.scrollingElement to access scroll properties of the view…, a=testonly Automatic update from web-platform-tests Use document.scrollingElement to access scroll properties of the view… (#12944) Use document.scrollingElement to access scroll properties of the viewport See https://drafts.csswg.org/cssom-view/#dom-document-scrollingelement Found with the following command: find . -type f | xargs egrep 'document.body.scroll|document.documentElement.scroll' -- wpt-commits: 251ec7054bfe6c5665b9464238dd4baffa89dbce wpt-pr: 12944 Differential Revision: https://phabricator.services.mozilla.com/D53536
testing/web-platform/tests/conformance-checkers/html-aria/_functional/tree/js/prototype.js
testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vlr-004-ref.xht
testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vlr-004.xht
testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vrl-001-ref.xht
testing/web-platform/tests/css/css-writing-modes/wm-propagation-body-scroll-offset-vertical-lr.html
testing/web-platform/tests/css/css-writing-modes/wm-propagation-body-scroll-offset-vertical-rl.html
testing/web-platform/tests/element-timing/scroll-to-text.html
testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html
testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html
--- a/testing/web-platform/tests/conformance-checkers/html-aria/_functional/tree/js/prototype.js
+++ b/testing/web-platform/tests/conformance-checkers/html-aria/_functional/tree/js/prototype.js
@@ -2700,18 +2700,18 @@ document.viewport = {
   },
 
   getHeight: function() {
     return this.getDimensions().height;
   },
 
   getScrollOffsets: function() {
     return Element._returnOffset(
-      window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
-      window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
+      window.pageXOffset || document.scrollingElement.scrollLeft,
+      window.pageYOffset || document.scrollingElement.scrollTop);
   }
 };
 /* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
  * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
  * license.  Please see http://www.yui-ext.com/ for more information. */
 
 var Selector = Class.create({
   initialize: function(expression) {
@@ -3746,20 +3746,18 @@ Event.Methods = (function() {
 
     findElement: function(event, expression) {
       var element = Event.element(event);
       return element.match(expression) ? element : element.up(expression);
     },
 
     pointer: function(event) {
       return {
-        x: event.pageX || (event.clientX +
-          (document.documentElement.scrollLeft || document.body.scrollLeft)),
-        y: event.pageY || (event.clientY +
-          (document.documentElement.scrollTop || document.body.scrollTop))
+        x: event.pageX || (event.clientX + document.scrollingElement.scrollLeft),
+        y: event.pageY || (event.clientY + document.scrollingElement.scrollTop)
       };
     },
 
     pointerX: function(event) { return Event.pointer(event).x },
     pointerY: function(event) { return Event.pointer(event).y },
 
     stop: function(event) {
       Event.extend(event);
@@ -4029,22 +4027,20 @@ var Position = {
   // NOT neeeded for page scrolling, only if draggable contained in
   // scrollable elements
   includeScrollOffsets: false,
 
   // must be called before calling withinIncludingScrolloffset, every time the
   // page is scrolled
   prepare: function() {
     this.deltaX =  window.pageXOffset
-                || document.documentElement.scrollLeft
-                || document.body.scrollLeft
+                || document.scrollingElement.scrollLeft
                 || 0;
     this.deltaY =  window.pageYOffset
-                || document.documentElement.scrollTop
-                || document.body.scrollTop
+                || document.scrollingElement.scrollTop
                 || 0;
   },
 
   // caches x/y coordinate pair to use with overlap
   within: function(element, x, y) {
     if (this.includeScrollOffsets)
       return this.withinIncludingScrolloffsets(element, x, y);
     this.xcomp = x;
--- a/testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vlr-004-ref.xht
+++ b/testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vlr-004-ref.xht
@@ -36,12 +36,12 @@
   ]]></style>
  </head>
 
  <body>
 
   <div>01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
 
 <script>
-  document.documentElement.scrollLeft=document.documentElement.scrollWidth;
+  document.scrollingElement.scrollLeft=document.scrollingElement.scrollWidth;
 </script>
  </body>
 </html>
--- a/testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vlr-004.xht
+++ b/testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vlr-004.xht
@@ -96,12 +96,12 @@
 
   <div id="auto-sized-vlr-containing-block">
 
     <div id="ortho-block-htb">01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00</div>
 
   </div>
 
 <script>
-  document.documentElement.scrollLeft=document.documentElement.scrollWidth;
+  document.scrollingElement.scrollLeft=document.scrollingElement.scrollWidth;
 </script>
  </body>
 </html>
--- a/testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vrl-001-ref.xht
+++ b/testing/web-platform/tests/css/css-writing-modes/sizing-orthog-htb-in-vrl-001-ref.xht
@@ -70,12 +70,12 @@
 
       <td id="before"><p id="sentence-before">Sentence&nbsp;before.</p></td>
 
     </tr>
 
   </table>
 
 <script>
-  document.documentElement.scrollLeft=document.documentElement.scrollWidth;
+  document.scrollingElement.scrollLeft=document.scrollingElement.scrollWidth;
 </script>
  </body>
 </html>
--- a/testing/web-platform/tests/css/css-writing-modes/wm-propagation-body-scroll-offset-vertical-lr.html
+++ b/testing/web-platform/tests/css/css-writing-modes/wm-propagation-body-scroll-offset-vertical-lr.html
@@ -13,24 +13,24 @@
   .result-wm, .result-wm > body {
     writing-mode: horizontal-tb;
     width: auto;
   }
 </style>
 <body>
 <script>
   test(function() {
-    assert_equals(document.documentElement.scrollLeft, 0, "scrollLeft should be 0.");
+    assert_equals(document.scrollingElement.scrollLeft, 0, "scrollLeft should be 0.");
   }, "Check initial scroll position of viewport.");
 
   test(function() {
-    document.documentElement.scrollLeft = -1000;
-    assert_equals(document.documentElement.scrollLeft, 0, "scrollLeft should be 0.");
+    document.scrollingElement.scrollLeft = -1000;
+    assert_equals(document.scrollingElement.scrollLeft, 0, "scrollLeft should be 0.");
   }, "Scroll to scrollLeft = -1000 should not be possible.");
 
   test(function() {
-    document.documentElement.scrollLeft = 1000;
-    assert_equals(document.documentElement.scrollLeft, 1000, "scrollLeft should be 1000.");
+    document.scrollingElement.scrollLeft = 1000;
+    assert_equals(document.scrollingElement.scrollLeft, 1000, "scrollLeft should be 1000.");
   }, "Scroll to scrollLeft = 1000 should be possible.");
 
   // Reset back to horizontal-tb to make the result readable on-screen.
-  document.documentElement.className = "result-wm";
+  document.scrollingElement.className = "result-wm";
 </script>
--- a/testing/web-platform/tests/css/css-writing-modes/wm-propagation-body-scroll-offset-vertical-rl.html
+++ b/testing/web-platform/tests/css/css-writing-modes/wm-propagation-body-scroll-offset-vertical-rl.html
@@ -13,24 +13,24 @@
   .result-wm, .result-wm > body {
     writing-mode: horizontal-tb;
     width: auto;
   }
 </style>
 <body>
 <script>
   test(function() {
-    assert_equals(document.documentElement.scrollLeft, 0, "scrollLeft should be 0.");
+    assert_equals(document.scrollingElement.scrollLeft, 0, "scrollLeft should be 0.");
   }, "Check initial scroll position of viewport.");
 
   test(function() {
-    document.documentElement.scrollLeft = -1000;
-    assert_equals(document.documentElement.scrollLeft, -1000, "scrollLeft should be -1000.");
+    document.scrollingElement.scrollLeft = -1000;
+    assert_equals(document.scrollingElement.scrollLeft, -1000, "scrollLeft should be -1000.");
   }, "Scroll to scrollLeft = -1000 should be possible.");
 
   test(function() {
-    document.documentElement.scrollLeft = 1000;
-    assert_equals(document.documentElement.scrollLeft, 0, "scrollLeft should be 0.");
+    document.scrollingElement.scrollLeft = 1000;
+    assert_equals(document.scrollingElement.scrollLeft, 0, "scrollLeft should be 0.");
   }, "Scroll to scrollLeft = 1000 should not be possible.");
 
   // Reset back to horizontal-tb to make the result readable on-screen.
-  document.documentElement.className = "result-wm";
+  document.scrollingElement.className = "result-wm";
 </script>
--- a/testing/web-platform/tests/element-timing/scroll-to-text.html
+++ b/testing/web-platform/tests/element-timing/scroll-to-text.html
@@ -20,13 +20,13 @@
     }
     const observer = new PerformanceObserver(t.step_func_done(() => {}));
     observer.observe({type: 'element', buffered: true});
     window.onload = () => {
       // The div occupies the whole screen because it occupies 100% of the height.
       // We scroll to the end of the document so that the paragraph becomes visible.
       // A user agent could paint the text before or after scrolling, but either way
       // it must produce an entry for it.
-      window.scrollTo(0,document.body.scrollHeight);
+      window.scrollTo(0,document.scrollingElement.scrollHeight);
     };
   }, 'Paragraph with elementtiming attribute is observed even when not initially visible.');
 </script>
 </body>
--- a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html
@@ -10,41 +10,37 @@
 <div id="%20has%20two%20spaces" style="position:absolute; top:300px;"></div>
 <div id="escape collision" style="position:absolute; top:400px;"></div>
 <div id="do%20not%20go%20here" style="position:absolute; top:400px;"></div>
 <div style="height:200em;"></div>
 <script>
 var steps = [{
     fragid:'has%20two%20spaces',
       handler: function(){
-        assert_equals( scrollPosition(), 100 );
+        assert_equals( document.scrollingElement.scrollTop, 100 );
       }
     },{
       fragid:'escape%20collision',
       handler: function(){
-        assert_equals( scrollPosition(), 200 );
+        assert_equals( document.scrollingElement.scrollTop, 200 );
         document.getElementById("%20has%20two%20spaces").setAttribute("id", "has%20two%20spaces");
       }
     },{
       fragid:'has%20two%20spaces',
       handler: function(){
-        assert_equals( scrollPosition(), 300 );
+        assert_equals( document.scrollingElement.scrollTop, 300 );
       }
     },{
       fragid:'do%20not%20go%20here',
       handler: function(){
         // don't move
-        assert_equals( scrollPosition(), 400 );
+        assert_equals( document.scrollingElement.scrollTop, 400 );
       }
     }];
 
-function scrollPosition(){
-  return document.documentElement.scrollTop || document.body.scrollTop;
-}
-
 function runNextStep(){
     if( steps.length > 0 ) {
       var step = steps.shift();
       var listener = t.step_func( function(){
         step.handler();
         runNextStep();
       });
       scrollToFragmentThenDo( step.fragid, listener );
--- a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html
@@ -6,39 +6,35 @@
 <body>
 <div></div>
 <div id="not-the-top"></div>
 <div style="height:200em"></div>
 <script>
 var steps = [{
     fragid:'not-the-top',
     handler: function(){
-      assert_not_equals( scrollPosition(), 0 );
+      assert_not_equals( document.scrollingElement.scrollTop, 0 );
     }
   },{
     fragid:'top',
     handler: function(){
-      assert_equals( scrollPosition(), 0 );
+      assert_equals( document.scrollingElement.scrollTop, 0 );
     }
   },{
     fragid:'not-the-top',
     handler: function(){
-      assert_not_equals( scrollPosition(), 0 );
+      assert_not_equals( document.scrollingElement.scrollTop, 0 );
     }
   },{
     fragid:'TOP',
     handler: function(){
-      assert_equals( scrollPosition(), 0 );
+      assert_equals( document.scrollingElement.scrollTop, 0 );
     }
   }];
 
-function scrollPosition(){
-  return document.documentElement.scrollTop || document.body.scrollTop;
-}
-
 function runNextStep(){
     if( steps.length > 0 ) {
       var step = steps.shift();
       var listener = t.step_func( function(){
         step.handler();
         runNextStep();
       });
       scrollToFragmentThenDo( step.fragid, listener );