Bug 1282427 - Reps: handle userDisplayName property on Function grips. r=linclark
authorgasolin <gasolin@gmail.com>
Wed, 13 Jul 2016 14:44:01 +0800
changeset 330037 604f5e5652104d8c9b4db0c8ce90a0115da53f02
parent 330036 6648e2942cf97d43f1706e38fb4e5aa61ebf70a3
child 330038 30a29ca5fb3ed56ccca66e23a3281620b1a84048
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslinclark
bugs1282427
milestone50.0a1
Bug 1282427 - Reps: handle userDisplayName property on Function grips. r=linclark MozReview-Commit-ID: 2DPfSuHeFo9
devtools/client/shared/components/reps/function.js
devtools/client/shared/components/test/mochitest/test_reps_function.html
--- a/devtools/client/shared/components/reps/function.js
+++ b/devtools/client/shared/components/reps/function.js
@@ -29,17 +29,17 @@ define(function (require, exports, modul
         return this.props.objectLink({
           object: grip
         }, "function");
       }
       return "";
     },
 
     summarizeFunction: function (grip) {
-      let name = grip.displayName || grip.name || "function";
+      let name = grip.userDisplayName || grip.displayName || grip.name || "function";
       return cropString(name + "()", 100);
     },
 
     render: function () {
       let grip = this.props.object;
 
       return (
         ObjectBox({className: "function"},
--- a/devtools/client/shared/components/test/mochitest/test_reps_function.html
+++ b/devtools/client/shared/components/test/mochitest/test_reps_function.html
@@ -47,16 +47,32 @@ window.onload = Task.async(function* () 
         mode: undefined,
         expectedOutput: defaultOutput,
       }
     ];
 
     testRepRenderModes(modeTests, testName, componentUnderTest, getGripStub(testName));
   }
 
+  function testUserNamed() {
+    // Test declaration: `function testName{ let innerVar = "foo" }`
+    const testName = "testUserNamed";
+
+    const defaultOutput = `testUserName()`;
+
+    const modeTests = [
+      {
+        mode: undefined,
+        expectedOutput: defaultOutput,
+      }
+    ];
+
+    testRepRenderModes(modeTests, testName, componentUnderTest, getGripStub(testName));
+  }
+
   function testVarNamed() {
     // Test declaration: `let testVarName = function() { }`
     const testName = "testVarNamed";
 
     const defaultOutput = `testVarName()`;
 
     const modeTests = [
       {
@@ -113,16 +129,33 @@ window.onload = Task.async(function* () 
           "name": "testName",
           "displayName": "testName",
           "location": {
             "url": "debugger eval code",
             "line": 1
           }
         };
 
+      case "testUserNamed":
+        return {
+          "type": "object",
+          "class": "Function",
+          "actor": "server1.conn6.obj35",
+          "extensible": true,
+          "frozen": false,
+          "sealed": false,
+          "name": "testName",
+          "userDisplayName": "testUserName",
+          "displayName": "testName",
+          "location": {
+            "url": "debugger eval code",
+            "line": 1
+          }
+        };
+
       case "testVarNamed":
         return {
           "type": "object",
           "class": "Function",
           "actor": "server1.conn7.obj41",
           "extensible": true,
           "frozen": false,
           "sealed": false,