Bug 1284232 - Convert internal error list to a set; r=automatedtester
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 08 Jul 2016 14:00:56 +0100
changeset 305446 53d2d214a699268aae7abb9fae5f204db5fa2fa5
parent 305445 bb0f0424f0f0c367c8878f2116463499c20b9fed
child 305447 cbf648dae9a0cc9c2e924741ce70b088c157733c
push id30661
push useratolfsen@mozilla.com
push dateTue, 19 Jul 2016 01:48:09 +0000
treeherderautoland@53d2d214a699 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester
bugs1284232
milestone50.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 1284232 - Convert internal error list to a set; r=automatedtester MozReview-Commit-ID: THj6qxvUus
testing/marionette/error.js
--- a/testing/marionette/error.js
+++ b/testing/marionette/error.js
@@ -1,17 +1,17 @@
 /* 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 {interfaces: Ci, utils: Cu} = Components;
 
-const ERRORS = [
+const ERRORS = new Set([
   "ElementNotAccessibleError",
   "ElementNotVisibleError",
   "InvalidArgumentError",
   "InvalidElementStateError",
   "InvalidSelectorError",
   "InvalidSessionIdError",
   "JavaScriptError",
   "NoAlertOpenError",
@@ -22,30 +22,30 @@ const ERRORS = [
   "SessionNotCreatedError",
   "StaleElementReferenceError",
   "TimeoutError",
   "UnableToSetCookieError",
   "UnknownCommandError",
   "UnknownError",
   "UnsupportedOperationError",
   "WebDriverError",
-];
+]);
 
 const BUILTIN_ERRORS = new Set([
   "Error",
   "EvalError",
   "InternalError",
   "RangeError",
   "ReferenceError",
   "SyntaxError",
   "TypeError",
   "URIError",
 ]);
 
-this.EXPORTED_SYMBOLS = ["error"].concat(ERRORS);
+this.EXPORTED_SYMBOLS = ["error"].concat(Array.from(ERRORS));
 
 this.error = {};
 
 /**
  * Checks if obj is an instance of the Error prototype in a safe manner.
  * Prefer using this over using instanceof since the Error prototype
  * isn't unique across browsers, and XPCOM nsIException's are special
  * snowflakes.
@@ -71,17 +71,17 @@ error.isError = function(val) {
   }
 };
 
 /**
  * Checks if obj is an object in the WebDriverError prototypal chain.
  */
 error.isWebDriverError = function(obj) {
   return error.isError(obj) &&
-      ("name" in obj && ERRORS.indexOf(obj.name) >= 0);
+      ("name" in obj && ERRORS.has(obj.name));
 };
 
 /**
  * Wraps an Error prototype in a WebDriverError.  If the given error is
  * already a WebDriverError, this is effectively a no-op.
  */
 error.wrap = function(err) {
   if (error.isWebDriverError(err)) {