Bug 1243415 - Remove B2G related code from screenshot methods. draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 05 Dec 2016 18:37:50 +0100
changeset 449725 3606359bba8295903b09d9fc5ceb6880a3db7872
parent 449724 a7fd79f040781531fd03c5f3b43439b0bc1c2194
child 449726 bb7fe939d7763ba803aeae2316aa96096ec8f37a
push id38633
push userbmo:hskupin@gmail.com
push dateWed, 14 Dec 2016 20:56:45 +0000
bugs1243415
milestone53.0a1
Bug 1243415 - Remove B2G related code from screenshot methods. MozReview-Commit-ID: 1C0XXOX2zuf
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -18,16 +18,17 @@ XPCOMUtils.defineLazyServiceGetter(
     this, "cookieManager", "@mozilla.org/cookiemanager;1", "nsICookieManager2");
 
 Cu.import("chrome://marionette/content/accessibility.js");
 Cu.import("chrome://marionette/content/action.js");
 Cu.import("chrome://marionette/content/addon.js");
 Cu.import("chrome://marionette/content/assert.js");
 Cu.import("chrome://marionette/content/atom.js");
 Cu.import("chrome://marionette/content/browser.js");
+Cu.import("chrome://marionette/content/capture.js");
 Cu.import("chrome://marionette/content/cert.js");
 Cu.import("chrome://marionette/content/element.js");
 Cu.import("chrome://marionette/content/error.js");
 Cu.import("chrome://marionette/content/evaluate.js");
 Cu.import("chrome://marionette/content/event.js");
 Cu.import("chrome://marionette/content/interaction.js");
 Cu.import("chrome://marionette/content/l10n.js");
 Cu.import("chrome://marionette/content/legacyaction.js");
@@ -2389,46 +2390,33 @@ GeckoDriver.prototype.clearImportedScrip
 GeckoDriver.prototype.takeScreenshot = function(cmd, resp) {
   let {id, highlights, full, hash} = cmd.parameters;
   highlights = highlights || [];
 
   switch (this.context) {
     case Context.CHROME:
       let win = this.getCurrentWindow();
       let canvas = win.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
-      let doc;
-      if (this.appName == "B2G") {
-        doc = win.document.body;
-      } else {
-        doc = win.document.documentElement;
-      }
+      let doc = win.document.documentElement;
       let docRect = doc.getBoundingClientRect();
       let width = docRect.width;
       let height = docRect.height;
 
       // Convert width and height from CSS pixels (potentially fractional)
       // to device pixels (integer).
       let scale = win.devicePixelRatio;
       canvas.setAttribute("width", Math.round(width * scale));
       canvas.setAttribute("height", Math.round(height * scale));
 
-      let context = canvas.getContext("2d");
-      let flags;
-      if (this.appName == "B2G") {
-        flags =
-          context.DRAWWINDOW_DRAW_CARET |
-          context.DRAWWINDOW_DRAW_VIEW |
+      // Bug 1075168: CanvasRenderingContext2D image is distorted when using
+      // certain flags in chrome context.
+      let flags = context.DRAWWINDOW_DRAW_VIEW |
           context.DRAWWINDOW_USE_WIDGET_LAYERS;
-      } else {
-        // Bug 1075168: CanvasRenderingContext2D image is distorted
-        // when using certain flags in chrome context.
-        flags =
-          context.DRAWWINDOW_DRAW_VIEW |
-          context.DRAWWINDOW_USE_WIDGET_LAYERS;
-      }
+
+      let context = canvas.getContext("2d");
       context.scale(scale, scale);
       context.drawWindow(win, 0, 0, width, height, "rgb(255,255,255)", flags);
       let dataUrl = canvas.toDataURL("image/png", "");
       let data = dataUrl.substring(dataUrl.indexOf(",") + 1);
       resp.body.value = data;
       break;
 
     case Context.CONTENT: