Bug 1429116 - Turn Context enum into a class. r=maja_zf
authorAndreas Tolfsen <ato@sny.no>
Tue, 09 Jan 2018 16:45:06 +0000
changeset 450606 706bf6511a6f04f1f05b2d1836d8941511e360e7
parent 450605 d7e62d039551133a61070e60dd4fb002db61b6e0
child 450607 ba4ce1d35c2d5aee17412c113473b6673b2b9a7d
push id8528
push userryanvm@gmail.com
push dateFri, 12 Jan 2018 02:17:15 +0000
treeherdermozilla-beta@713625f4b2f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1429116
milestone59.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 1429116 - Turn Context enum into a class. r=maja_zf There is no functional purpose of this patch apart from laying groundwork to make the window tracking patches easier to review. MozReview-Commit-ID: GOIysDLVWIf
testing/marionette/browser.js
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -23,47 +23,46 @@ this.browser = {};
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 /**
  * Variations of Marionette contexts.
  *
  * Choosing a context through the <tt>Marionette:SetContext</tt>
  * command directs all subsequent browsing context scoped commands
  * to that context.
- *
- * @enum
  */
-const Context = {
-  Chrome: "chrome",
-  Content: "content",
-};
-this.Context = Context;
+class Context {
+  /**
+   * Gets the correct context from a string.
+   *
+   * @param {string} s
+   *     Context string serialisation.
+   *
+   * @return {Context}
+   *     Context.
+   *
+   * @throws {TypeError}
+   *     If <var>s</var> is not a context.
+   */
+  static fromString(s) {
+    switch (s) {
+      case "chrome":
+        return Context.Chrome;
 
-/**
- * Gets the correct context from a string.
- *
- * @param {string} s
- *     Context string serialisation.
- *
- * @return {Context}
- *     Context.
- *
- * @throws {TypeError}
- *     If <var>s</var> is not a context.
- */
-Context.fromString = function(s) {
-  switch (s) {
-    case "chrome":
-      return Context.Chrome;
-    case "content":
-      return Context.Content;
-    default:
-      throw new TypeError(`Unknown context: ${s}`);
+      case "content":
+        return Context.Content;
+
+      default:
+        throw new TypeError(`Unknown context: ${s}`);
+    }
   }
-};
+}
+Context.Chrome = "chrome";
+Context.Content = "content";
+this.Context = Context;
 
 /**
  * Get the <code>&lt;xul:browser&gt;</code> for the specified tab.
  *
  * @param {Tab} tab
  *     The tab whose browser needs to be returned.
  *
  * @return {Browser}