Bug 1116853 - Use Object.assign instead of DevToolsUtils.update. r=jlongster

This commit is contained in:
Nick Fitzgerald 2015-01-02 14:14:20 -08:00
parent dc105af026
commit cdc895d33a
3 changed files with 12 additions and 35 deletions

View File

@ -341,30 +341,6 @@ exports.dbg_assert = function dbg_assert(cond, 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
*

View File

@ -11,7 +11,7 @@ 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");
@ -653,7 +653,7 @@ ThreadActor.prototype = {
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.
@ -707,7 +707,7 @@ ThreadActor.prototype = {
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;
@ -4420,9 +4420,9 @@ function PauseScopedObjectActor()
PauseScopedObjectActor.prototype = Object.create(PauseScopedActor.prototype);
update(PauseScopedObjectActor.prototype, ObjectActor.prototype);
Object.assign(PauseScopedObjectActor.prototype, ObjectActor.prototype);
update(PauseScopedObjectActor.prototype, {
Object.assign(PauseScopedObjectActor.prototype, {
constructor: PauseScopedObjectActor,
actorPrefix: "pausedobj",
@ -4471,7 +4471,7 @@ update(PauseScopedObjectActor.prototype, {
}),
});
update(PauseScopedObjectActor.prototype.requestTypes, {
Object.assign(PauseScopedObjectActor.prototype.requestTypes, {
"threadGrip": PauseScopedObjectActor.prototype.onThreadGrip,
});
@ -4765,7 +4765,9 @@ BreakpointActor.prototype = {
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.
@ -5039,7 +5041,7 @@ function ChromeDebuggerActor(aConnection, 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.
@ -5067,7 +5069,7 @@ function AddonThreadActor(aConnect, 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.

View File

@ -9,7 +9,6 @@
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");
@ -1536,7 +1535,7 @@ function AddonConsoleActor(aAddon, aConnection, aParentActor)
AddonConsoleActor.prototype = Object.create(WebConsoleActor.prototype);
update(AddonConsoleActor.prototype, {
Object.assign(AddonConsoleActor.prototype, {
constructor: AddonConsoleActor,
actorPrefix: "addonConsole",