Bug 1243415 - Remove B2G related code from screenshot methods. r=automatedtester

MozReview-Commit-ID: 1C0XXOX2zuf

--HG--
extra : rebase_source : 83861ee3f4527dd1bfbe9311a67c1302b42a17c6
This commit is contained in:
Henrik Skupin 2016-12-05 18:37:50 +01:00
Родитель 03cbd80428
Коммит 468d519037
1 изменённых файлов: 7 добавлений и 19 удалений

Просмотреть файл

@ -22,6 +22,7 @@ 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");
@ -2410,12 +2411,7 @@ GeckoDriver.prototype.takeScreenshot = function (cmd, resp) {
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;
@ -2426,20 +2422,12 @@ GeckoDriver.prototype.takeScreenshot = function (cmd, resp) {
canvas.setAttribute("width", Math.round(width * scale));
canvas.setAttribute("height", Math.round(height * scale));
// Bug 1075168: CanvasRenderingContext2D image is distorted when using
// certain flags in chrome context.
let flags = context.DRAWWINDOW_DRAW_VIEW |
context.DRAWWINDOW_USE_WIDGET_LAYERS;
let context = canvas.getContext("2d");
let flags;
if (this.appName == "B2G") {
flags =
context.DRAWWINDOW_DRAW_CARET |
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;
}
context.scale(scale, scale);
context.drawWindow(win, 0, 0, width, height, "rgb(255,255,255)", flags);
let dataUrl = canvas.toDataURL("image/png", "");