Bug 1116853 - Use Object.assign instead of DevToolsUtils.update. r=jlongster
☠☠ backed out by 918ab351ea21 ☠ ☠
authorNick Fitzgerald <fitzgen@gmail.com>
Fri, 02 Jan 2015 14:14:20 -0800
changeset 247680 89c73451325ed382f267575e9470a7b9860cf774
parent 247679 c21ef02bbde9f0d5049da90d0046a87c91d15f26
child 247681 6b480b80299ac822da975ad74e2c1fe83d64d71f
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlongster
bugs1116853
milestone37.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 1116853 - Use Object.assign instead of DevToolsUtils.update. r=jlongster
toolkit/devtools/DevToolsUtils.js
toolkit/devtools/server/actors/script.js
toolkit/devtools/server/actors/webconsole.js
--- a/toolkit/devtools/DevToolsUtils.js
+++ b/toolkit/devtools/DevToolsUtils.js
@@ -337,40 +337,16 @@ exports.dumpv.wantVerbose = false;
 exports.dbg_assert = function dbg_assert(cond, e) {
   if (!cond) {
     return e;
   }
 };
 
 
 /**
- * Utility function for updating an object with the properties of
- * other objects.
- *
- * @param aTarget Object
- *        The object being updated.
- * @param aNewAttrs Object
- *        The rest params are objects to update aTarget with. You
- *        can pass as many as you like.
- */
-exports.update = function update(aTarget, ...aArgs) {
-  for (let attrs of aArgs) {
-    for (let key in attrs) {
-      let desc = Object.getOwnPropertyDescriptor(attrs, key);
-
-      if (desc) {
-        Object.defineProperty(aTarget, key, desc);
-      }
-    }
-  }
-
-  return aTarget;
-}
-
-/**
  * Utility function for getting the values from an object as an array
  *
  * @param aObject Object
  *        The object to iterate over
  */
 exports.values = function values(aObject) {
   return Object.keys(aObject).map(k => aObject[k]);
 }
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -6,17 +6,17 @@
 
 "use strict";
 
 const Services = require("Services");
 const { Cc, Ci, Cu, components, ChromeWorker } = require("chrome");
 const { ActorPool, getOffsetColumn } = require("devtools/server/actors/common");
 const { DebuggerServer } = require("devtools/server/main");
 const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
-const { dbg_assert, dumpn, update, fetch } = DevToolsUtils;
+const { dbg_assert, dumpn, fetch } = DevToolsUtils;
 const { dirname, joinURI } = require("devtools/toolkit/path");
 const { SourceMapConsumer, SourceMapGenerator } = require("source-map");
 const promise = require("promise");
 const PromiseDebugging = require("PromiseDebugging");
 const Debugger = require("Debugger");
 const xpcInspector = require("xpcInspector");
 const mapURIToAddonID = require("./utils/map-uri-to-addon-id");
 const ScriptStore = require("./utils/ScriptStore");
@@ -648,17 +648,17 @@ ThreadActor.prototype = {
 
     if (this.state !== "detached") {
       return { error: "wrongState",
                message: "Current state is " + this.state };
     }
 
     this._state = "attached";
 
-    update(this._options, aRequest.options || {});
+    Object.assign(this._options, aRequest.options || {});
 
     // Initialize an event loop stack. This can't be done in the constructor,
     // because this.conn is not yet initialized by the actor pool at that time.
     this._nestedEventLoops = new EventLoopStack({
       hooks: this._parent,
       connection: this.conn,
       thread: this
     });
@@ -702,17 +702,17 @@ ThreadActor.prototype = {
     };
   },
 
   onReconfigure: function (aRequest) {
     if (this.state == "exited") {
       return { error: "wrongState" };
     }
 
-    update(this._options, aRequest.options || {});
+    Object.assign(this._options, aRequest.options || {});
     // Clear existing sources, so they can be recreated on next access.
     this._sources = null;
 
     return {};
   },
 
   /**
    * Pause the debuggee, by entering a nested event loop, and return a 'paused'
@@ -4415,19 +4415,19 @@ DebuggerServer.ObjectActorPreviewers.Obj
  */
 function PauseScopedObjectActor()
 {
   ObjectActor.apply(this, arguments);
 }
 
 PauseScopedObjectActor.prototype = Object.create(PauseScopedActor.prototype);
 
-update(PauseScopedObjectActor.prototype, ObjectActor.prototype);
-
-update(PauseScopedObjectActor.prototype, {
+Object.assign(PauseScopedObjectActor.prototype, ObjectActor.prototype);
+
+Object.assign(PauseScopedObjectActor.prototype, {
   constructor: PauseScopedObjectActor,
   actorPrefix: "pausedobj",
 
   onOwnPropertyNames:
     PauseScopedActor.withPaused(ObjectActor.prototype.onOwnPropertyNames),
 
   onPrototypeAndProperties:
     PauseScopedActor.withPaused(ObjectActor.prototype.onPrototypeAndProperties),
@@ -4466,17 +4466,17 @@ update(PauseScopedObjectActor.prototype,
                message: "Only thread-lifetime actors can be released." };
     }
 
     this.release();
     return {};
   }),
 });
 
-update(PauseScopedObjectActor.prototype.requestTypes, {
+Object.assign(PauseScopedObjectActor.prototype.requestTypes, {
   "threadGrip": PauseScopedObjectActor.prototype.onThreadGrip,
 });
 
 
 /**
  * Creates an actor for the specied "very long" string. "Very long" is specified
  * at the server's discretion.
  *
@@ -4760,17 +4760,19 @@ BreakpointActor.prototype = {
    * Handle a protocol request to remove this breakpoint.
    *
    * @param aRequest object
    *        The protocol request object.
    */
   onDelete: function (aRequest) {
     // Remove from the breakpoint store.
     this.threadActor.breakpointActorMap.deleteActor(
-      update({}, this.location, { source: this.location.sourceActor.form() })
+      Object.assign({},
+                    this.location,
+                    { source: this.location.sourceActor.form() })
     );
     this.threadActor.threadLifetimePool.removeActor(this);
     // Remove the actual breakpoint from the associated scripts.
     this.removeScripts();
     return { from: this.actorID };
   }
 };
 
@@ -5034,17 +5036,17 @@ Object.defineProperty(Debugger.Frame.pro
  */
 function ChromeDebuggerActor(aConnection, aParent)
 {
   ThreadActor.call(this, aParent);
 }
 
 ChromeDebuggerActor.prototype = Object.create(ThreadActor.prototype);
 
-update(ChromeDebuggerActor.prototype, {
+Object.assign(ChromeDebuggerActor.prototype, {
   constructor: ChromeDebuggerActor,
 
   // A constant prefix that will be used to form the actor ID by the server.
   actorPrefix: "chromeDebugger"
 });
 
 exports.ChromeDebuggerActor = ChromeDebuggerActor;
 
@@ -5062,17 +5064,17 @@ exports.ChromeDebuggerActor = ChromeDebu
  *        properties.
  */
 function AddonThreadActor(aConnect, aParent) {
   ThreadActor.call(this, aParent);
 }
 
 AddonThreadActor.prototype = Object.create(ThreadActor.prototype);
 
-update(AddonThreadActor.prototype, {
+Object.assign(AddonThreadActor.prototype, {
   constructor: AddonThreadActor,
 
   // A constant prefix that will be used to form the actor ID by the server.
   actorPrefix: "addonThread",
 
   /**
    * Override the eligibility check for scripts and sources to make
    * sure every script and source with a URL is stored when debugging
--- a/toolkit/devtools/server/actors/webconsole.js
+++ b/toolkit/devtools/server/actors/webconsole.js
@@ -4,17 +4,16 @@
  * 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 { Cc, Ci, Cu } = require("chrome");
 const { DebuggerServer, ActorPool } = require("devtools/server/main");
 const { EnvironmentActor, LongStringActor, ObjectActor, ThreadActor } = require("devtools/server/actors/script");
-const { update } = require("devtools/toolkit/DevToolsUtils");
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 XPCOMUtils.defineLazyGetter(this, "NetworkMonitor", () => {
   return require("devtools/toolkit/webconsole/network-monitor")
          .NetworkMonitor;
@@ -1531,17 +1530,17 @@ exports.WebConsoleActor = WebConsoleActo
 function AddonConsoleActor(aAddon, aConnection, aParentActor)
 {
   this.addon = aAddon;
   WebConsoleActor.call(this, aConnection, aParentActor);
 }
 
 AddonConsoleActor.prototype = Object.create(WebConsoleActor.prototype);
 
-update(AddonConsoleActor.prototype, {
+Object.assign(AddonConsoleActor.prototype, {
   constructor: AddonConsoleActor,
 
   actorPrefix: "addonConsole",
 
   /**
    * The add-on that this console watches.
    */
   addon: null,