Closed Bug 458959 Opened 13 years ago Closed 13 years ago

this.JSON is enumerable

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
minor

Tracking

()

VERIFIED FIXED

People

(Reporter: jruderman, Assigned: sayrer)

References

Details

(Keywords: regression, testcase)

Attachments

(1 file, 1 obsolete file)

js> uneval(this)
({JSON:JSON})

js> for (i in this) print(i)
JSON

Seems like a bug to me.  Is there something special about the JSON object that it should be enumerable when everything else (Math, gc, toSource, etc) is not?

If this is a bug, I'd appreciate a quick fix, because this change frustrates the reproducibility of jsfunfuzz bugs like bug 458679 that involve "uneval(this)" or "for (i in this)".
It looks to me like the flag should be JSPROP_READONLY | JSPROP_PERMANENT.

The only snag with this is that it will cause the export of JSON.jsm to fail, because it tries to export a "JSON" symbol and its JS_SetProperty call won't work.
What do you mean by "fail" and "won't work?" Setting a readonly property silently does nothing, it doesn't throw.
Assignee: general → sayrer
(In reply to comment #2)
> What do you mean by "fail" and "won't work?" Setting a readonly property
> silently does nothing, it doesn't throw.

This turns out to be what was happening. It was GlobalForLocation failing to compile the script, because of

var JSON = { ...
Attachment #342332 - Flags: superreview?(mrbkap)
Attachment #342332 - Flags: review?(mrbkap)
Attachment #342332 - Attachment is obsolete: true
Attachment #342344 - Flags: superreview?(mrbkap)
Attachment #342344 - Flags: review?(mrbkap)
Attachment #342332 - Flags: superreview?(mrbkap)
Attachment #342332 - Flags: review?(mrbkap)
Comment on attachment 342344 [details] [diff] [review]
Switch to JSON native where possible, rename JSON module symbol, fix JSPROPs

Looks good. Are there bugs filed on making the other JSON consumer switch to the native API?
Attachment #342344 - Flags: superreview?(mrbkap)
Attachment #342344 - Flags: superreview+
Attachment #342344 - Flags: review?(mrbkap)
Attachment #342344 - Flags: review+
(In reply to comment #6)
> Are there bugs filed on making the other JSON consumer switch to the native API?

I'm waiting for review in bug 407110 (BTW: fixing bug 442059 would make that significantly simpler). Shall I completely remove JSON.jsm once we're done?
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Depends on: 459233
Does this causes the regression bug 459293 "Sites not loading - redeclaration const JSON error on console"?
Depends on: 459293
/cvsroot/mozilla/js/tests/js1_8_1/JSON/regress-458959.js,v  <--  regress-458959.js
initial revision: 1.1

http://hg.mozilla.org/mozilla-central/rev/b04c04268a94
Flags: in-testsuite+
Flags: in-litmus-
v 1.9.1
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.