setter & getter of an array are displayed as undefined
Categories
(DevTools :: Shared Components, defect, P3)
Tracking
(firefox103 fixed)
Tracking | Status | |
---|---|---|
firefox103 | --- | fixed |
People
(Reporter: Krischna, Assigned: arai)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0
Steps to reproduce:
- Go into the console.
- Execute this snippet:
var arr1=[],obj1={}
Object.defineProperty(arr1,0,{get: ()=>"Value"})
Object.defineProperty(obj1,"a",{get: ()=>"Value"})
var arr2=[],obj2={}
Object.defineProperty(arr2,0,{get: ()=>"Value", enumerable: true})
Object.defineProperty(obj2,"a",{get: ()=>"Value", enumerable: true})
console.log(arr1,obj1)
console.log(arr2,obj2)
console.log([...arr1],{...obj1})
console.log([...arr2],{...obj2})
Getters may also be replaced with setters. It has the same effect.
Actual results:
The getter in the arrays are displayed as undefined. Though they behave like getters.
Array [ undefined ] Object { … }
Array [ undefined ] Object { a: Getter }
Array [ "Value" ] Object { }
Array [ "Value" ] Object { a: "Value" }
Expected results:
The setter in the array should be displayed as such.
NodeJS, as an example, gets it right:
[ [Setter] ] {}
[ [Setter] ] { a: [Setter] }
[ undefined ] {}
[ undefined ] { a: undefined }
Edit:
copypasted the wrong output from NodeJS and I can't seem to be able to edit the post.
Here the correct output from NodeJS:
[ [Getter] ] {}
[ [Getter] ] { a: [Getter] }
[ 'Value' ] {}
[ 'Value' ] { a: 'Value' }
Assignee | ||
Comment 2•3 years ago
•
|
||
The formatting is done in DevTools, grip-array.js and accessor.js
Assignee | ||
Comment 3•3 years ago
|
||
The undefined comes from the following:
Array: [
function({ obj, hooks }, grip) {
...
for (let i = 0; i < length; ++i) {
if (raw && !isWorker) {
...
const desc = Object.getOwnPropertyDescriptor(Cu.waiveXrays(raw), i);
if (desc && !desc.get && !desc.set) {
...
} else if (!desc) {
...
} else {
items.push(hooks.createValueGrip(undefined));
Assignee | ||
Comment 4•3 years ago
|
||
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 5•3 years ago
|
||
Comment 7•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0646b8bb3ec5
https://hg.mozilla.org/mozilla-central/rev/e033ff580f53
Description
•