Bug 1123686 - setBreakpoint should return a promise;r=jlongster
authorEddy Bruël <ejpbruel@gmail.com>
Tue, 27 Jan 2015 08:52:33 +0100
changeset 239251 fcd8ddf5cd312b9ba8cce29b71db629e176c4b4e
parent 239250 2574b2a836f417b6acb40baded4389af88093a6f
child 239252 a910bc402adc1321071d18b6d3f087fd3c6da947
push id497
push usermleibovic@mozilla.com
push dateWed, 28 Jan 2015 16:43:37 +0000
reviewersjlongster
bugs1123686
milestone38.0a1
Bug 1123686 - setBreakpoint should return a promise;r=jlongster
toolkit/devtools/server/actors/script.js
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -2725,22 +2725,20 @@ SourceActor.prototype = {
       }
       else {
         return this._createBreakpoint(genLoc, originalLoc, aRequest.condition);
       }
     });
   },
 
   _createBreakpoint: function(loc, originalLoc, condition) {
-    return resolve(null).then(() => {
-      return this.setBreakpoint({
-        line: loc.line,
-        column: loc.column,
-      }, condition);
-    }).then(response => {
+    return this.setBreakpoint({
+      line: loc.line,
+      column: loc.column,
+    }, condition).then(response => {
       var actual = response.actualLocation;
       if (actual) {
         if (this.source) {
           return this.threadActor.sources.getOriginalLocation({
             source: this.source,
             line: actual.line,
             column: actual.column
           }).then(({ sourceActor, line, column }) => {
@@ -2927,27 +2925,27 @@ SourceActor.prototype = {
 
     if (scripts.length === 0) {
       // Since we did not find any scripts to set the breakpoint on now, return
       // early. When a new script that matches this breakpoint location is
       // introduced, the breakpoint actor will already be in the breakpoint
       // store and the breakpoint will be set at that time. This is similar to
       // GDB's "pending" breakpoints for shared libraries that aren't loaded
       // yet.
-      return {
+      return Promise.resolve({
         actor: actor.actorID
-      }
+      });
     }
 
     // Ignore scripts for which the BreakpointActor is already a breakpoint
     // handler.
     scripts = scripts.filter((script) => !actor.hasScript(script));
 
     if (location.column) {
-      return this._setBreakpointAtColumn(scripts, location, actor);
+      return Promise.resolve(this._setBreakpointAtColumn(scripts, location, actor));
     }
 
     let result;
     if (actor.scripts.size === 0) {
       // If the BreakpointActor is not a breakpoint handler for any script, its
       // location is not yet fixed. Use breakpoint sliding to select the first
       // line greater than or equal to the requested line that has one or more
       // offsets.
@@ -2961,20 +2959,20 @@ SourceActor.prototype = {
         result = {
           line: location.line,
           entryPoints: entryPoints
         };
       }
     }
 
     if (!result) {
-      return {
+      return Promise.resolve({
         error: "noCodeAtLineColumn",
         actor: actor.actorID
-      };
+      });
     }
 
     const { line, entryPoints } = result;
     const actualLocation = line !== location.line
                          ? { sourceActor: this, line }
       : undefined;
 
     if (actualLocation) {
@@ -2982,37 +2980,37 @@ SourceActor.prototype = {
       // location. If we do have an existing actor, then the actor we created
       // above is redundant and must be destroyed. If we do not have an existing
       // actor, we need to update the breakpoint store with the new location.
 
       let existingActor = this.breakpointActorMap.getActor(actualLocation);
       if (existingActor) {
         actor.onDelete();
         this.breakpointActorMap.deleteActor(location);
-        return {
+        return Promise.resolve({
           actor: existingActor.actorID,
           actualLocation
-        };
+        });
       } else {
         actor.location = actualLocation;
         actor.location = {
           sourceActor: this,
           line: actualLocation.line
         };
         this.breakpointActorMap.deleteActor(location);
         this.breakpointActorMap.setActor(actualLocation, actor);
       }
     }
 
     setBreakpointOnEntryPoints(this.threadActor, actor, entryPoints);
 
-    return {
+    return Promise.resolve({
       actor: actor.actorID,
       actualLocation
-    };
+    });
   },
 
   /**
    * Find all of the offset mappings associated with `aScript` that are closest
    * to `aTargetLocation`. If new offset mappings are found that are closer to
    * `aTargetOffset` than the existing offset mappings inside
    * `aScriptsAndOffsetMappings`, we empty that map and only consider the
    * closest offset mappings.