Bug 1363428 - Allow passing flags when drawing to a canavs, r=ato draft
authorJames Graham <james@hoppipolla.co.uk>
Tue, 09 May 2017 17:26:08 +0100
changeset 600206 477ef51adf854e5a3f498e2d9b5647ae54da202e
parent 600205 d7f97f3df9fda3ad812a47be90c02fd2dd2a2457
child 600207 dd220667cbf6dd9e2701306502161dc1058c4bd1
push id65688
push userbmo:james@hoppipolla.co.uk
push dateSat, 24 Jun 2017 11:04:46 +0000
reviewersato
bugs1363428
milestone56.0a1
Bug 1363428 - Allow passing flags when drawing to a canavs, r=ato MozReview-Commit-ID: 8QAFiWcsKNE
testing/marionette/capture.js
--- 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;
 };