Created
July 29, 2010 06:16
-
-
Save cms/497388 to your computer and use it in GitHub Desktop.
BESEN undefined accessor properties bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BESEN strange behavior on named accessor property | |
// Tested on r77 | |
var obj = Object.defineProperty({}, 'foo', { set: undefined }), | |
desc = Object.getOwnPropertyDescriptor(obj, 'foo'); | |
// Definning a setter just to make the property a named accessor property. | |
// (`undefined` is a valid value for the [[Set]] and [[Get]] property attributes) | |
// the getter is correctly `undefined`, the FromPropertyDescriptor | |
// and ToPropertyDescriptor abstract operations are working properly, | |
// (BTW, Chrome 5, 6dev and Safari 5 fail to even create the property ;) | |
print(desc.hasOwnProperty('get') && desc.get === undefined); // 1. true | |
// [[Put]]/[[CanPut]] also work propertly, an asssignment | |
// simply fails silently on non-strict code, [[CanPut]] | |
// just returns `false` (Sect. 8.12.4, Step 2.a.i) | |
obj.foo = 'bar'; | |
// But [[Get]](P) should explicitly return `undefined` if the | |
// getter of an accessor property is `undefined` as described | |
// in the section 8.12.3 (on the wrongly numbered step 12): | |
print(obj.foo); // 2. "reference", no clue about this | |
print(typeof obj.foo); // 3. "undefined" as expected, but: | |
print(obj.foo === undefined); // 4. false | |
try { | |
obj.foo+''; // 5. "TypeError: Bad to string conversation" | |
} catch (e) { // I thought that print made ToString convertion | |
print(e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment