Closed Bug 1517969 Opened 6 years ago Closed 5 years ago

console.log() prints array literal when property name of object passed to console.log() is 0 or '0'

Categories

(DevTools :: Console, defect, P3)

64 Branch
defect

Tracking

(firefox74 fixed)

RESOLVED FIXED
Firefox 74
Tracking Status
firefox74 --- fixed

People

(Reporter: guest271314, Assigned: pranavpandey1998official, NeedInfo)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0 Steps to reproduce: 1. console.log({[0]:0}, {'0':0}) Actual results: -> Object [ 0 ] -> Object [ 0 ] Expected results: -> Object { 0: 0 } -> Object { 0: 0 }
Summary: console.log() prints array literal adjacent to Object when property name of object passed to console.log() is 0 or '0'' → console.log() prints array literal adjacent to Object when property name of object passed to console.log() is 0 or '0'
Component: Untriaged → Console
Product: Firefox → DevTools
It's a feature that was introduced quite some time ago to make Object which looked like arrays more array-like. I agree that we shouldn't do such thing (at all, or only if there's no length property on the object). Harald, what do you think of this? The Array-like thing was done to improve the readability of jquery `$` results.
Flags: needinfo?(hkirschner)
Summary: console.log() prints array literal adjacent to Object when property name of object passed to console.log() is 0 or '0' → console.log() prints array literal when property name of object passed to console.log() is 0 or '0'

If there are no other use cases known than jQuery, it makes sense to align with the expected behavior and what other browsers do.

Flags: needinfo?(hkirschner)
Priority: -- → P3
Status: UNCONFIRMED → NEW
Ever confirmed: true

Hi,
I would like to work on this bug.

Thanks

Hello Jacob, thanks for offering help!

if it's your first time contributing, I suggest to go through http://docs.firefox-dev.tools/getting-started/ to setup the work environment first.

This is the place where we declare such Object as arrays: devtools/server/actors/object/previewers.js#886-950

I think we can delete this whole function, and we shouldn't have those kind of object anymore.
After that, we'll probably need to remove some test (like this one devtools/server/tests/unit/test_objectgrips-array-like-object.js ), or update other ones.

Let me know if you have any trouble, either in this bug or on our Slack.

Assignee: nobody → makuer4
Status: NEW → ASSIGNED

Hi Nicolas,
Thanks for the reply regarding this bug.

I have made the changes as follows:

  1. Deleted the pseudoArray() function which was in https://github.com/makuerj/gecko-dev/tree/bug-1517969/devtools/server/actors/object/previewers.js

  2. Deleted the tests for this feature by deleting the file https://github.com/makuerj/gecko-dev/tree/bug-1517969/devtools/server/tests/unit/test_objectgrips-array-like-object.js

3 Modified the file https://github.com/makuerj/gecko-dev/tree/bug-1517969/devtools/server/tests/unit/xpcshell.ini to stop running tests on the array-like feature.

The changes can be seen in the patch file here https://github.com/makuerj/gecko-dev/blob/bug-1517969/doc/1517969.patch

Thanks,
Jacob

In addition, here is the behavior of objects in the developer console after the fix.

https://github.com/makuerj/gecko-dev/blob/bug-1517969/doc/After.png

Thanks,
Jacob

Hello Jacob, thanks for the patch.

We're using a dedicated tool for the reviews, could you read https://docs.firefox-dev.tools/contributing/making-prs.html and push your patch there please? Thanks!

Yes for sure Nicolas. I will update once the patch is pushed. Thanks!

Hello Jacob,

Do you need help pushing the patch to phabricator?

Flags: needinfo?(makuer4)

Since we didn't hear from Jacob for 2 months, I'm going to unassign this bug.
Jacob, if you're still working on this let me know and I'll reassign it :)

Assignee: makuer4 → nobody
Status: ASSIGNED → NEW

hi can i take this

(In reply to Pranav pandey from comment #11)

hi can i take this

Sure! Thanks for helping us!

Assignee: nobody → pranavpandey1998official
Attachment #9123973 - Attachment description: Bug 1517969 - removed PseudoArray function(and tests) from previewer actor. → Bug 1517969 - Removed PseudoArray previewer and related tests. r=nchevobbe.
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8390ffb1d13d Removed PseudoArray previewer and related tests. r=nchevobbe.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: