Closed Bug 1358919 Opened 7 years ago Closed 11 months ago

Web Console displays array element with accessor descriptor as an empty slot.

Categories

(DevTools :: Console, defect, P3)

52 Branch
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: brady.j.garvin, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20170329150204

Steps to reproduce:

1. Navigate to about:blank
2. Open Web Console
3. Enter the following:
    x = [0]; Object.defineProperty(x, '0', { get: function() { return 0; } });



Actual results:

Web Console displays
    Array [ <1 empty slot> ]



Expected results:

Web Console should describe the slot in some other way.  The output
    Array [ 0 ]
might be acceptable, or it may be preferable to show
    Array [ Getter ]
in analogy to the output of
    x = { y: 0 }; Object.defineProperty(x, 'y', { get: function() { return  0; } });
On further thought,
    Array [ 0 ]
is obviously incorrect because it would require running the getter, which may have side-effects.
Component: Untriaged → Developer Tools: Console
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0

Hi and thanks for your report!

I was able to reproduce the issue you described on Release 53.0 and Beta 54.0b2 builds using Windows 10 x64, Ubuntu 16.04 LTS and MAC OS X.
On the Nightly channel, the Web Console displays the following output:
Array [ null ]
Status: UNCONFIRMED → NEW
Has STR: --- → yes
Ever confirmed: true
I agree - it'd be nice if we showed an icon to indicate that the slot had a getter but we wouldn't want to run it automatically due to side effects
Hi,

Thanks for reporting, this surfaced a bug in the console on Nightly as well.

Now for the original bug, here's the grip we get when we evaluate the STR :

  {
    "type": "object",
    "actor": "server1.conn8.child1/obj31",
    "class": "Array",
    "extensible": true,
    "frozen": false,
    "sealed": false,
    "ownPropertyLength": 2,
    "preview": {
      "kind": "ArrayLike",
      "length": 1,
      "items": [
        null
      ]
    }
  }

We obtain the same grip when we evaluate `new Array(1)`, which explains why we have the same output in the old console.
In order to handle this properly, we need to add some extra information on the backend side when an element of the array has a getter function.
(In reply to Brian Grinstead [:bgrins] from comment #4)
> The feature for showing getters is tracked in Reps:
> https://github.com/devtools-html/reps/issues/138

Addendum: Reps work is tracked here https://github.com/devtools-html/reps/issues/140
Priority: -- → P3
Product: Firefox → DevTools
Severity: normal → S3
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → INVALID
Status: RESOLVED → REOPENED
Resolution: INVALID → ---

I can verify that this bug has been fixed (also see the issues linked in the discussion), but it looks like as a reporter I cannot mark it as resolved with setting an incorrect resolution. If someone with suitable permissions could properly close it as fixed, that would be appreciated.

Status: REOPENED → RESOLVED
Closed: 11 months ago11 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.