Bug 1517895 - Use scrollToVisual() in the session store tests. r=JanH
authorBotond Ballo <botond@mozilla.com>
Wed, 13 Mar 2019 16:00:07 +0000
changeset 521794 02e879149e47
parent 521793 ee808a9cfb1b
child 521795 f41b081164d2
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJanH
bugs1517895
milestone67.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 1517895 - Use scrollToVisual() in the session store tests. r=JanH Differential Revision: https://phabricator.services.mozilla.com/D19874
mobile/android/tests/browser/chrome/head_scroll.js
--- a/mobile/android/tests/browser/chrome/head_scroll.js
+++ b/mobile/android/tests/browser/chrome/head_scroll.js
@@ -11,22 +11,31 @@ function getFrame(browser, { frame = nul
     window = browser.contentWindow.frames[frame];
   } else {
     window = browser.contentWindow;
   }
   return window;
 }
 
 function setScrollPosition(browser,
-                           { x = 0, y = 0, zoom = 0, frame }) {
+                           { x = 0, y = 0, zoom = 0, frame = null }) {
   let window = getFrame(browser, {frame});
+  let topLevelUtils = browser.contentWindow.windowUtils;
   if (zoom) {
-    browser.contentWindow.windowUtils.setResolutionAndScaleTo(zoom);
+    topLevelUtils.setResolutionAndScaleTo(zoom);
   }
-  window.scrollTo(x, y);
+  // The root content document has a distinction between visual and layout
+  // scroll positions. We want to set the visual one.
+  // For frames, there is no such distinction and scrollToVisual() does
+  // not support them, so use window.scrollTo().
+  if (frame !== null) {
+    window.scrollTo(x, y);
+  } else {
+    topLevelUtils.scrollToVisual(x, y, topLevelUtils.UPDATE_TYPE_MAIN_THREAD);
+  }
 }
 
 function checkScroll(browser, data) {
   let {x, y, zoom} = data;
   let scrollPos = getScrollPosition(browser, data);
 
   if (data.hasOwnProperty("x")) {
     is(scrollPos.x, x, "scrollX set correctly");