diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index 81b119c8777d..ee702a0d478a 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -3014,8 +3014,8 @@ GeckoDriver.prototype.takeScreenshot = async function(cmd) { let el = this.curBrowser.seenEls.get(webEl, win); rect = el.getBoundingClientRect(); } else if (full) { - let clientRect = win.document.documentElement.getBoundingClientRect(); - rect = new win.DOMRect(0, 0, clientRect.width, clientRect.height); + const docEl = win.document.documentElement; + rect = new DOMRect(0, 0, docEl.scrollWidth, docEl.scrollHeight); } else { // viewport rect = new win.DOMRect( diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py b/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py index 9e9f4699ff0b..4956ed4883b6 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py @@ -218,7 +218,10 @@ class TestScreenCaptureContent(WindowManagerMixin, ScreenCaptureTestCase): @property def scroll_dimensions(self): return tuple(self.marionette.execute_script(""" - return [document.body.scrollWidth, document.body.scrollHeight] + return [ + document.documentElement.scrollWidth, + document.documentElement.scrollHeight + ]; """)) def test_capture_tab_already_closed(self): @@ -266,18 +269,18 @@ class TestScreenCaptureContent(WindowManagerMixin, ScreenCaptureTestCase): self.get_image_dimensions(screenshot)) self.assertGreater(self.page_y_offset, 0) - def test_capture_html_document_element(self): + def test_capture_full_html_document_element(self): self.marionette.navigate(long) screenshot = self.marionette.screenshot() self.assert_png(screenshot) self.assertEqual(self.scale(self.scroll_dimensions), self.get_image_dimensions(screenshot)) - def test_capture_svg_document_element(self): + def test_capture_full_svg_document_element(self): self.marionette.navigate(svg) screenshot = self.marionette.screenshot() self.assert_png(screenshot) - self.assertEqual(self.scale(self.get_element_dimensions(self.document_element)), + self.assertEqual(self.scale(self.scroll_dimensions), self.get_image_dimensions(screenshot)) def test_capture_viewport(self): diff --git a/testing/marionette/listener.js b/testing/marionette/listener.js index 8d307803fb92..c6f621f0d1f3 100644 --- a/testing/marionette/listener.js +++ b/testing/marionette/listener.js @@ -1663,8 +1663,8 @@ function getScreenshotRect({ el, full = true, scroll = true } = {}) { } rect = getElementRect(el); } else if (full) { - let clientRect = win.document.documentElement.getBoundingClientRect(); - rect = new DOMRect(0, 0, clientRect.width, clientRect.height); + const docEl = win.document.documentElement; + rect = new DOMRect(0, 0, docEl.scrollWidth, docEl.scrollHeight); } else { // viewport rect = new DOMRect( diff --git a/testing/web-platform/mozilla/tests/webdriver/take_full_screenshot/__init__.py b/testing/web-platform/mozilla/tests/webdriver/take_full_screenshot/__init__.py index fa86372a78e8..d5de0d731c20 100644 --- a/testing/web-platform/mozilla/tests/webdriver/take_full_screenshot/__init__.py +++ b/testing/web-platform/mozilla/tests/webdriver/take_full_screenshot/__init__.py @@ -1,7 +1,8 @@ def document_dimensions(session): return tuple(session.execute_script(""" - let {devicePixelRatio} = window; - let {width, height} = document.documentElement.getBoundingClientRect(); + const {devicePixelRatio} = window; + const width = document.documentElement.scrollWidth; + const height = document.documentElement.scrollHeight; return [Math.floor(width * devicePixelRatio), Math.floor(height * devicePixelRatio)]; """))