| Summary: | In strict mode, `Object.keys(arguments)` includes "length" | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Jordan Harband <ljharb> | ||||
| Component: | JavaScriptCore | Assignee: | Yusuke Suzuki <ysuzuki> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | commit-queue, darin, fpizlo, timothy, webkit-bug-importer, ysuzuki | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Bug Depends on: | 146510 | ||||||
| Bug Blocks: | |||||||
| Attachments: |
|
||||||
Nice catch. This is because, ClonedArguments doesn't set "length" with DontEnum. I'll upload the patch to fix this. Created attachment 257034 [details]
Patch
I'm surprised that a property that's not set with DontEnum would report "propertyIsEnumerable" as false :-/ Why aren't they consistent? When you fix this, could you also make ClonedArguments look the same in the inspector? Comment on attachment 257034 [details]
Patch
Thank you for your review, darin!
Comment on attachment 257034 [details] Patch Clearing flags on attachment: 257034 Committed r187017: <http://trac.webkit.org/changeset/187017> All reviewed patches have been landed. Closing bug. |
Given this JS: ``` var argsSloppy = (function () { return arguments; }(1,2,3)); var argsStrict = (function () { 'use strict'; return arguments; }(1,2,3)); assert(!Object.prototype.propertyIsEnumerable(argsSloppy, 'length')); assert(!Object.prototype.propertyIsEnumerable(argsStrict, 'length')); assert(Object.keys(argsSloppy).length === Object.keys(argsStrict).length); // fails assert(Object.keys(argsSloppy).indexOf('length') === -1) assert(Object.keys(argsStrict).indexOf('length') === -1); // fails ``` Even though `length` is non-enumerable on both arguments objects, `Object.keys` returns "length" for the one created in strict mode. Additionally, in the inspector, both look different - the sloppy one looks nice and pretty; the strict one doesn't. This is not broken in Safari, but it is in the latest WebKit Nightly. Note that it's a type error to do `argsStrict.callee` but not `argsSloppy.callee` - I suspect this is implementation difference between the two modes is the cause of this bug.