Title: [181516] trunk
Revision
181516
Author
[email protected]
Date
2015-03-15 17:16:30 -0700 (Sun, 15 Mar 2015)

Log Message

Web Inspector: Better handle displaying -0
https://bugs.webkit.org/show_bug.cgi?id=142708

Patch by Joseph Pecoraro <[email protected]> on 2015-03-15
Reviewed by Timothy Hatcher.

Source/_javascript_Core:

Modeled after a blink change:

Patch by <[email protected]>
DevTools: DevTools: Show -0 for negative zero in console
https://src.chromium.org/viewvc/blink?revision=162605&view=revision

* inspector/InjectedScriptSource.js:
When creating a description string, or preview value string
for -0, be sure the string is "-0" and not "0".

LayoutTests:

Add tests for -0 in different places.
I don't understand yet why the test says "0" for
the property previews of "-0". Everything behaves
correctly, but I can't see to make the test show
the right value appear in the test. That is worth
investigating separately though.

* inspector/model/remote-object-expected.txt:
* inspector/model/remote-object.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181515 => 181516)


--- trunk/LayoutTests/ChangeLog	2015-03-15 23:07:37 UTC (rev 181515)
+++ trunk/LayoutTests/ChangeLog	2015-03-16 00:16:30 UTC (rev 181516)
@@ -1,3 +1,20 @@
+2015-03-15  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Better handle displaying -0
+        https://bugs.webkit.org/show_bug.cgi?id=142708
+
+        Reviewed by Timothy Hatcher.
+
+        Add tests for -0 in different places.
+        I don't understand yet why the test says "0" for
+        the property previews of "-0". Everything behaves
+        correctly, but I can't see to make the test show
+        the right value appear in the test. That is worth
+        investigating separately though.
+
+        * inspector/model/remote-object-expected.txt:
+        * inspector/model/remote-object.html:
+
 2015-03-15  Simon Fraser  <[email protected]>
 
         Reduce the side-effects of animations turning off overlap testing

Modified: trunk/LayoutTests/inspector/model/remote-object-expected.txt (181515 => 181516)


--- trunk/LayoutTests/inspector/model/remote-object-expected.txt	2015-03-15 23:07:37 UTC (rev 181515)
+++ trunk/LayoutTests/inspector/model/remote-object-expected.txt	2015-03-16 00:16:30 UTC (rev 181516)
@@ -59,7 +59,7 @@
 _expression_: -0
 {
   "_type": "number",
-  "_description": "0",
+  "_description": "-0",
   "_value": 0
 }
 
@@ -136,6 +136,14 @@
 }
 
 -----------------------------------------------------
+_expression_: -Infinity
+{
+  "_type": "number",
+  "_description": "-Infinity",
+  "_value": null
+}
+
+-----------------------------------------------------
 _expression_: ''
 {
   "_type": "string",
@@ -532,29 +540,39 @@
 }
 
 -----------------------------------------------------
-_expression_: [1, 2]
+_expression_: [0, -0, 1, 2]
 {
   "_type": "object",
   "_subtype": "array",
   "_objectId": "<filtered>",
   "_description": "Array",
-  "_size": 2,
+  "_size": 4,
   "_preview": {
     "_type": "object",
     "_subtype": "array",
     "_description": "Array",
     "_lossless": true,
     "_overflow": false,
-    "_size": 2,
+    "_size": 4,
     "_properties": [
       {
         "_name": "0",
         "_type": "number",
-        "_value": "1"
+        "_value": "0"
       },
       {
         "_name": "1",
         "_type": "number",
+        "_value": "0"
+      },
+      {
+        "_name": "2",
+        "_type": "number",
+        "_value": "1"
+      },
+      {
+        "_name": "3",
+        "_type": "number",
         "_value": "2"
       }
     ],
@@ -1466,6 +1484,38 @@
 }
 
 -----------------------------------------------------
+_expression_: ({a: 1, b: 0, c: -0})
+{
+  "_type": "object",
+  "_objectId": "<filtered>",
+  "_description": "Object",
+  "_preview": {
+    "_type": "object",
+    "_description": "Object",
+    "_lossless": true,
+    "_overflow": false,
+    "_properties": [
+      {
+        "_name": "a",
+        "_type": "number",
+        "_value": "1"
+      },
+      {
+        "_name": "b",
+        "_type": "number",
+        "_value": "0"
+      },
+      {
+        "_name": "c",
+        "_type": "number",
+        "_value": "0"
+      }
+    ],
+    "_entries": null
+  }
+}
+
+-----------------------------------------------------
 _expression_: ({a: 1, b: "string", c: /regex/, d: Symbol('sym')})
 {
   "_type": "object",

Modified: trunk/LayoutTests/inspector/model/remote-object.html (181515 => 181516)


--- trunk/LayoutTests/inspector/model/remote-object.html	2015-03-15 23:07:37 UTC (rev 181515)
+++ trunk/LayoutTests/inspector/model/remote-object.html	2015-03-16 00:16:30 UTC (rev 181516)
@@ -36,6 +36,7 @@
         {_expression_: "Number.MIN_VALUE"},
         {_expression_: "NaN"},
         {_expression_: "Infinity"},
+        {_expression_: "-Infinity"},
 
         // Strings
         {_expression_: "''"},
@@ -71,7 +72,7 @@
 
         // Array
         {_expression_: "[]"},
-        {_expression_: "[1, 2]"},
+        {_expression_: "[0, -0, 1, 2]"},
         {_expression_: "[[1],[2],[3]]"},
         {_expression_: "[true, 1, 1.234, 'string', /regex/]"},
         {_expression_: "[{a:1}, {b:2}, {c:2}]"},
@@ -88,6 +89,7 @@
         // Object
         {_expression_: "({})"},
         {_expression_: "({a: 1})"},
+        {_expression_: "({a: 1, b: 0, c: -0})"},
         {_expression_: "({a: 1, b: \"string\", c: /regex/, d: Symbol('sym')})"},
         {_expression_: "({a:function a(){}, b:function b(){}, get getter(){}, set setter(v){}})"},
         {_expression_: "function Foo() {}; new Foo"},

Modified: trunk/Source/_javascript_Core/ChangeLog (181515 => 181516)


--- trunk/Source/_javascript_Core/ChangeLog	2015-03-15 23:07:37 UTC (rev 181515)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-03-16 00:16:30 UTC (rev 181516)
@@ -1,3 +1,20 @@
+2015-03-15  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Better handle displaying -0
+        https://bugs.webkit.org/show_bug.cgi?id=142708
+
+        Reviewed by Timothy Hatcher.
+
+        Modeled after a blink change:
+
+        Patch by <[email protected]>
+        DevTools: DevTools: Show -0 for negative zero in console
+        https://src.chromium.org/viewvc/blink?revision=162605&view=revision
+
+        * inspector/InjectedScriptSource.js:
+        When creating a description string, or preview value string
+        for -0, be sure the string is "-0" and not "0".
+
 2015-03-14  Ryosuke Niwa  <[email protected]>
 
         parseClass should popScope after pushScope

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (181515 => 181516)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-03-15 23:07:37 UTC (rev 181515)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-03-16 00:16:30 UTC (rev 181516)
@@ -39,6 +39,14 @@
     return String(obj);
 }
 
+function toStringDescription(obj)
+{
+    if (obj === 0 && 1 / obj < 0)
+        return "-0";
+
+    return toString(obj);
+}
+
 function isUInt32(obj)
 {
     if (typeof obj === "number")
@@ -424,7 +432,7 @@
     {
         var remoteObject = this._wrapObject(value, objectGroup);
         try {
-            remoteObject.description = toString(value);
+            remoteObject.description = toStringDescription(value);
         } catch (e) {}
         return {
             wasThrown: true,
@@ -895,7 +903,7 @@
 
         // Provide user-friendly number values.
         if (this.type === "number")
-            this.description = object + "";
+            this.description = toStringDescription(object);
         return;
     }
 
@@ -1056,7 +1064,7 @@
                     value = this._abbreviateString(value, maxLength, true);
                     preview.lossless = false;
                 }
-                this._appendPropertyPreview(preview, internal, {name, type, value: toString(value)}, propertiesThreshold);
+                this._appendPropertyPreview(preview, internal, {name, type, value: toStringDescription(value)}, propertiesThreshold);
                 continue;
             }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to