Bug 122867 - Web Inspector: ES6: Improved Console Format for Set and Map Objects (like Arrays)
Summary: Web Inspector: ES6: Improved Console Format for Set and Map Objects (like Arr...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-10-15 15:21 PDT by Joseph Pecoraro
Modified: 2015-01-29 11:25 PST (History)
7 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (87.70 KB, patch)
2015-01-26 19:50 PST, Joseph Pecoraro
joepeck: commit-queue-
Details | Formatted Diff | Diff
[PATCH] Proposed Fix (87.86 KB, patch)
2015-01-27 14:55 PST, Joseph Pecoraro
timothy: review+
timothy: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2013-10-15 15:21:57 PDT
JSC supports ES6 Set objects. We should have an improved Console Formatting for Sets, like we do Arrays. Currently the console.log is cumbersome.

    var set = new Set(1,2,1,2,3);
    // Possible UI: { 1, 2, 3 }
Comment 1 Radar WebKit Bug Importer 2013-10-15 15:22:20 PDT
<rdar://problem/15235745>
Comment 2 Timothy Hatcher 2013-10-16 11:25:59 PDT
{ 1, 2, 3 } sounds good, what about Maps? { foo: 1, bar: 2, bas: 3 }? Too much like an object literal?
Comment 3 Michał Gołębiowski-Owczarek 2014-04-29 01:38:07 PDT
(In reply to comment #2)
> { 1, 2, 3 } sounds good, what about Maps? { foo: 1, bar: 2, bas: 3 }? Too much like an object literal?

What about Maps with non-primitive keys? { foo: 1, { bar: 4 }: 2, bas: 3 }? Or will it just be omitted? Such a notation would create a weird case where map({ bar: 4 }) === undefined even though you see this object serialization in the console.
Comment 4 Joseph Pecoraro 2015-01-21 22:41:51 PST
I'll be doing this soon.
Comment 5 Joseph Pecoraro 2015-01-26 19:50:24 PST
Created attachment 245403 [details]
[PATCH] Proposed Fix
Comment 6 WebKit Commit Bot 2015-01-26 19:51:51 PST
This patch modifies the inspector protocol generator. Please ensure that you have rebaselined any generator test results (i.e., by running `Tools/Scripts/run-inspector-generator-tests --reset-results`)
Comment 7 Joseph Pecoraro 2015-01-26 19:53:12 PST
+ Some JavaScriptCore folks.

Can you review the JSC WeakMapData portions of the patch?

    runtime/WeakMapData.h
    inspector/JSInjectedScriptHostPrototype.cpp:
    inspector/JSInjectedScriptHost.h:
    inspector/JSInjectedScriptHost.cpp:
Comment 8 Joseph Pecoraro 2015-01-26 19:56:40 PST
Comment on attachment 245403 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=245403&action=review

> Source/JavaScriptCore/inspector/InjectedScriptSource.js:793
> +        this.preview = this._generatePreview(object, objectGroupName, undefined, columnNames);

Oops, this objectGroupName addition is now no longer necessary. I will remove it here and in subsequent sections.

> Source/JavaScriptCore/inspector/InjectedScriptSource.js:966
> +    _appendEntryPreviews: function(object, objectGroupName, preview)

Like here, where it is no longer used.
Comment 9 Joseph Pecoraro 2015-01-26 23:53:28 PST
Comment on attachment 245403 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=245403&action=review

> Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js:282
> -            var lossless = this._appendObjectPreview(titleElement, obj);
> +            var lossless = this._appendPreview(titleElement, obj.preview);

Oops, I think this will break iOS 7/8. I will have to augment the type/subtype/description onto the the preview for those. Should be easy:

    if (!preview.type) {
        preview.type = obj.type;
        preview.subtype = obj.subtype;
    }

But maybe I should invest in creating a real WebInspector.ObjectPreview model object to abstract this away.
Comment 10 Joseph Pecoraro 2015-01-27 14:28:20 PST
Comment on attachment 245403 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=245403&action=review

> LayoutTests/TestExpectations:101
> +# Garbage Collection is missing an object.
> +webkit.org/b/140919 inspector/model/remote-object-weak-collection.html [ Skip ]

We got to the bottom of this and can change the test to get consistent expected results. Unfortunately, I think I'll still need to skip the test because the bots still timeout randomly on inspector tests but bug 140919 has been closed.
Comment 11 Joseph Pecoraro 2015-01-27 14:55:51 PST
Created attachment 245475 [details]
[PATCH] Proposed Fix
Comment 12 Timothy Hatcher 2015-01-27 23:02:21 PST
Comment on attachment 245475 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=245475&action=review

> Source/JavaScriptCore/inspector/InjectedScriptSource.js:737
> +        }
> +        return entries;

Nit: Newline.
Comment 13 Joseph Pecoraro 2015-01-29 11:25:59 PST
http://trac.webkit.org/changeset/179349