<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>142656</bug_id>
          
          <creation_ts>2015-03-12 23:44:04 -0700</creation_ts>
          <short_desc>Web Inspector: Expose a way for developer provided object previews</short_desc>
          <delta_ts>2026-01-12 09:08:23 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Joseph Pecoraro">joepeck</assigned_to>
          <cc>0.cynics-squints</cc>
    
    <cc>graouts</cc>
    
    <cc>inspector-bugzilla-changes</cc>
    
    <cc>jonowells</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1076870</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-03-12 23:44:04 -0700</bug_when>
    <thetext>* SUMMARY
Expose a way for developer provided object previews.

* IDEA (nvasilyev)

The idea here is that instead of just showing the first 5 properties of an object in Object Previews, we could show more useful previews based on what the developer of the object may deem most useful to expose.

For example an object might display poorly:

  js&gt; obj
  ▶︎ MyObject {_root: Object, __owner: undefined, __hash: undefined...}

We can provide a hook for the developers to provide better previews. For example, we could check if the object has a Symbol.preview getter in the prototype chain, and if so use that object in the prototype chain

For example:

  MyObject.prototype = {
    toJSON() { ... },
    get [Symbol.preview]() { return this.toJSON(); },
  };

Would produce:

  js&gt; obj
  ▶︎ MyObject {x: 2, y: 42, color: &quot;red&quot;}


* NOTES
- &quot;Symbol.preview&quot; is probably bad, since that is a built-in object.
- &quot;console.preview&quot; is likely better, after all this is for the &quot;console&quot; / debugger</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1076871</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2015-03-12 23:44:42 -0700</bug_when>
    <thetext>&lt;rdar://problem/20149654&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1180952</commentid>
    <comment_count>2</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2016-04-05 13:36:14 -0700</bug_when>
    <thetext>Chrome seems to do this with a global map hanging off window (window.devtoolsFormatters). Yuck.

https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1972250</commentid>
    <comment_count>3</comment_count>
    <who name="Salam">0.cynics-squints</who>
    <bug_when>2023-08-19 13:05:22 -0700</bug_when>
    <thetext>Hi,

Now that both Google Chrome[1] and Mozilla Firefox[2] implemented this feature, is it possible for WebKit/Safari to do the same so that developers (myself included) who use Safari as their primary browser for development can benefit from it as well? The community of developers that can benefit from this feature seem not so insignificant as evidenced by the backlash when the Google Chrome team made an announcement of removing this feature from Google Chrome[3].

Thanks.

[1] https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/
[2] https://fxdx.dev/firefox-devtools-custom-object-formatters/
[3] https://twitter.com/ChromeDevTools/status/1263421789671239681</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>