Bug 922835 - Make youngestFrame a getter instead of managing it manually; r=past
authorNick Fitzgerald <fitzgen@gmail.com>
Fri, 11 Oct 2013 14:35:51 -0700
changeset 164333 c5235838989731c07bc4781507cafda90c6a8b1a
parent 164332 71d3897f3ba8b029e0b65b588d3e4ebf395bb011
child 164362 73f37c7a386094cfb79205529ef72ba1966509f4
child 164387 f22b6a8bc244d4f19fb07b07b74e8148384ae043
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs922835
milestone27.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 922835 - Make youngestFrame a getter instead of managing it manually; r=past
toolkit/devtools/server/actors/script.js
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -462,16 +462,23 @@ ThreadActor.prototype = {
   get sources() {
     if (!this._sources) {
       this._sources = new ThreadSources(this, this._options.useSourceMaps,
                                         this._allowSource, this.onNewSource);
     }
     return this._sources;
   },
 
+  get youngestFrame() {
+    if (!this.state == "paused") {
+      return null;
+    }
+    return this.dbg.getNewestFrame();
+  },
+
   _prettyPrintWorker: null,
   get prettyPrintWorker() {
     if (!this._prettyPrintWorker) {
       this._prettyPrintWorker = new ChromeWorker(
         "resource://gre/modules/devtools/server/actors/pretty-print-worker.js");
 
       this._prettyPrintWorker.addEventListener(
         "error", this._onPrettyPrintError, false);
@@ -1174,20 +1181,16 @@ ThreadActor.prototype = {
                message: "Evaluation frame not found" };
     }
 
     if (!frame.environment) {
       return { error: "notDebuggee",
                message: "cannot access the environment of this frame." };
     }
 
-    // We'll clobber the youngest frame if the eval causes a pause, so
-    // save our frame now to be restored after eval returns.
-    // XXX: or we could just start using dbg.getNewestFrame() now that it
-    // works as expected.
     let youngest = this.youngestFrame;
 
     // Put ourselves back in the running state and inform the client.
     let resumedPacket = this._resumed();
     this.conn.send(resumedPacket);
 
     // Run the expression.
     // XXX: test syntax errors
@@ -1733,20 +1736,16 @@ ThreadActor.prototype = {
       for (let [,bp] of this._hiddenBreakpoints) {
         bp.onDelete();
       }
       this._hiddenBreakpoints.clear();
     }
 
     this._state = "paused";
 
-    // Save the pause frame (if any) as the youngest frame for
-    // stack viewing.
-    this.youngestFrame = aFrame;
-
     // Create the actor pool that will hold the pause actor and its
     // children.
     dbg_assert(!this._pausePool, "No pause pool should exist yet");
     this._pausePool = new ActorPool(this.conn);
     this.conn.addActorPool(this._pausePool);
 
     // Give children of the pause pool a quick link back to the
     // thread...
@@ -1778,17 +1777,16 @@ ThreadActor.prototype = {
   _resumed: function TA_resumed() {
     this._state = "running";
 
     // Drop the actors in the pause actor pool.
     this.conn.removeActorPool(this._pausePool);
 
     this._pausePool = null;
     this._pauseActor = null;
-    this.youngestFrame = null;
 
     return { from: this.actorID, type: "resumed" };
   },
 
   /**
    * Expire frame actors for frames that have been popped.
    *
    * @returns A list of actor IDs whose frames have been popped.
@@ -4019,17 +4017,17 @@ function getOffsetColumn(aOffset, aScrip
  * frame does not have a script, the location's properties are all null.
  *
  * @param Debugger.Frame aFrame
  *        The frame whose location we are getting.
  * @returns Object
  *          Returns an object of the form { url, line, column }
  */
 function getFrameLocation(aFrame) {
-  if (!aFrame.script) {
+  if (!aFrame || !aFrame.script) {
     return { url: null, line: null, column: null };
   }
   return {
     url: aFrame.script.url,
     line: aFrame.script.getOffsetLine(aFrame.offset),
     column: getOffsetColumn(aFrame.offset, aFrame.script)
   }
 }