DevTools: new Array(len) should not log as (len) [undefined x len]
Reported by
hux...@gmail.com,
Jun 10 2017
|
||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Steps to reproduce the problem: 1. open DevTool > Console 2. evaluate "new Array(2)" What is the expected behavior? you should see "(2) [undefined × 2]" What went wrong? (2) [undefined × 2] is easily confused with (2) [undefined, undefined]. However, according to ECMAScript Spec, It's different. There are no real "undefined"s in arrays constructed from new Array(len). For example, hasOwnProperty(0) will return false and iteration functions like map() would behave differently. As a comparison, Safari log "new Array(2)" as just "[] (2)"; Firefox log "new Array(2) as "Array [ <2 empty slots> ]"; (prefered) Did this work before? N/A Chrome version: 58.0.3029.110 Channel: n/a OS Version: OS X 10.11.6 Flash Version: Shockwave Flash 25.0 r0
,
Jun 15 2017
,
Jun 19 2017
The formatting takes place in devtools, not v8. Reassigning to luoe@ per git blame, please feel free to reassign as appropriate.
,
Jun 19 2017
,
Jun 28 2017
Thanks for the report. We could align closer to Firefox's formatting in this case, as the two cases are different.
,
Jul 13 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/072313e39845ddbd3174acddc64686b8fa12ca15 commit 072313e39845ddbd3174acddc64686b8fa12ca15 Author: luoe <luoe@chromium.org> Date: Thu Jul 13 00:12:20 2017 DevTools: use 'empty' for array holes Console used to format holes in an Array very similarly to Array entries that contained the value 'undefined'. The former showed up as 'undefined x n', (e.g. `new Array(2)` or `[,,1]`) while the latter showed up as multiple 'undefined's (e.g. `[undefined, undefined]`). The two cases are functionally different, since `0 in Array(1)` !== `0 in [undefined]`. This CL reduces confusion by using 'empty x n' instead of 'undefined x n' for holes in an Array. BUG= 732021 Review-Url: https://codereview.chromium.org/2977463002 Cr-Commit-Position: refs/heads/master@{#486173} [modify] https://crrev.com/072313e39845ddbd3174acddc64686b8fa12ca15/third_party/WebKit/LayoutTests/inspector/console/console-format-array-prototype-expected.txt [modify] https://crrev.com/072313e39845ddbd3174acddc64686b8fa12ca15/third_party/WebKit/LayoutTests/inspector/console/console-format-collections-expected.txt [modify] https://crrev.com/072313e39845ddbd3174acddc64686b8fa12ca15/third_party/WebKit/LayoutTests/inspector/console/console-log-object-with-getter-expected.txt [modify] https://crrev.com/072313e39845ddbd3174acddc64686b8fa12ca15/third_party/WebKit/LayoutTests/inspector/console/console-object-preview-expected.txt [modify] https://crrev.com/072313e39845ddbd3174acddc64686b8fa12ca15/third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/debugger-inline-values-expected.txt [modify] https://crrev.com/072313e39845ddbd3174acddc64686b8fa12ca15/third_party/WebKit/Source/devtools/front_end/object_ui/RemoteObjectPreviewFormatter.js
,
Jul 13 2017
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by chrishtr@chromium.org
, Jun 14 2017