Bug 1363428 - Allow passing flags when drawing to a canavs, r=ato
MozReview-Commit-ID: 8QAFiWcsKNE
--- a/testing/marionette/capture.js
+++ b/testing/marionette/capture.js
@@ -87,37 +87,43 @@ capture.viewport = function (win, highli
* The width dimension of the rectangle to paint.
* @param {number} height
* The height dimension of the rectangle to paint.
* @param {Array.<Node>=} highlights
* Optional array of nodes, around which a border will be marked to
* highlight them in the screenshot.
* @param {HTMLCanvasElement=} canvas
* Optional canvas to reuse for the screenshot.
+ * @param {number=} flags
+ * Optional integer representing flags to pass to drawWindow; these
+ * are defined on CanvasRenderingContext2D.
*
* @return {HTMLCanvasElement}
* The canvas on which the selection from the window's framebuffer
* has been painted on.
*/
-capture.canvas = function (win, left, top, width, height, {highlights = [], canvas = null} = {}) {
- let scale = win.devicePixelRatio;
+capture.canvas = function (win, left, top, width, height,
+ {highlights = [], canvas = null, flags = null} = {}) {
+ let scale = win.devicePixelRatio;
if (canvas === null) {
canvas = win.document.createElementNS(XHTML_NS, "canvas");
canvas.width = width * scale;
canvas.height = height * scale;
}
let ctx = canvas.getContext(CONTEXT_2D);
- let flags = ctx.DRAWWINDOW_DRAW_CARET;
- // Disabled in bug 1243415 for webplatform-test failures due to out of view elements.
- // Needs https://github.com/w3c/web-platform-tests/issues/4383 fixed.
- // ctx.DRAWWINDOW_DRAW_VIEW;
- // Bug 1009762 - Crash in [@ mozilla::gl::ReadPixelsIntoDataSurface]
- // ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
+ if (flags === null) {
+ flags = ctx.DRAWWINDOW_DRAW_CARET;
+ // Disabled in bug 1243415 for webplatform-test failures due to out of view elements.
+ // Needs https://github.com/w3c/web-platform-tests/issues/4383 fixed.
+ // ctx.DRAWWINDOW_DRAW_VIEW;
+ // Bug 1009762 - Crash in [@ mozilla::gl::ReadPixelsIntoDataSurface]
+ // ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
+ }
ctx.scale(scale, scale);
ctx.drawWindow(win, left, top, width, height, BG_COLOUR, flags);
ctx = capture.highlight_(ctx, highlights, top, left);
return canvas;
};