Backed out changeset 4fc14159ba69 (bug 1585529) for debugger failures. CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Fri, 04 Oct 2019 15:55:49 +0300
changeset 496320 d477fb519881ddd1836c7c84938d553b070e4d1a
parent 496319 1cf96914dd193a3a596e6b35a12fdaeb816e095a
child 496321 e89c795c2260feb3752db02c7c7466ac7c5f2e5e
push id36651
push userncsoregi@mozilla.com
push dateFri, 04 Oct 2019 21:38:11 +0000
treeherdermozilla-central@74c62117e3e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1585529
milestone71.0a1
backs out4fc14159ba6925ee071ec7d1a2425b4612f5bc0d
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
Backed out changeset 4fc14159ba69 (bug 1585529) for debugger failures. CLOSED TREE
devtools/client/debugger/packages/devtools-reps/src/object-inspector/components/ObjectInspectorItem.js
devtools/client/debugger/packages/devtools-reps/src/object-inspector/utils/node.js
devtools/client/shared/components/reps/reps.js
devtools/client/webconsole/test/browser/browser_webconsole_object_inspector_getters.js
--- a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/components/ObjectInspectorItem.js
+++ b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/components/ObjectInspectorItem.js
@@ -172,23 +172,34 @@ class ObjectInspectorItem extends Compon
           open: nodeHasFullText(item) && expanded,
         };
       }
 
       if (nodeHasGetter(item)) {
         const targetGrip = getParentGripValue(item);
         const receiverGrip = getNonPrototypeParentGripValue(item);
         if (targetGrip && receiverGrip) {
+          let propertyName = item.name;
+          // If we're dealing with a property that can't be accessed
+          // with the dot notation, for example: x["hello-world"]
+          if (propertyName.startsWith(`"`) && propertyName.endsWith(`"`)) {
+            // We remove the quotes wrapping the property name, and we replace any
+            // "double" escaped quotes (\\\") by simple escaped ones (\").
+            propertyName = propertyName
+              .substring(1, propertyName.length - 1)
+              .replace(/\\\"/g, `\"`);
+          }
+
           Object.assign(repProps, {
             onInvokeGetterButtonClick: () =>
               this.props.invokeGetter(
                 item,
                 targetGrip,
                 receiverGrip.actor,
-                item.propertyName || item.name
+                propertyName
               ),
           });
         }
       }
 
       return {
         label,
         value: Utils.renderRep(item, repProps),
--- a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/utils/node.js
+++ b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/utils/node.js
@@ -517,17 +517,16 @@ function makeDefaultPropsBucket(
       contents: null,
       type: NODE_TYPES.DEFAULT_PROPERTIES,
     });
 
     const defaultNodes = defaultProperties.map((name, index) =>
       createNode({
         parent: defaultPropertiesNode,
         name: maybeEscapePropertyName(name),
-        propertyName: name,
         path: createPath(index, name),
         contents: ownProperties[name],
       })
     );
     nodes.push(setNodeChildren(defaultPropertiesNode, defaultNodes));
   }
   return nodes;
 }
@@ -536,17 +535,16 @@ function makeNodesForOwnProps(
   propertiesNames: Array<string>,
   parent: Node,
   ownProperties: Object
 ): Array<Node> {
   return propertiesNames.map(name =>
     createNode({
       parent,
       name: maybeEscapePropertyName(name),
-      propertyName: name,
       contents: ownProperties[name],
     })
   );
 }
 
 function makeNodesForProperties(
   objProps: GripProperties,
   parent: Node
@@ -657,22 +655,20 @@ function makeNodeForPrototype(objProps: 
 
 function createNode(options: {
   parent: Node,
   name: string,
   contents: any,
   path?: string,
   type?: Symbol,
   meta?: Object,
-  propertyName?: string,
 }): ?Node {
   const {
     parent,
     name,
-    propertyName,
     path,
     contents,
     type = NODE_TYPES.GRIP,
     meta,
   } = options;
 
   if (contents === undefined) {
     return null;
@@ -680,18 +676,16 @@ function createNode(options: {
 
   // The path is important to uniquely identify the item in the entire
   // tree. This helps debugging & optimizes React's rendering of large
   // lists. The path will be separated by property name.
 
   return {
     parent,
     name,
-    // `name` can be escaped; propertyName contains the original property name.
-    propertyName,
     path: createPath(parent && parent.path, path || name),
     contents,
     type,
     meta,
   };
 }
 
 function createGetterNode({ parent, property, name }) {
--- a/devtools/client/shared/components/reps/reps.js
+++ b/devtools/client/shared/components/reps/reps.js
@@ -2048,31 +2048,29 @@ function makeDefaultPropsBucket(properti
       parent,
       name: "<default properties>",
       contents: null,
       type: NODE_TYPES.DEFAULT_PROPERTIES
     });
     const defaultNodes = defaultProperties.map((name, index) => createNode({
       parent: defaultPropertiesNode,
       name: maybeEscapePropertyName(name),
-      propertyName: name,
       path: createPath(index, name),
       contents: ownProperties[name]
     }));
     nodes.push(setNodeChildren(defaultPropertiesNode, defaultNodes));
   }
 
   return nodes;
 }
 
 function makeNodesForOwnProps(propertiesNames, parent, ownProperties) {
   return propertiesNames.map(name => createNode({
     parent,
     name: maybeEscapePropertyName(name),
-    propertyName: name,
     contents: ownProperties[name]
   }));
 }
 
 function makeNodesForProperties(objProps, parent) {
   const {
     ownProperties = {},
     ownSymbols,
@@ -2184,35 +2182,32 @@ function makeNodeForPrototype(objProps, 
 
   return null;
 }
 
 function createNode(options) {
   const {
     parent,
     name,
-    propertyName,
     path,
     contents,
     type = NODE_TYPES.GRIP,
     meta
   } = options;
 
   if (contents === undefined) {
     return null;
   } // The path is important to uniquely identify the item in the entire
   // tree. This helps debugging & optimizes React's rendering of large
   // lists. The path will be separated by property name.
 
 
   return {
     parent,
     name,
-    // `name` can be escaped; propertyName contains the original property name.
-    propertyName,
     path: createPath(parent && parent.path, path || name),
     contents,
     type,
     meta
   };
 }
 
 function createGetterNode({
@@ -8262,18 +8257,27 @@ class ObjectInspectorItem extends Compon
         };
       }
 
       if (nodeHasGetter(item)) {
         const targetGrip = getParentGripValue(item);
         const receiverGrip = getNonPrototypeParentGripValue(item);
 
         if (targetGrip && receiverGrip) {
+          let propertyName = item.name; // If we're dealing with a property that can't be accessed
+          // with the dot notation, for example: x["hello-world"]
+
+          if (propertyName.startsWith(`"`) && propertyName.endsWith(`"`)) {
+            // We remove the quotes wrapping the property name, and we replace any
+            // "double" escaped quotes (\\\") by simple escaped ones (\").
+            propertyName = propertyName.substring(1, propertyName.length - 1).replace(/\\\"/g, `\"`);
+          }
+
           Object.assign(repProps, {
-            onInvokeGetterButtonClick: () => this.props.invokeGetter(item, targetGrip, receiverGrip.actor, item.propertyName || item.name)
+            onInvokeGetterButtonClick: () => this.props.invokeGetter(item, targetGrip, receiverGrip.actor, propertyName)
           });
         }
       }
 
       return {
         label,
         value: Utils.renderRep(item, repProps)
       };
--- a/devtools/client/webconsole/test/browser/browser_webconsole_object_inspector_getters.js
+++ b/devtools/client/webconsole/test/browser/browser_webconsole_object_inspector_getters.js
@@ -69,19 +69,16 @@ add_task(async function() {
             return longString;
           },
           get ["hyphen-getter"]() {
             return "---";
           },
           get [`"quoted-getter"`]() {
             return "quoted";
           },
-          get [`"'\``]() {
-            return "quoted2";
-          },
         })
       )
     );
   });
 
   const node = await waitFor(() => findMessage(hud, "oi-test"));
   const oi = node.querySelector(".tree");
 
@@ -98,17 +95,17 @@ add_task(async function() {
   await testTrueGetter(oi);
   await testObjectGetter(oi);
   await testArrayGetter(oi);
   await testMapGetter(oi);
   await testProxyGetter(oi);
   await testThrowingGetter(oi);
   await testLongStringGetter(oi, LONGSTRING);
   await testHypgenGetter(oi);
-  await testQuotedGetters(oi);
+  await testQuotedGetter(oi);
 });
 
 async function testStringGetter(oi) {
   let node = findObjectInspectorNode(oi, "myStringGetter");
   is(
     isObjectInspectorNodeExpandable(node),
     false,
     "The node can't be expanded"
@@ -597,57 +594,43 @@ async function testHypgenGetter(oi) {
   );
   is(
     isObjectInspectorNodeExpandable(node),
     false,
     "The node can't be expanded"
   );
 }
 
-async function testQuotedGetters(oi) {
-  const nodes = [
-    {
-      name: `"\\"quoted-getter\\""`,
-      expected: `"quoted"`,
-      expandable: false,
-    },
-    {
-      name: `"\\"'\`"`,
-      expected: `"quoted2"`,
-      expandable: false,
-    },
-  ];
+async function testQuotedGetter(oi) {
+  const findQuotedGetterNode = () =>
+    findObjectInspectorNode(oi, `"\\"quoted-getter\\""`);
+  let node = findQuotedGetterNode();
 
-  for (const { name, expected, expandable } of nodes) {
-    await testGetter(oi, name, expected, expandable);
-  }
-}
-
-async function testGetter(oi, propertyName, expectedResult, resultExpandable) {
-  info(`Check «${propertyName}» getter`);
-  const findNode = () => findObjectInspectorNode(oi, propertyName);
-
-  let node = findNode();
   is(
     isObjectInspectorNodeExpandable(node),
     false,
-    `«${propertyName}» can't be expanded`
+    "The node can't be expanded"
   );
-  getObjectInspectorInvokeGetterButton(node).click();
-  await waitFor(() => !getObjectInspectorInvokeGetterButton(findNode()));
+  const invokeButton = getObjectInspectorInvokeGetterButton(node);
+  ok(invokeButton, "There is an invoke button as expected");
 
-  node = findNode();
+  invokeButton.click();
+  await waitFor(
+    () => !getObjectInspectorInvokeGetterButton(findQuotedGetterNode())
+  );
+
+  node = findQuotedGetterNode();
   ok(
-    node.textContent.includes(`${propertyName}: ${expectedResult}`),
-    `«${propertyName}» now has the expected text content («${expectedResult}»)`
+    node.textContent.includes(`"\\"quoted-getter\\"": "quoted"`),
+    "Node now has the expected text content"
   );
   is(
     isObjectInspectorNodeExpandable(node),
-    resultExpandable,
-    `«${propertyName}» ${resultExpandable ? "now can" : "can't"} be expanded`
+    false,
+    "The node can't be expanded"
   );
 }
 
 function checkChildren(node, expectedChildren) {
   const children = getObjectInspectorChildrenNodes(node);
   is(
     children.length,
     expectedChildren.length,