Bug 1571424 - [marionette] Full screenshot has to capture the whole content size. r=marionette-reviewers,ato

Differential Revision: https://phabricator.services.mozilla.com/D58530

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henrik Skupin 2020-01-03 09:07:00 +00:00
Родитель c7e5e99af1
Коммит 598061176a
4 изменённых файлов: 14 добавлений и 10 удалений

Просмотреть файл

@ -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(

Просмотреть файл

@ -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):

Просмотреть файл

@ -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(

Просмотреть файл

@ -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)];
"""))