Bug 1429116 - Turn Context enum into a class. r?maja_zf draft
authorAndreas Tolfsen <ato@sny.no>
Tue, 09 Jan 2018 16:45:06 +0000
changeset 717801 955a3006015d0cfa2c60ecf2eaa5e345cb6cdd3f
parent 717738 6f5fac320fcb6625603fa8a744ffa8523f8b3d71
child 745350 968c2482d17bc471f3a6f4b75a893114334e761b
push id94783
push userbmo:ato@sny.no
push dateTue, 09 Jan 2018 16:46:06 +0000
reviewersmaja_zf
bugs1429116
milestone59.0a1
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}