⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181516 in webkit


Ignore:
Timestamp:
Mar 15, 2015, 5:16:30 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-03-15
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Modeled after a blink change:

Patch by <aandrey@chromium.org>
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181515 r181516  
     12015-03-15  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Better handle displaying -0
     4        https://bugs.webkit.org/show_bug.cgi?id=142708
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Add tests for -0 in different places.
     9        I don't understand yet why the test says "0" for
     10        the property previews of "-0". Everything behaves
     11        correctly, but I can't see to make the test show
     12        the right value appear in the test. That is worth
     13        investigating separately though.
     14
     15        * inspector/model/remote-object-expected.txt:
     16        * inspector/model/remote-object.html:
     17
    1182015-03-15  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/LayoutTests/inspector/model/remote-object-expected.txt

    r181203 r181516  
    6060{
    6161  "_type": "number",
    62   "_description": "0",
     62  "_description": "-0",
    6363  "_value": 0
    6464}
     
    137137
    138138-----------------------------------------------------
     139EXPRESSION: -Infinity
     140{
     141  "_type": "number",
     142  "_description": "-Infinity",
     143  "_value": null
     144}
     145
     146-----------------------------------------------------
    139147EXPRESSION: ''
    140148{
     
    533541
    534542-----------------------------------------------------
    535 EXPRESSION: [1, 2]
     543EXPRESSION: [0, -0, 1, 2]
    536544{
    537545  "_type": "object",
     
    539547  "_objectId": "<filtered>",
    540548  "_description": "Array",
    541   "_size": 2,
     549  "_size": 4,
    542550  "_preview": {
    543551    "_type": "object",
     
    546554    "_lossless": true,
    547555    "_overflow": false,
    548     "_size": 2,
     556    "_size": 4,
    549557    "_properties": [
    550558      {
    551559        "_name": "0",
    552560        "_type": "number",
    553         "_value": "1"
     561        "_value": "0"
    554562      },
    555563      {
    556564        "_name": "1",
     565        "_type": "number",
     566        "_value": "0"
     567      },
     568      {
     569        "_name": "2",
     570        "_type": "number",
     571        "_value": "1"
     572      },
     573      {
     574        "_name": "3",
    557575        "_type": "number",
    558576        "_value": "2"
     
    14601478        "_type": "number",
    14611479        "_value": "1"
     1480      }
     1481    ],
     1482    "_entries": null
     1483  }
     1484}
     1485
     1486-----------------------------------------------------
     1487EXPRESSION: ({a: 1, b: 0, c: -0})
     1488{
     1489  "_type": "object",
     1490  "_objectId": "<filtered>",
     1491  "_description": "Object",
     1492  "_preview": {
     1493    "_type": "object",
     1494    "_description": "Object",
     1495    "_lossless": true,
     1496    "_overflow": false,
     1497    "_properties": [
     1498      {
     1499        "_name": "a",
     1500        "_type": "number",
     1501        "_value": "1"
     1502      },
     1503      {
     1504        "_name": "b",
     1505        "_type": "number",
     1506        "_value": "0"
     1507      },
     1508      {
     1509        "_name": "c",
     1510        "_type": "number",
     1511        "_value": "0"
    14621512      }
    14631513    ],
  • trunk/LayoutTests/inspector/model/remote-object.html

    r181203 r181516  
    3737        {expression: "NaN"},
    3838        {expression: "Infinity"},
     39        {expression: "-Infinity"},
    3940
    4041        // Strings
     
    7273        // Array
    7374        {expression: "[]"},
    74         {expression: "[1, 2]"},
     75        {expression: "[0, -0, 1, 2]"},
    7576        {expression: "[[1],[2],[3]]"},
    7677        {expression: "[true, 1, 1.234, 'string', /regex/]"},
     
    8990        {expression: "({})"},
    9091        {expression: "({a: 1})"},
     92        {expression: "({a: 1, b: 0, c: -0})"},
    9193        {expression: "({a: 1, b: \"string\", c: /regex/, d: Symbol('sym')})"},
    9294        {expression: "({a:function a(){}, b:function b(){}, get getter(){}, set setter(v){}})"},
  • trunk/Source/JavaScriptCore/ChangeLog

    r181503 r181516  
     12015-03-15  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Better handle displaying -0
     4        https://bugs.webkit.org/show_bug.cgi?id=142708
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Modeled after a blink change:
     9
     10        Patch by <aandrey@chromium.org>
     11        DevTools: DevTools: Show -0 for negative zero in console
     12        https://src.chromium.org/viewvc/blink?revision=162605&view=revision
     13
     14        * inspector/InjectedScriptSource.js:
     15        When creating a description string, or preview value string
     16        for -0, be sure the string is "-0" and not "0".
     17
    1182015-03-14  Ryosuke Niwa  <rniwa@webkit.org>
    219
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js

    r181203 r181516  
    4040}
    4141
     42function toStringDescription(obj)
     43{
     44    if (obj === 0 && 1 / obj < 0)
     45        return "-0";
     46
     47    return toString(obj);
     48}
     49
    4250function isUInt32(obj)
    4351{
     
    425433        var remoteObject = this._wrapObject(value, objectGroup);
    426434        try {
    427             remoteObject.description = toString(value);
     435            remoteObject.description = toStringDescription(value);
    428436        } catch (e) {}
    429437        return {
     
    896904        // Provide user-friendly number values.
    897905        if (this.type === "number")
    898             this.description = object + "";
     906            this.description = toStringDescription(object);
    899907        return;
    900908    }
     
    10571065                    preview.lossless = false;
    10581066                }
    1059                 this._appendPropertyPreview(preview, internal, {name, type, value: toString(value)}, propertiesThreshold);
     1067                this._appendPropertyPreview(preview, internal, {name, type, value: toStringDescription(value)}, propertiesThreshold);
    10601068                continue;
    10611069            }
Note: See TracChangeset for help on using the changeset viewer.