New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 2 users

Issue metadata

Status: Fixed
Owner:
User never visited
Closed: Dec 2013
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

DevToools: console: `copy()` should JSON.stringify objects instead of returning '[object Object]'

Reported by remy.a.b...@gmail.com, Sep 11 2013

Issue description

This is in response to this tweet thread: https://twitter.com/remybach/status/375573175633195008

Chrome Version       : 29.0.1547.65 (Official Build 220622) 

What steps will reproduce the problem?
1. Open the Console in the Dev Tools.
2. Type the following and hit enter: copy({foo: "bar"})
3. Paste the output anywhere.

What is the expected result?
Ideally:

    {
      foo: "bar"
    }

What happens instead?
You get: [object Object]

---

It's not a huge issue or anything, but it would just be really neat to not have to do `copy(JSON.stringify(obj, null, 2))`.

I've got a working example of how to test for this here if it could be of any use: http://jsbin.com/ukufIce/4/edit
 
Labels: Cr-Platform-DevTools Cr-Platform-DevTools-JavaScript
Summary: DevToools: console: `copy()` should JSON.stringify objects instead of returning '[object Object]' (was: Enhance the `copy` function to JSON.stringify objects instead of returning '[object Object]')
I've heard this a few times. Some clever sugar.
Wish I could take credit for the 'clever sugar', but that's all thanks to the jQuery guys :P

Not sure if I can edit the original report, but this link is better (shows the correct panes in jsbin): http://jsbin.com/ukufIce/4/edit?js,console
Owner: zvorygin@chromium.org
Status: Assigned
To summarize:

- copy(Node) copies markup
- copy(JSON.stringify-able) copies JSON
- copy(obj) copies String(obj)

sg?
Sounds about right to me :)
Status: Started
Project Member

Comment 6 by bugdroid1@chromium.org, Dec 6 2013

The following revision refers to this bug:
    http://src.chromium.org/viewvc/blink?view=rev&rev=163344

------------------------------------------------------------------------
r163344 | zvorygin@chromium.org | 2013-12-06T14:10:16.520798Z

Changed paths:
   M http://src.chromium.org/viewvc/blink/trunk/LayoutTests/inspector/console/console-command-copy.html?r1=163344&r2=163343&pathrev=163344
   M http://src.chromium.org/viewvc/blink/trunk/Source/core/inspector/InjectedScriptSource.js?r1=163344&r2=163343&pathrev=163344
   M http://src.chromium.org/viewvc/blink/trunk/LayoutTests/inspector/console/console-command-copy-expected.txt?r1=163344&r2=163343&pathrev=163344

[DevTools] Improved console.copy command to handle JSON.stringifyable objects.

BUG= 289348 

Review URL: https://codereview.chromium.org/102433002
------------------------------------------------------------------------
Status: Fixed

Sign in to add a comment