Bug 141173

Summary: Web Inspector: ES6: Improved Console Support for Symbol Objects
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren, graouts, joepeck, jonowells, mattbaker, nvasilyev, timothy, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix
timothy: review+
[IMAGE] Symbol Appearance none

Description Joseph Pecoraro 2015-02-02 14:33:31 PST
* SUMMARY
JSC got ES6 Symbol support in: http://trac.webkit.org/changeset/179429

We should do a good job with Symbols in the Console.

  (1) Formatting Symbol Objects

      js> Symbol("test")
      ACTUAL => Symbol
      EXPECT => Symbol(test)

  (2) Showing Symbol properties on Objects

      js> var o = {}; o[Symbol("test")] = 1; o;
      ACTUAL => {}
      EXPECT => {Symbol("test"): 1}

Note, for (2) we may need Object.getOwnPropertySymbols, which doesn't look like JSC has yet.

Anything else that might be useful for Symbols?
Comment 1 Radar WebKit Bug Importer 2015-02-02 14:34:03 PST
<rdar://problem/19690733>
Comment 2 Joseph Pecoraro 2015-02-02 14:40:21 PST
Note inspector is already complaining in a few places that it doesn't know about symbols, since it is a new default type:

    js> typeof Symbol("test")
    "symbol"

I'll probably have to look into this sooner than later!
Comment 3 Joseph Pecoraro 2015-02-02 14:46:14 PST
>   (2) Showing Symbol properties on Objects
> 
>       js> var o = {}; o[Symbol("test")] = 1; o;
>       ACTUAL => {}
>       EXPECT => {Symbol("test"): 1}

Err, the EXPECT should have been {Symbol(test): 1}
Comment 4 Joseph Pecoraro 2015-02-02 14:49:35 PST
Another note about Symbols:

    js> "" + Symbol("test")
    TypeError: Type error

However, String() works:

    js> String(Symbol("test"))
    "Symbol(test)"

So we likely have to update InjectedScriptSource's stringification to use String() or move away from (""+o).
Comment 5 Joseph Pecoraro 2015-02-03 19:05:16 PST
Created attachment 246006 [details]
[PATCH] Proposed Fix

This handles (1). I'll have to address (2) "symbol properties on objects" separately. Ideally once we get Object.getOwnPropertySymbols in JavaScriptCore.
Comment 6 Joseph Pecoraro 2015-02-03 19:05:50 PST
Created attachment 246007 [details]
[IMAGE] Symbol Appearance
Comment 7 Joseph Pecoraro 2015-02-04 19:15:42 PST
http://trac.webkit.org/changeset/179659

Part (2) to be covered by bug 141279:
<https://webkit.org/b/141279> Web Inspector: ES6: Show Symbol properties on Objects