Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there tests against legacy magic properties that are nonconfigurable and nonwritable? #649

Closed
claudepache opened this issue May 26, 2016 · 4 comments
Labels

Comments

@claudepache
Copy link
Contributor

claudepache commented May 26, 2016

According to 6.1.7.3

If a property P is described as a data property with Desc.[[Value]] equal to v and Desc.[[Writable]] and Desc.[[Configurable]] are both false, then the SameValue must be returned for the Desc.[[Value]] attribute of the property on all future calls to [[GetOwnProperty]] ( P ).

However, as of today, many implementations define some legacy magic properties as nonconfigurable and nonwritable, but keep them changing their value over time, e.g.:

  • f.arguments and f.caller for sloppy function f (bug observed in WebKit, V8 and Chakra);
  • RegExp.$1, etc. (bug observed in WebKit).

Are there tests against these cases.

Suggested sample test:

function f() { return Object.getOwnPropertyDescriptor(f, 'arguments'); }

try { 
    Object.defineProperty(f, 'arguments', { writable: false, configurable: false });
}
catch (e) { }

var desc = Object.getOwnPropertyDescriptor(f, 'arguments');
if (desc && desc.configurable === false && desc.writable === false) {
    var desc2 = f();
    assert.sameValue(desc.value, desc2.value);
}
@jugglinmike
Copy link
Contributor

Thanks for reporting; that's a very strange bug!

I think there's value in including a test for it, but it raises a question about test organization. This isn't the right place to discuss it, so I've opened gh-650 to elaborate. If you have any thoughts on the matter, please let me know!

@littledan
Copy link
Member

littledan commented May 27, 2016

It's hard to say, strictly speaking, whether these are spec violations. Is it a prohibited extension to make these objects "exotic" with respect to those properties? (Definitely seems not that great though!)

@claudepache
Copy link
Contributor Author

@littledan Objects may behave as exotically as they want, as long as they do not violate the essential invariants given in 6.1.7.3. Citing the spec:

An implementation must not allow these invariants to be circumvented in any manner...

Among other things, the integrity of proxies depends on that.

@jugglinmike
Copy link
Contributor

I've opened gh-653 to address this.

leobalter pushed a commit that referenced this issue Mar 1, 2017
Some popular JavaScript engines display violation of invariants about
property attributes for some non-standard but “web-reality” object
properties. Add tests against such violations

Closes #653
Fixes #649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants