Bug 1441228 - Correct error returned for invalid input to capture.highlight_. r?maja_zf
The WebDriver:TakeScreenshot command should return an invalid
argument error when the input is malformed.
MozReview-Commit-ID: HZFkq6QkWze
--- a/testing/marionette/capture.js
+++ b/testing/marionette/capture.js
@@ -1,14 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
+const {InvalidArgumentError} = ChromeUtils.import("chrome://marionette/content/error.js", {});
+
Cu.importGlobalProperties(["crypto"]);
this.EXPORTED_SYMBOLS = ["capture"];
const CONTEXT_2D = "2d";
const BG_COLOUR = "rgb(255,255,255)";
const PNG_MIME = "image/png";
const XHTML_NS = "http://www.w3.org/1999/xhtml";
@@ -135,18 +137,18 @@ capture.canvas = function(win, left, top
if (highlights.length) {
ctx = capture.highlight_(ctx, highlights, top, left);
}
return canvas;
};
capture.highlight_ = function(context, highlights, top = 0, left = 0) {
- if (!highlights) {
- throw new TypeError("Missing highlights");
+ if (typeof highlights == "undefined") {
+ throw new InvalidArgumentError("Missing highlights");
}
context.lineWidth = "2";
context.strokeStyle = "red";
context.save();
for (let el of highlights) {
let rect = el.getBoundingClientRect();