Bug 997219 - When inspecting an object, do not trim property names except when displaying them. r=fitzgen
authorOriol <oriol-bugzilla@hotmail.com>
Wed, 10 Aug 2016 16:18:00 -0400
changeset 352977 eb1e3117f53c7c2a03d342a22db0e3f2f63c2fe7
parent 352976 28ded847d319a75a1ea5e651447dffa2103914b2
child 352978 e336054c4c852458dc7a4b28e333212343f2bb61
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs997219
milestone51.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 997219 - When inspecting an object, do not trim property names except when displaying them. r=fitzgen
devtools/client/debugger/test/mochitest/browser.ini
devtools/client/debugger/test/mochitest/browser_dbg_variables-view-06.js
devtools/client/debugger/test/mochitest/browser_dbg_variables-view-07.js
devtools/client/debugger/test/mochitest/browser_dbg_variables-view-08.js
devtools/client/debugger/test/mochitest/doc_whitespace-property-names.html
devtools/client/shared/widgets/VariablesView.jsm
--- a/devtools/client/debugger/test/mochitest/browser.ini
+++ b/devtools/client/debugger/test/mochitest/browser.ini
@@ -114,16 +114,17 @@ support-files =
   doc_script-switching-02.html
   doc_script_webext_contentscript.html
   doc_split-console-paused-reload.html
   doc_step-many-statements.html
   doc_step-out.html
   doc_terminate-on-tab-close.html
   doc_watch-expressions.html
   doc_watch-expression-button.html
+  doc_whitespace-property-names.html
   doc_with-frame.html
   doc_worker-source-map.html
   doc_WorkerActor.attach-tab1.html
   doc_WorkerActor.attach-tab2.html
   doc_WorkerActor.attachThread-tab.html
   head.js
   sjs_post-page.sjs
   sjs_random-javascript.sjs
@@ -516,16 +517,18 @@ skip-if = e10s && debug
 [browser_dbg_variables-view-04.js]
 skip-if = e10s && debug
 [browser_dbg_variables-view-05.js]
 skip-if = e10s && debug
 [browser_dbg_variables-view-06.js]
 skip-if = e10s && debug
 [browser_dbg_variables-view-07.js]
 skip-if = e10s && debug
+[browser_dbg_variables-view-08.js]
+skip-if = e10s && debug
 [browser_dbg_variables-view-accessibility.js]
 subsuite = clipboard
 skip-if = e10s && debug
 [browser_dbg_variables-view-data.js]
 skip-if = e10s && debug
 [browser_dbg_variables-view-edit-cancel.js]
 skip-if = e10s && debug
 [browser_dbg_variables-view-edit-click.js]
--- a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-06.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-06.js
@@ -116,12 +116,10 @@ var test = Task.async(function* () {
                   "A rejected promise shouldn't have a value");
           }
         }
         ok(foundState, "We should have found the <state> property.");
         break;
     }
   }
 
-  debugger;
-
   resumeDebuggerThenCloseAndFinish(panel);
 });
--- a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-07.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-07.js
@@ -23,19 +23,21 @@ var test = Task.async(function* () {
 
   const variables = panel.panelWin.DebuggerView.Variables;
   ok(variables, "Should get the variables view.");
 
   const scope = [...variables][0];
   ok(scope, "Should get the current function's scope.");
 
   let proxy;
-  [...scope].forEach(function([name, value]) {
-    if(name === "proxy") proxy = value;
-  });
+  for (let [name, value] of scope) {
+    if (name === "proxy") {
+      proxy = value;
+    }
+  }
   ok(proxy, "Should have found the proxy variable");
 
   info("Expanding variable 'proxy'");
   let expanded = once(variables, "fetched");
   proxy.expand();
   yield expanded;
 
   let foundTarget = false;
@@ -47,21 +49,21 @@ var test = Task.async(function* () {
     yield expanded;
     if (property === "<target>") {
       for(let [subprop, subdata] of data) if(subprop === "name") {
         is(subdata.value, "target", "The value of '<target>' should be the [[ProxyTarget]]");
         foundTarget = true;
       }
     } else {
       is(property, "<handler>", "There shouldn't be properties other than <target> and <handler>");
-      for(let [subprop, subdata] of data) if(subprop === "name") {
-        is(subdata.value, "handler", "The value of '<handler>' should be the [[ProxyHandler]]");
-        foundHandler = true;
+      for (let [subprop, subdata] of data) {
+        if(subprop === "name") {
+          is(subdata.value, "handler", "The value of '<handler>' should be the [[ProxyHandler]]");
+          foundHandler = true;
+        }
       }
     }
   }
   ok(foundTarget, "Should have found the '<target>' property containing the [[ProxyTarget]]");
   ok(foundHandler, "Should have found the '<handler>' property containing the [[ProxyHandler]]");
 
-  debugger;
-
   resumeDebuggerThenCloseAndFinish(panel);
 });
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-08.js
@@ -0,0 +1,61 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test that property values are not missing when the property names only contain whitespace.
+ */
+
+const TAB_URL = EXAMPLE_URL + "doc_whitespace-property-names.html";
+
+var test = Task.async(function* () {
+  let options = {
+    source: TAB_URL,
+    line: 1
+  };
+  var dbg = initDebugger(TAB_URL, options);
+  const [tab,, panel] = yield dbg;
+  const debuggerLineNumber = 24;
+  const scopes = waitForCaretAndScopes(panel, debuggerLineNumber);
+  callInTab(tab, "doPause");
+  yield scopes;
+
+  const variables = panel.panelWin.DebuggerView.Variables;
+  ok(variables, "Should get the variables view.");
+
+  const scope = [...variables][0];
+  ok(scope, "Should get the current function's scope.");
+
+  let obj;
+  for (let [name, value] of scope) {
+    if (name === "obj") {
+      obj = value;
+    }
+  }
+  ok(obj, "Should have found the 'obj' variable");
+
+  info("Expanding variable 'obj'");
+  let expanded = once(variables, "fetched");
+  obj.expand();
+  yield expanded;
+
+  let values = [" ", "\r", "\n", "\t", "\f", "\uFEFF", "\xA0"];
+  let count = values.length;
+
+  for (let [property, value] of obj) {
+    let index = values.indexOf(property);
+    if (index >= 0) {
+      --count;
+      is(value._nameString, property,
+         "The _nameString is different than the property name");
+      is(value._valueString, index + "",
+         "The _valueString is different than the stringified value");
+      is(value._valueLabel.getAttribute("value"), index + "",
+         "The _valueLabel value is different than the stringified value");
+    }
+  }
+  is(count, 0, "There are " + count + " missing properties");
+
+  resumeDebuggerThenCloseAndFinish(panel);
+});
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/doc_whitespace-property-names.html
@@ -0,0 +1,29 @@
+<!-- Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!DOCTYPE html>
+
+<html>
+  <head>
+    <meta charset="utf-8"/>
+    <title>Debugger + Whitespace property name test page</title>
+  </head>
+
+  <body>
+    <script>
+    window.obj = {
+      " ": 0,
+      "\r": 1,
+      "\n": 2,
+      "\t": 3,
+      "\f": 4,
+      "\uFEFF": 5,
+      "\xA0": 6
+    };
+    window.doPause = function () {
+      var obj = window.obj;
+      debugger;
+    };
+    </script>
+  </body>
+
+</html>
--- a/devtools/client/shared/widgets/VariablesView.jsm
+++ b/devtools/client/shared/widgets/VariablesView.jsm
@@ -1252,17 +1252,17 @@ function Scope(aView, aName, aFlags = {}
   this.editableNameTooltip = aView.editableNameTooltip;
   this.editableValueTooltip = aView.editableValueTooltip;
   this.editButtonTooltip = aView.editButtonTooltip;
   this.deleteButtonTooltip = aView.deleteButtonTooltip;
   this.domNodeValueTooltip = aView.domNodeValueTooltip;
   this.contextMenuId = aView.contextMenuId;
   this.separatorStr = aView.separatorStr;
 
-  this._init(aName.trim(), aFlags);
+  this._init(aName, aFlags);
 }
 
 Scope.prototype = {
   /**
    * Whether this Scope should be prefetched when it is remoted.
    */
   shouldPrefetch: true,
 
@@ -1817,17 +1817,17 @@ Scope.prototype = {
     element.id = this._idString;
     element.className = aTargetClassName;
 
     let arrow = this._arrow = document.createElement("hbox");
     arrow.className = "arrow theme-twisty";
 
     let name = this._name = document.createElement("label");
     name.className = "plain name";
-    name.setAttribute("value", aName);
+    name.setAttribute("value", aName.trim());
     name.setAttribute("crop", "end");
 
     let title = this._title = document.createElement("hbox");
     title.className = "title " + aTitleClassName;
     title.setAttribute("align", "center");
 
     let enumerable = this._enum = document.createElement("vbox");
     let nonenum = this._nonenum = document.createElement("vbox");