Bug 159257 - console.log doesn't display object correctly if followed by delete
Summary: console.log doesn't display object correctly if followed by delete
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-06-29 03:48 PDT by Rafał Miłecki
Modified: 2017-07-11 11:57 PDT (History)
3 users (show)

See Also:


Attachments
Test case (384 bytes, text/html)
2016-06-29 03:48 PDT, Rafał Miłecki
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafał Miłecki 2016-06-29 03:48:09 PDT
Created attachment 282338 [details]
Test case

If we log object right before deleting one of its properties a wrong version appears in the console.

Example:
var test = {};
test.foo = {};
test.foo.bar = "Lorem ipsum";
console.log(test);
delete test.foo.bar;

Logged object doesn't have "bar" property when using:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.21 (KHTML, like Gecko) rekonq/2.3.2 Safari/537.21

In the past we already had some problem with displaying objects with console.log (#35801) it looks like similar issue (does it help to find a solution?).
Comment 1 Radar WebKit Bug Importer 2016-06-29 20:04:26 PDT
<rdar://problem/27097304>
Comment 2 Joseph Pecoraro 2016-06-29 20:10:26 PDT
This is expected behavior.

When Web Inspector is open, it provides a preview/snapshot of what the object was that was logged in case the object changes.

For large objects, when expanded, you see the live, current data. But for simple objects, when logged, we provide the snapshots.

In this particular case, you logged a simple JSON stringifyable object, and the console message includes the complete description of the object at the time it was logged. That would be what I expect.

Is this causing you an issue in some more realistic situation?
Comment 3 Joseph Pecoraro 2016-06-29 20:12:16 PDT
To expand on my last comment.

When Web Inspector is closed, it does not do this previewing/snapshotting behavior. The performance overhead of console methods is a minimum when Web Inspector is closed.