mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-12 00:50:40 +00:00
Bug 1485730 - [marionette] Limit width and height of created canvas to 32767 pixels. r=ato
The Skia GFX backend limits the dimension of canvases to a maximum of 32767 for the width and height. --HG-- extra : rebase_source : b0e1f60cc2f0c1b83e7cb7551216323983cb3407
This commit is contained in:
parent
ef28c22d42
commit
65c9584a67
@ -7,13 +7,16 @@
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const {InvalidArgumentError} = ChromeUtils.import("chrome://marionette/content/error.js", {});
|
||||
const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["crypto"]);
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["capture"];
|
||||
|
||||
const CONTEXT_2D = "2d";
|
||||
const BG_COLOUR = "rgb(255,255,255)";
|
||||
const MAX_SKIA_DIMENSIONS = 32767;
|
||||
const PNG_MIME = "image/png";
|
||||
const XHTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
|
||||
@ -112,9 +115,24 @@ capture.canvas = function(win, left, top, width, height,
|
||||
const scale = win.devicePixelRatio;
|
||||
|
||||
if (canvas === null) {
|
||||
let canvasWidth = width * scale;
|
||||
let canvasHeight = height * scale;
|
||||
|
||||
if (canvasWidth > MAX_SKIA_DIMENSIONS) {
|
||||
logger.warn("Reducing screenshot width because it exceeds " +
|
||||
MAX_SKIA_DIMENSIONS + " pixels");
|
||||
canvasWidth = MAX_SKIA_DIMENSIONS;
|
||||
}
|
||||
|
||||
if (canvasHeight > MAX_SKIA_DIMENSIONS) {
|
||||
logger.warn("Reducing screenshot height because it exceeds " +
|
||||
MAX_SKIA_DIMENSIONS + " pixels");
|
||||
canvasHeight = MAX_SKIA_DIMENSIONS;
|
||||
}
|
||||
|
||||
canvas = win.document.createElementNS(XHTML_NS, "canvas");
|
||||
canvas.width = width * scale;
|
||||
canvas.height = height * scale;
|
||||
canvas.width = canvasWidth;
|
||||
canvas.height = canvasHeight;
|
||||
}
|
||||
|
||||
let ctx = canvas.getContext(CONTEXT_2D);
|
||||
|
@ -294,6 +294,11 @@ class TestScreenCaptureContent(WindowManagerMixin, ScreenCaptureTestCase):
|
||||
self.assertRaises(NoSuchWindowException, self.marionette.screenshot)
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
def test_capture_vertical_bounds(self):
|
||||
self.marionette.navigate(inline("<body style='margin-top: 32768px'>foo"))
|
||||
screenshot = self.marionette.screenshot()
|
||||
self.assert_png(screenshot)
|
||||
|
||||
def test_capture_element(self):
|
||||
self.marionette.navigate(box)
|
||||
el = self.marionette.find_element(By.TAG_NAME, "div")
|
||||
|
Loading…
Reference in New Issue
Block a user