bug 1385706: marionette: fix WebDriver:TakeScreenshot to use viewport bounds; r=ato
☠☠ backed out by e7ed31dd6f7f ☠ ☠
authorAndreas Tolfsen <ato@sny.no>
Wed, 09 Jan 2019 14:47:04 +0000
changeset 510184 76be2a9fde9e21b0955227521c98b4ca28781bbf
parent 510183 4d2475136b9340eddf6852f3798259a0bfd1d456
child 510185 b52489bddb94bdb2d6fe88ed639d5c35cb2f5c7e
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1385706
milestone66.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 1385706: marionette: fix WebDriver:TakeScreenshot to use viewport bounds; r=ato The WebDriver:TakeScreenshot command relied on the document element's clientWidth/clientHeight, but should according to the WebDriver specification use the viewport's dimensions. Thanks-to: JinaJita <jitajina@gmail.com>
testing/marionette/capture.js
testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
testing/web-platform/tests/webdriver/tests/take_screenshot/__init__.py
--- a/testing/marionette/capture.js
+++ b/testing/marionette/capture.js
@@ -67,24 +67,22 @@ capture.element = function(node, highlig
  * @param {Array.<Node>=} highlights
  *     Optional array of nodes, around which a border will be marked to
  *     highlight them in the screenshot.
  *
  * @return {HTMLCanvasElement}
  *     The canvas element where the viewport has been painted on.
  */
 capture.viewport = function(win, highlights = []) {
-  let rootNode = win.document.documentElement;
-
   return capture.canvas(
       win,
       win.pageXOffset,
       win.pageYOffset,
-      rootNode.clientWidth,
-      rootNode.clientHeight,
+      win.innerWidth,
+      win.innerHeight,
       {highlights});
 };
 
 /**
  * Low-level interface to draw a rectangle off the framebuffer.
  *
  * @param {DOMWindow} win
  *     The DOM window used for the framebuffer, and providing the interfaces
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
@@ -62,20 +62,17 @@ class ScreenCaptureTestCase(MarionetteTe
         return self.marionette.find_element(By.CSS_SELECTOR, ":root")
 
     @property
     def page_y_offset(self):
         return self.marionette.execute_script("return window.pageYOffset")
 
     @property
     def viewport_dimensions(self):
-        return self.marionette.execute_script("""
-            return [arguments[0].clientWidth,
-                    arguments[0].clientHeight];
-            """, script_args=[self.document_element])
+        return self.marionette.execute_script("return [window.innerWidth, window.innerHeight];")
 
     def assert_png(self, screenshot):
         """Test that screenshot is a Base64 encoded PNG file."""
         image = base64.decodestring(screenshot)
         self.assertEqual(imghdr.what("", image), "png")
 
     def assert_formats(self, element=None):
         if element is None:
--- a/testing/web-platform/tests/webdriver/tests/take_screenshot/__init__.py
+++ b/testing/web-platform/tests/webdriver/tests/take_screenshot/__init__.py
@@ -1,6 +1,2 @@
 def document_dimensions(session):
-    return tuple(session.execute_script("""
-        let devicePixelRatio = window.devicePixelRatio;
-        let rect = document.documentElement.getBoundingClientRect();
-        return [Math.floor(rect.width * devicePixelRatio), Math.floor(rect.height * devicePixelRatio)];
-        """))
+    return tuple(session.execute_script("return [window.innerWidth, window.innerHeight];"))