Bug 1406150 - Always throw exceptions by using 'new'. r=maja_zf
authorHenrik Skupin <mail@hskupin.info>
Fri, 06 Oct 2017 14:07:13 +0200
changeset 384954 3d7f66f234ad985b0b5064cb3c0c98e636b48e90
parent 384953 33181ffec32af337242ce542e31f9ee06ee286d9
child 384955 645a700843fefbdf5c5dab0ec5f1fc7f13dcaf01
push id95880
push userarchaeopteryx@coole-files.de
push dateSat, 07 Oct 2017 08:58:44 +0000
treeherdermozilla-inbound@156942799371 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1406150
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1406150 - Always throw exceptions by using 'new'. r=maja_zf MozReview-Commit-ID: GmI1PuSQwWU
testing/marionette/driver.js
testing/marionette/navigate.js
testing/marionette/packets.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -195,33 +195,33 @@ Object.defineProperty(GeckoDriver.protot
       case Context.CHROME:
         let chromeWin = this.getCurrentWindow();
         return new URL(chromeWin.location.href);
 
       case Context.CONTENT:
         return new URL(this.curBrowser.currentURI.spec);
 
       default:
-        throw TypeError(`Unknown context: ${this.context}`);
+        throw new TypeError(`Unknown context: ${this.context}`);
     }
   },
 });
 
 Object.defineProperty(GeckoDriver.prototype, "title", {
   get() {
     switch (this.context) {
       case Context.CHROME:
         let chromeWin = this.getCurrentWindow();
         return chromeWin.document.documentElement.getAttribute("title");
 
       case Context.CONTENT:
         return this.curBrowser.currentTitle;
 
       default:
-        throw TypeError(`Unknown context: ${this.context}`);
+        throw new TypeError(`Unknown context: ${this.context}`);
     }
   },
 });
 
 Object.defineProperty(GeckoDriver.prototype, "proxy", {
   get() {
     return this.capabilities.get("proxy");
   },
@@ -2696,17 +2696,17 @@ GeckoDriver.prototype.deleteCookie = fun
   let {hostname, pathname} = this.currentURL;
   let candidateName = assert.string(cmd.parameters.name);
   for (let toDelete of cookie.iter(hostname, pathname)) {
     if (toDelete.name === candidateName) {
       return cookie.remove(toDelete);
     }
   }
 
-  throw UnknownError("Unable to find cookie");
+  throw new UnknownError("Unable to find cookie");
 };
 
 /**
  * Close the currently selected tab/window.
  *
  * With multiple open tabs present the currently selected tab will
  * be closed.  Otherwise the window itself will be closed. If it is the
  * last window currently open, the window will not be closed to prevent
@@ -3311,17 +3311,17 @@ GeckoDriver.prototype.quit = async funct
 
 GeckoDriver.prototype.installAddon = function(cmd) {
   assert.firefox();
 
   let path = cmd.parameters.path;
   let temp = cmd.parameters.temporary || false;
   if (typeof path == "undefined" || typeof path != "string" ||
       typeof temp != "boolean") {
-    throw InvalidArgumentError();
+    throw new InvalidArgumentError();
   }
 
   return addon.install(path, temp);
 };
 
 GeckoDriver.prototype.uninstallAddon = function(cmd) {
   assert.firefox();
 
--- a/testing/marionette/navigate.js
+++ b/testing/marionette/navigate.js
@@ -27,17 +27,17 @@ this.navigate = {};
  *
  * @throws TypeError
  *     If <code>current</code> is not defined, or any of
  *     <code>current</code> or <code>future</code>  are invalid URLs.
  */
 navigate.isLoadEventExpected = function(current, future = undefined) {
   // assume we will go somewhere exciting
   if (typeof current == "undefined") {
-    throw TypeError("Expected at least one URL");
+    throw new TypeError("Expected at least one URL");
   }
 
   // Assume we will go somewhere exciting
   if (typeof future == "undefined") {
     return true;
   }
 
   let cur = new URL(current);
--- a/testing/marionette/packets.js
+++ b/testing/marionette/packets.js
@@ -80,18 +80,18 @@ Packet.fromHeader = function(header, tra
 Packet.prototype = {
 
   get length() {
     return this._length;
   },
 
   set length(length) {
     if (length > PACKET_LENGTH_MAX) {
-      throw Error("Packet length " + length + " exceeds the max length of " +
-                  PACKET_LENGTH_MAX);
+      throw new Error("Packet length " + length +
+                      " exceeds the max length of " + PACKET_LENGTH_MAX);
     }
     this._length = length;
   },
 
   destroy() {
     this._transport = null;
   },
 };