Bug 1527612 - Format displayName in the server. r=loganfsmyth
authorJason Laster <jlaster@mozilla.com>
Wed, 13 Feb 2019 22:32:00 +0000
changeset 458985 b075ee1b25dcd9609e9f5441ce51711769e3d6ad
parent 458984 788e4338d31f2bb0709d3c4c06f3d46a7f77cc54
child 458986 76e2c2df0ce01be4e542e40afbe2412f850c2c61
push id78141
push userjlaster@mozilla.com
push dateWed, 13 Feb 2019 22:32:35 +0000
treeherderautoland@b075ee1b25dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1527612
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 1527612 - Format displayName in the server. r=loganfsmyth Differential Revision: https://phabricator.services.mozilla.com/D19666
devtools/client/debugger/new/src/client/firefox/create.js
devtools/server/actors/frame.js
devtools/server/tests/unit/test_frameactor-01.js
devtools/server/tests/unit/test_frameactor-04.js
--- a/devtools/client/debugger/new/src/client/firefox/create.js
+++ b/devtools/client/debugger/new/src/client/firefox/create.js
@@ -15,33 +15,27 @@ import type {
 } from "./types";
 
 import { clientCommands } from "./commands";
 
 export function createFrame(thread: ThreadId, frame: FramePacket): ?Frame {
   if (!frame) {
     return null;
   }
-  let title;
-  if (frame.type == "call") {
-    const c = frame.callee;
-    title = c.name || c.userDisplayName || c.displayName;
-  } else {
-    title = `(${frame.type})`;
-  }
+  
   const location = {
     sourceId: clientCommands.getSourceForActor(frame.where.actor),
     line: frame.where.line,
     column: frame.where.column
   };
 
   return {
     id: frame.actor,
     thread,
-    displayName: title,
+    displayName: frame.displayName,
     location,
     generatedLocation: location,
     this: frame.this,
     source: null,
     scope: frame.environment
   };
 }
 
--- a/devtools/server/actors/frame.js
+++ b/devtools/server/actors/frame.js
@@ -6,16 +6,25 @@
 
 "use strict";
 
 const { ActorPool } = require("devtools/server/actors/common");
 const { createValueGrip } = require("devtools/server/actors/object/utils");
 const { ActorClassWithSpec } = require("devtools/shared/protocol");
 const { frameSpec } = require("devtools/shared/specs/frame");
 
+function formatDisplayName(frame) {
+  if (frame.type === "call") {
+    const callee = frame.callee;
+    return callee.name || callee.userDisplayName || callee.displayName;
+  }
+
+  return `(${frame.type})`;
+}
+
 /**
  * An actor for a specified stack frame.
  */
 const FrameActor = ActorClassWithSpec(frameSpec, {
   /**
    * Creates the Frame actor.
    *
    * @param frame Debugger.Frame
@@ -71,35 +80,32 @@ const FrameActor = ActorClassWithSpec(fr
 
   /**
    * Returns a frame form for use in a protocol message.
    */
   form: function() {
     const threadActor = this.threadActor;
     const form = { actor: this.actorID,
                    type: this.frame.type };
-    if (this.frame.type === "call") {
-      form.callee = createValueGrip(this.frame.callee, threadActor._pausePool,
-        threadActor.objectGrip);
-    }
 
     // NOTE: ignoreFrameEnvironment lets the client explicitly avoid
     // populating form environments on pause.
     if (
       !this.threadActor._options.ignoreFrameEnvironment &&
       this.frame.environment
     ) {
       form.environment = this.getEnvironment();
     }
 
     if (this.frame.type != "wasmcall") {
       form.this = createValueGrip(this.frame.this, threadActor._pausePool,
         threadActor.objectGrip);
     }
 
+    form.displayName = formatDisplayName(this.frame);
     form.arguments = this._args();
     if (this.frame.script) {
       const generatedLocation = this.threadActor.sources.getFrameLocation(this.frame);
       form.where = {
         actor: generatedLocation.generatedSourceActor.actorID,
         line: generatedLocation.generatedLine,
         column: generatedLocation.generatedColumn,
       };
--- a/devtools/server/tests/unit/test_frameactor-01.js
+++ b/devtools/server/tests/unit/test_frameactor-01.js
@@ -28,17 +28,17 @@ function run_test() {
   });
   do_test_pending();
 }
 
 function test_pause_frame() {
   gThreadClient.addOneTimeListener("paused", function(event, packet) {
     Assert.ok(!!packet.frame);
     Assert.ok(!!packet.frame.actor);
-    Assert.equal(packet.frame.callee.name, "stopMe");
+    Assert.equal(packet.frame.displayName, "stopMe");
     gThreadClient.resume(function() {
       finishClient(gClient);
     });
   });
 
   gDebuggee.eval("(" + function() {
     function stopMe() {
       debugger;
--- a/devtools/server/tests/unit/test_frameactor-04.js
+++ b/devtools/server/tests/unit/test_frameactor-04.js
@@ -24,67 +24,46 @@ function run_test() {
                            function(response, targetFront, threadClient) {
                              gThreadClient = threadClient;
                              test_pause_frame();
                            });
   });
   do_test_pending();
 }
 
-var gFrames = [
+var frameFixtures = [
   // Function calls...
-  { type: "call", callee: { name: "depth3" } },
-  { type: "call", callee: { name: "depth2" } },
-  { type: "call", callee: { name: "depth1" } },
+  { type: "call", displayName: "depth3" },
+  { type: "call", displayName: "depth2" },
+  { type: "call", displayName: "depth1" },
 
   // Anonymous function call in our eval...
-  { type: "call", callee: { name: undefined } },
+  { type: "call", displayName: undefined },
 
   // The eval itself.
-  { type: "eval", callee: { name: undefined } },
-];
-
-var gSliceTests = [
-  { start: 0, count: undefined, resetActors: true },
-  { start: 0, count: 1 },
-  { start: 2, count: 2 },
-  { start: 1, count: 15 },
-  { start: 15, count: undefined },
+  { type: "eval", displayName: "(eval)" },
 ];
 
-function test_frame_slice() {
-  if (gSliceTests.length == 0) {
-    gThreadClient.resume(() => finishClient(gClient));
-    return;
-  }
-
-  const test = gSliceTests.shift();
-  gThreadClient.getFrames(test.start, test.count, function(response) {
-    const testFrames = gFrames.slice(test.start,
-                                   test.count ? test.start + test.count : undefined);
-    Assert.equal(testFrames.length, response.frames.length);
-    for (let i = 0; i < testFrames.length; i++) {
-      const expected = testFrames[i];
+function test_frame_packet() {
+  gThreadClient.getFrames(0, 1000, function(response) {
+    for (let i = 0; i < response.frames.length; i++) {
+      const expected = frameFixtures[i];
       const actual = response.frames[i];
 
-      if (test.resetActors) {
-        expected.actor = actual.actor;
-      }
+      Assert.equal(expected.displayname, actual.displayname, "Frame displayname");
+      Assert.equal(expected.type, actual.type, "Frame displayname");
+    }
 
-      for (const key of ["type", "callee-name"]) {
-        Assert.equal(expected[key] || undefined, actual[key]);
-      }
-    }
-    test_frame_slice();
+    gThreadClient.resume(() => finishClient(gClient));
   });
 }
 
 function test_pause_frame() {
   gThreadClient.addOneTimeListener("paused", function(event, packet) {
-    test_frame_slice();
+    test_frame_packet();
   });
 
   gDebuggee.eval("(" + function() {
     function depth3() {
       debugger;
     }
     function depth2() {
       depth3();