Reps: Handle array indices lower than length of generic objects

RESOLVED DUPLICATE of bug 1314571

Status

()

Firefox
Developer Tools: Shared Components
RESOLVED DUPLICATE of bug 1314571
2 years ago
2 years ago

People

(Reporter: bgrins, Assigned: nchevobbe)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

2 years ago
This regressed from Bug 1301999, see https://bugzilla.mozilla.org/show_bug.cgi?id=1301999#c0 and the fix in that bug.
(Reporter)

Updated

2 years ago
Blocks: 1301999
(Assignee)

Updated

2 years ago
Assignee: nobody → chevobbe.nicolas
(Assignee)

Comment 1

2 years ago
The STR from https://bugzilla.mozilla.org/show_bug.cgi?id=1301999#c6 looks good to me.
When entering `({0: 0, 1: 1, 2: 2, 3: 3, length: 2})`, I get "Object { 0: 0, 1: 1, 2: 2, 2 more… }" , which is correct : we show the first three items (0,1,2), and the object has 5 items (0,1,2,3,length), so there's 2 more.

But there is indeed a problem when you put in length equal or higher than there are in the object.
For example, if I enter `({0: 0, 1: 1, 2: 2, 3: 3, length: 6})`, I get "Object [ 0, 1, 2, 3 more… ]".
This is not specific to the new frontend though, in the old console I get "Object [ 0, 1, 2, 3, <2 empty slots> ]".

Let's take a look at the grip we have in this case : 

```
{
  "type": "object",
  "actor": "server1.conn1.child1/obj195",
  "class": "Object",
  "extensible": true,
  "frozen": false,
  "sealed": false,
  "ownPropertyLength": 5,
  "preview": {
    "kind": "ArrayLike",
    "length": 6,
    "items": [
      0,
      1,
      2,
      3,
      null,
      null
    ]
  }
}
```

We can see the preview property has an "ArrayLike" kind.

When looking at the server, it looks like this is an expected behavior (http://searchfox.org/mozilla-central/source/devtools/server/actors/object.js#1794) : object with subsequent indexed properties are flagged as ArrayLike.

If I'm correct, this was introduced by Bug 1301794, and it was done on purpose.

Given all this, it looks like there's no bug and we can close this.
Do you see any issue Brian ?
Flags: needinfo?(bgrinstead)
(Reporter)

Comment 2

2 years ago
Thanks for the investigation!  I see now - what we are showing is better than the initial report in Bug 1301999:

Pre Bug 1301999 - "Object { 2: 2, 3: 3, length: 2, 2 more… }"
Post Bug 1301999 - "Object { 0: 0, 1: 1, 2: 2, 3: 3, length: 2 }"
Now - "Object { 0: 0, 1: 1, 2: 2, 2 more… }"

So even though the output has changed with reps, it's still correct now.

We might consider changing the hardcoded number of items we show by default (the old frontend shows around 10 and we are now showing 3).  Do you think we should do that?
Flags: needinfo?(bgrinstead) → needinfo?(chevobbe.nicolas)
(Assignee)

Comment 3

2 years ago
> We might consider changing the hardcoded number of items we show by default (the old frontend shows around 10 and we are now showing 3).  Do you think we should do that?

I agree, In fact this is already planned, in two steps : 
 - Bug 1314573: Reps "long" mode should preview the first 10 items for Object-like and Array-like grip
 - Bug 1314571: Use Reps in "long" mode in the new console frontend

I think I'll be able to work on those once I'm done with Bug 1307940 (i.e. this week or the next one).
Flags: needinfo?(chevobbe.nicolas)
(Reporter)

Comment 4

2 years ago
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #3)
> > We might consider changing the hardcoded number of items we show by default (the old frontend shows around 10 and we are now showing 3).  Do you think we should do that?
> 
> I agree, In fact this is already planned, in two steps : 
>  - Bug 1314573: Reps "long" mode should preview the first 10 items for
> Object-like and Array-like grip
>  - Bug 1314571: Use Reps in "long" mode in the new console frontend
> 
> I think I'll be able to work on those once I'm done with Bug 1307940 (i.e.
> this week or the next one).

OK, great!  I'll just close this one as a dupe of Bug 1314571 then
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1314571
You need to log in before you can comment on or make changes to this bug.