bug 1523104: remote: stop binding JSM exported globals on this; r=ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 12 Feb 2019 05:58:23 -0800
changeset 521075 bea61357248a
parent 521074 294ef13003d0
child 521076 f73d7c3bced4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1523104
milestone67.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 1523104: remote: stop binding JSM exported globals on this; r=ato This was breaking the constructor name, used in Domain.jsm. As doing this.Foo = class extends Domain { creates a class with undefined constructor name. While class Foo extends Domain { creates a class with "Foo" as domain name.
remote/Actor.jsm
remote/Collections.jsm
remote/Connection.jsm
remote/ConsoleServiceObserver.jsm
remote/Domain.jsm
remote/Error.jsm
remote/EventEmitter.jsm
remote/Handler.jsm
remote/Log.jsm
remote/MessageChannel.jsm
remote/Observer.jsm
remote/Protocol.jsm
remote/Session.jsm
remote/Target.jsm
remote/TargetListener.jsm
remote/WindowManager.jsm
remote/actor/DOMChild.jsm
remote/actor/LogChild.jsm
remote/domain/Log.jsm
remote/domain/Network.jsm
remote/domain/Page.jsm
remote/domain/Runtime.jsm
--- a/remote/Actor.jsm
+++ b/remote/Actor.jsm
@@ -13,17 +13,17 @@ const {ActorChild} = ChromeUtils.import(
 const {Log} = ChromeUtils.import("chrome://remote/content/Log.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "log", Log.get);
 
 // TODO(ato):
 // This used to have more stuff on it, but now only really does logging,
 // and I'm sure there's a better way to get the message manager logs.
-this.RemoteAgentActorChild = class extends ActorChild {
+class RemoteAgentActorChild extends ActorChild {
   get browsingContext() {
     return this.docShell.browsingContext;
   }
 
   sendAsyncMessage(name, data = {}) {
     log.trace(`<--(message ${name}) ${JSON.stringify(data)}`);
     super.sendAsyncMessage(name, data);
   }
@@ -32,17 +32,17 @@ this.RemoteAgentActorChild = class exten
     log.trace(`(message ${name})--> ${JSON.stringify(data)}`);
     super.receiveMessage(name, data);
   }
 };
 
 // TODO(ato): Move to MessageChannel.jsm?
 // TODO(ato): This can eventually be replaced by ActorChild and IPDL generation
 // TODO(ato): Can we find a shorter name?
-this.MessageChannelActorChild = class extends RemoteAgentActorChild {
+class MessageChannelActorChild extends RemoteAgentActorChild {
   constructor(dispatcher) {
     super(dispatcher);
     this.name = `RemoteAgent:${this.constructor.name}`;
   }
 
   emit(eventName, params = {}) {
     this.send({eventName, params});
   }
--- a/remote/Collections.jsm
+++ b/remote/Collections.jsm
@@ -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";
 
 var EXPORTED_SYMBOLS = ["AtomicMap"];
 
-this.AtomicMap = class extends Map {
+class AtomicMap extends Map {
   set(key, value) {
     if (this.has(key)) {
       throw new RangeError("Key already used: " + key);
     }
     super.set(key, value);
   }
 
   pop(key) {
--- a/remote/Connection.jsm
+++ b/remote/Connection.jsm
@@ -6,17 +6,17 @@
 
 var EXPORTED_SYMBOLS = ["Connection"];
 
 const {Log} = ChromeUtils.import("chrome://remote/content/Log.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "log", Log.get);
 
-this.Connection = class {
+class Connection {
   constructor(connID, transport, socketListener) {
     this.id = connID;
     this.transport = transport;
     this.socketListener = socketListener;
 
     this.transport.hooks = this;
     this.onmessage = () => {};
   }
--- a/remote/ConsoleServiceObserver.jsm
+++ b/remote/ConsoleServiceObserver.jsm
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["ConsoleServiceObserver"];
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-this.ConsoleServiceObserver = class {
+class ConsoleServiceObserver {
   constructor() {
     this.running = false;
   }
 
   start() {
     if (!this.running) {
       Services.console.registerListener(this);
       this.running = true;
--- a/remote/Domain.jsm
+++ b/remote/Domain.jsm
@@ -4,17 +4,17 @@
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Domain"];
 
 const {EventEmitter} = ChromeUtils.import("chrome://remote/content/EventEmitter.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-this.Domain = class {
+class Domain {
   constructor(session, target) {
     this.session = session;
     this.target = target;
     this.name = this.constructor.name;
 
     EventEmitter.decorate(this);
   }
 
--- a/remote/Error.jsm
+++ b/remote/Error.jsm
@@ -29,32 +29,32 @@ class RemoteAgentError extends Error {
 }
 
 /**
  * A fatal error that it is not possible to recover from
  * or send back to the client.
  *
  * Constructing this error will cause the application to quit.
  */
-this.FatalError = class extends RemoteAgentError {
+class FatalError extends RemoteAgentError {
   constructor(...args) {
     super(...args);
     this.quit();
   }
 
   notify() {
     log.fatal(formatError(this, {stack: true}));
   }
 
   quit(mode = Ci.nsIAppStartup.eForceQuit) {
     Services.startup.quit(mode);
   }
 };
 
-this.UnsupportedError = class extends RemoteAgentError {};
+class UnsupportedError extends RemoteAgentError {};
 
 function formatError(error, {stack = false} = {}) {
   const s = [];
   s.push(`${error.name}: ${error.message}`);
   s.push("");
   if (stack) {
     s.push("Stacktrace:");
   }
--- a/remote/EventEmitter.jsm
+++ b/remote/EventEmitter.jsm
@@ -7,17 +7,17 @@
 var EXPORTED_SYMBOLS = ["EventEmitter"];
 
 const LISTENERS = Symbol("EventEmitter/listeners");
 const ONCE_ORIGINAL_LISTENER = Symbol("EventEmitter/once-original-listener");
 
 const BAD_LISTENER = "Listener must be a function " +
     "or an object that has an onevent function";
 
-this.EventEmitter = class {
+class EventEmitter {
   constructor() {
     this.listeners = new Map();
   }
 
   static on(target, type, listener) {
     if (typeof listener != "function" && !isEventHandler(listener)) {
       throw new TypeError(BAD_LISTENER);
     }
--- a/remote/Handler.jsm
+++ b/remote/Handler.jsm
@@ -34,32 +34,32 @@ class Handler {
 class JSONHandler extends Handler {
   register(server) {
     server.registerPathHandler(this.path, (req, resp) => {
       this.rawHandle(req, new JSONWriter(resp));
     });
   }
 }
 
-this.TargetListHandler = class extends JSONHandler {
+class TargetListHandler extends JSONHandler {
   constructor(targets) {
     super();
     this.targets = targets;
   }
 
   get path() {
     return "/json/list";
   }
 
   handle(request, response) {
     response.write([...this.targets]);
   }
 };
 
-this.ProtocolHandler = class extends JSONHandler {
+class ProtocolHandler extends JSONHandler {
   get path() {
     return "/json/protocol";
   }
 
   handle(request, response) {
     response.write(Protocol.Description);
   }
 };
--- a/remote/Log.jsm
+++ b/remote/Log.jsm
@@ -2,17 +2,17 @@
  * 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";
 
 var EXPORTED_SYMBOLS = ["Log"];
 
 /** E10s compatible wrapper for the standard logger from Log.jsm. */
-this.Log = class {
+class Log {
   static get() {
     const StdLog = ChromeUtils.import("resource://gre/modules/Log.jsm").Log;
     const logger = StdLog.repository.getLogger("RemoteAgent");
     if (logger.ownAppenders.length == 0) {
       logger.addAppender(new StdLog.DumpAppender());
       logger.manageLevelFromPref("remote.log.level");
     }
     return logger;
--- a/remote/MessageChannel.jsm
+++ b/remote/MessageChannel.jsm
@@ -8,17 +8,17 @@ var EXPORTED_SYMBOLS = ["MessageChannel"
 
 const {AtomicMap} = ChromeUtils.import("chrome://remote/content/Collections.jsm");
 const {FatalError} = ChromeUtils.import("chrome://remote/content/Error.jsm");
 const {Log} = ChromeUtils.import("chrome://remote/content/Log.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "log", Log.get);
 
-this.MessageChannel = class {
+class MessageChannel {
   constructor(target, channelName, messageManager) {
     this.target = target;
     this.name = channelName;
     this.mm = messageManager;
     this.mm.addMessageListener(this.name, this);
 
     this.ids = 0;
     this.pending = new AtomicMap();
--- a/remote/Observer.jsm
+++ b/remote/Observer.jsm
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Observer"];
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-this.Observer = class {
+class Observer {
   static observe(type, observer) {
     Services.obs.addObserver(observer, type);
   }
 
   static unobserve(type, observer) {
     Services.obs.removeObserver(observer, type);
   }
 
--- a/remote/Protocol.jsm
+++ b/remote/Protocol.jsm
@@ -1,16 +1,16 @@
 "use strict";
 
 var EXPORTED_SYMBOLS = [
   "Protocol",
   "t",
 ];
 
-this.t = {
+var t = {
   String: x => typeof x == "string" || x instanceof String,
   Number: x => typeof x == "number",
   Boolean: x => typeof x == "boolean",
   Null: x => Object.is(x, null),
   Enum: values => x => values.includes(x),
   Undefined: x => Object.is(x, undefined),
   Or: (...schemas) => x => schemas.some(schema => checkSchema(schema, x)),
   Either: (...schemas) => x => schemas.map(schema => checkSchema(schema, x)).reduce((acc, x) => acc + (x ? 1 : 0)) === 1,
@@ -17399,12 +17399,12 @@ const Description = {
         }
     ],
     "version": {
         "major": "1",
         "minor": "3"
     }
 };
 
-this.Protocol = {
+var Protocol = {
   checkSchema,
   Description,
 };
--- a/remote/Session.jsm
+++ b/remote/Session.jsm
@@ -5,17 +5,17 @@
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Session"];
 
 const {Domain} = ChromeUtils.import("chrome://remote/content/Domain.jsm");
 const {formatError} = ChromeUtils.import("chrome://remote/content/Error.jsm");
 const {Protocol} = ChromeUtils.import("chrome://remote/content/Protocol.jsm");
 
-this.Session = class {
+class Session {
   constructor(connection, target) {
     this.connection = connection;
     this.target = target;
 
     this.domains = new Domains(this);
 
     this.connection.onmessage = this.dispatch.bind(this);
   }
--- a/remote/Target.jsm
+++ b/remote/Target.jsm
@@ -15,17 +15,17 @@ XPCOMUtils.defineLazyServiceGetter(this,
     "@mozilla.org/browser/favicon-service;1", "nsIFaviconService");
 
 /**
  * A debugging target.
  *
  * Targets can be a document (page), an OOP frame, a background
  * document, or a worker.  They can all run in dedicated process or frame.
  */
-this.Target = class {
+class Target {
   constructor(browser) {
     this.browser = browser;
     this.debugger = new TargetListener(this);
 
     EventEmitter.decorate(this);
   }
 
   connect() {
--- a/remote/TargetListener.jsm
+++ b/remote/TargetListener.jsm
@@ -14,17 +14,17 @@ const {SocketListener} = ChromeUtils.imp
  * Represents a debuggee target (a browsing context, typically a tab)
  * that clients can connect to and debug.
  *
  * Debugger#listen starts a WebSocket listener,
  * and for each accepted connection a new Session is created.
  * There can be multiple sessions per target.
  * The session's lifetime is equal to the lifetime of the debugger connection.
  */
-this.TargetListener = class {
+class TargetListener {
   constructor(target) {
     this.target = target;
     this.listener = null;
     this.sessions = new Map();
     this.nextConnID = 0;
   }
 
   get connected() {
--- a/remote/WindowManager.jsm
+++ b/remote/WindowManager.jsm
@@ -36,17 +36,17 @@ XPCOMUtils.defineLazyGetter(this, "log",
 // browser tracking across host process changes.
 
 /**
  * Observes DOMWindows as they open and close.
  *
  * The WindowObserver.Event.Open event fires when a window opens.
  * The WindowObserver.Event.Close event fires when a window closes.
  */
-this.WindowObserver = class {
+class WindowObserver {
   /**
    * @param {boolean?} [false] registerExisting
    *     Events will be despatched for the ChromeWindows that exist
    *     at the time the observer is started.
    */
   constructor({registerExisting = false} = {}) {
     this.registerExisting = registerExisting;
     EventEmitter.decorate(this);
@@ -91,17 +91,17 @@ this.WindowObserver = class {
 };
 
 /**
  * Observe Firefox tabs as they open and close.
  *
  * "open" fires when a tab opens.
  * "close" fires when a tab closes.
  */
-this.TabObserver = class {
+class TabObserver {
   /**
    * @param {boolean?} [false] registerExisting
    *     Events will be fired for ChromeWIndows and their respective tabs
    *     at the time when the observer is started.
    */
   constructor({registerExisting = false} = {}) {
     this.windows = new WindowObserver({registerExisting});
     EventEmitter.decorate(this);
@@ -151,17 +151,17 @@ this.TabObserver = class {
  * BrowserObserver is more powerful than TabObserver,
  * as it watches for any content browser appearing anywhere in Gecko.
  * TabObserver on the other hand is limited to browsers associated with a tab.
  *
  * This class is currently not used by the remote agent,
  * but leave it in here because we may have use for it later
  * if we decide to allow Marionette-style chrome automation.
  */
-this.BrowserObserver = class {
+class BrowserObserver {
   constructor() {
     EventEmitter.decorate(this);
   }
 
   start() {
     // TODO(ato): Theoretically it would be better to use ChromeWindow#getGroupMessageManager("Browsers")
     // TODO(ato): Browser:Init does not cover browsers living in the parent process
     Services.mm.addMessageListener("Browser:Init", this);
@@ -238,9 +238,9 @@ function isWindowIncluded(boundary, targ
   const {parent} = target;
   if (!parent || parent === boundary) {
     return false;
   }
 
   return isWindowIncluded(boundary, parent);
 }
 
-this.WindowManager = {isWindowIncluded};
+var WindowManager = {isWindowIncluded};
--- a/remote/actor/DOMChild.jsm
+++ b/remote/actor/DOMChild.jsm
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["DOMChild"];
 
 const {RemoteAgentActorChild} = ChromeUtils.import("chrome://remote/content/Actor.jsm");
 
-this.DOMChild = class extends RemoteAgentActorChild {
+class DOMChild extends RemoteAgentActorChild {
   handleEvent({type}) {
     const event = {
       type,
       timestamp: Date.now(),
     };
     this.sendAsyncMessage("RemoteAgent:DOM:OnEvent", event);
   }
 };
--- a/remote/actor/LogChild.jsm
+++ b/remote/actor/LogChild.jsm
@@ -5,17 +5,17 @@
 "use strict";
 
 var EXPORTED_SYMBOLS = ["LogChild"];
 
 const {RemoteAgentActorChild} = ChromeUtils.import("chrome://remote/content/Actor.jsm");
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {WindowManager} = ChromeUtils.import("chrome://remote/content/WindowManager.jsm");
 
-this.LogChild = class extends RemoteAgentActorChild {
+class LogChild extends RemoteAgentActorChild {
   observe(subject, topic) {
     const event = subject.wrappedJSObject;
 
     if (this.isEventRelevant(event)) {
       const entry = {
         source: "javascript",
         level: reduceLevel(event.level),
         text: event.arguments.join(" "),
--- a/remote/domain/Log.jsm
+++ b/remote/domain/Log.jsm
@@ -30,17 +30,17 @@ const ALLOWED_SOURCES = [
 
 const ALLOWED_LEVELS = [
   "verbose",
   "info",
   "warning",
   "error",
 ];
 
-this.Log = class extends Domain {
+class Log extends Domain {
   constructor(session, target) {
     super(session, target);
     this.enabled = false;
   }
 
   destructor() {
     this.disable();
   }
@@ -88,17 +88,17 @@ this.Log = class extends Domain {
       },
       events: {
         entryAdded: Log.LogEntry.schema,
       },
     };
   }
 };
 
-this.Log.LogEntry = {
+Log.LogEntry = {
   schema: {
     source: t.Enum(ALLOWED_SOURCES),
     level: t.Enum(ALLOWED_LEVELS),
     text: t.String,
     timestamp: Runtime.Timestamp,
     url: t.Optional(t.String),
     lineNumber: t.Optional(t.Number),
     stackTrace: t.Optional(Runtime.StackTrace.schema),
--- a/remote/domain/Network.jsm
+++ b/remote/domain/Network.jsm
@@ -3,13 +3,13 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Network"];
 
 const {t} = ChromeUtils.import("chrome://remote/content/Protocol.jsm");
 
-this.Network = {
+var Network = {
   MonotonicTime: {schema: t.Number},
   LoaderId: {schema: t.String},
   RequestId: {schema: t.Number},
 };
--- a/remote/domain/Page.jsm
+++ b/remote/domain/Page.jsm
@@ -6,17 +6,17 @@
 
 var EXPORTED_SYMBOLS = ["Page"];
 
 const {Domain} = ChromeUtils.import("chrome://remote/content/Domain.jsm");
 const {t} = ChromeUtils.import("chrome://remote/content/Protocol.jsm");
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {UnsupportedError} = ChromeUtils.import("chrome://remote/content/Error.jsm");
 
-this.Page = class extends Domain {
+class Page extends Domain {
   constructor(session, target) {
     super(session, target);
     this.enabled = false;
   }
 
   destructor() {
     this.disable();
   }
@@ -111,18 +111,18 @@ this.Page = class extends Domain {
         loadEventFired: {
           timestamp: Domain.Network.MonotonicTime.schema,
         },
       },
     };
   }
 };
 
-this.Page.FrameId = {schema: t.String};
-this.Page.TransitionType = {
+Page.FrameId = {schema: t.String};
+Page.TransitionType = {
   schema: t.Enum([
     "auto_bookmark",
     "auto_subframe",
     "link",
     "manual_subframe",
     "reload",
     "typed",
   ]),
--- a/remote/domain/Runtime.jsm
+++ b/remote/domain/Runtime.jsm
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Runtime"];
 
 const {t} = ChromeUtils.import("chrome://remote/content/Protocol.jsm");
 
-this.Runtime = {
+var Runtime = {
   StackTrace: {schema: t.String},
 
   RemoteObject: {
     schema: t.Either(
         {
           type: t.Enum([
             "object",
             "function",