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
--- 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><xul:browser></code> for the specified tab.
*
* @param {Tab} tab
* The tab whose browser needs to be returned.
*
* @return {Browser}