mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
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>
This commit is contained in:
parent
a805e86f79
commit
e490d97127
@ -72,14 +72,12 @@ capture.element = function(node, highlights = []) {
|
||||
* 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});
|
||||
};
|
||||
|
||||
|
@ -67,10 +67,7 @@ class ScreenCaptureTestCase(MarionetteTestCase):
|
||||
|
||||
@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."""
|
||||
|
@ -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];"))
|
||||
|
Loading…
Reference in New Issue
Block a user