From: kangax on 16 Jul 2010 19:44 On 7/16/10 7:31 PM, Thomas 'PointedEars' Lahn wrote: > kangax wrote: > >> Thomas 'PointedEars' Lahn wrote: >>> RobG wrote: >> [...] >>> ECMAScript Edition 5 specifies the Object.defineProperty() and >>> Object.defineProperties() methods to define a non-enumerable property; >>> they are implemented in Google V8 since version 2.1 (Chrome 5.0.342) and >>> Apple JavaScriptCore since version 533.16 (Safari 4.0.4). >> ^^^^^ >> >> That should be Safari 5, not 4.0.4 (build number is right, though). >> >> Also see<http://kangax.github.com/es5-compat-table/> > > No. As a matter of fact, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) > AppleWebKit/533.16 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10" > supports both Object.defineProperty() and Object.defineProperties(). Interesting... My Safari 4.0.5 [1] on Mac OS X has neither `Object.defineProperty` nor `Object.defineProperties`; Safari 5 [2] has both. [1] Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7 [2] Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 I don't understand how your 4.0.4 ended up with 533.x webkit build. Can anyone else confirm? -- kangax
From: Thomas 'PointedEars' Lahn on 16 Jul 2010 20:31 kangax wrote: > Thomas 'PointedEars' Lahn wrote: >> kangax wrote: >>> Thomas 'PointedEars' Lahn wrote: >>>> RobG wrote: >>> [...] >>>> ECMAScript Edition 5 specifies the Object.defineProperty() and >>>> Object.defineProperties() methods to define a non-enumerable property; >>>> they are implemented in Google V8 since version 2.1 (Chrome 5.0.342) >>>> and Apple JavaScriptCore since version 533.16 (Safari 4.0.4). >>> ^^^^^ >>> >>> That should be Safari 5, not 4.0.4 (build number is right, though). >>> >>> Also see<http://kangax.github.com/es5-compat-table/> >> >> No. As a matter of fact, "Mozilla/5.0 (Windows; U; Windows NT 5.1; >> en-US) AppleWebKit/533.16 (KHTML, like Gecko) Version/4.0.4 >> Safari/531.21.10" supports both Object.defineProperty() and >> Object.defineProperties(). > > Interesting... > > My Safari 4.0.5 [1] on Mac OS X has neither `Object.defineProperty` nor > `Object.defineProperties`; Safari 5 [2] has both. > > [1] Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) > AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7 > > [2] Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) > AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 > > I don't understand how your 4.0.4 ended up with 533.x webkit build. JFTR: I had the older version before, but thought it was an error to be corrected. (So I did. D'oh.) Now that you pointed out the version mismatch too, I came to suspect that it was because I had installed Safari 5.0 in the same Wine subtree. Since I suddenly had problems running any Safari browser tonight (which might have to do with a winecfg on the wrong subtree), I have just reinstalled version 4.0.4 again into a clean subtree, and you are right: "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10" does not support Object.defineProperty() or Object.defineProperties(). (See the tests below.) Thank you. (Note to self: Always install a Safari version into its own Wine subtree.) It would appear that I have to double-check all JavaScriptCore test results for the ECMAScript Support Matrix¹ so far. BTW, those are tests for functionality, and will be available with the next revision of the Matrix. As a preview, for those two methods they currently are (PHP code cleaned, pretty-printed): var o = new Object(), b = isMethod(Object, 'defineProperty') && Object.defineProperty(o, 'a', { value: {b: 'c'}, writable: false, configurable: false, enumerable: false }) && (typeof o.a == 'object') && o.a && (o.a.b == 'c') && (o.a = 42) && (o.a != 42); delete o.a; b = b && (typeof o.a != 'undefined'); if (b) { var found = false; for (var p in o) { if (p == 'a') { found = true; break; } } } b && !found; and var o = new Object(), b = isMethod(Object, 'defineProperties') && Object.defineProperties(o, { a: { value: {b: 'c'}, writable: false, configurable: false, enumerable: false }, b: { value: {c: 'd'}, writable: false, configurable: false, enumerable: false } }) && (typeof o.a == 'object') && o.a && (o.a.b == 'c') && (o.a = 42) && (o.a != 42) && (typeof o.b == 'object') && o.b && (o.b.c == 'd') && (o.b = 42) && (o.b != 42); delete o.a; delete o.b; b = b && (typeof o.a != 'undefined') && (typeof o.b != 'undefined'); if (b) { var found = false; for (var p in o) { if (p == 'a' || p == 'b') { found = true; break; } } } b && !found; The result of either program determines if the corresponding feature is considered to be supported by an implementation. A true-value indicates that it is supported, a false-value that it is not. AFAICS, the tests are only incomplete in that they do not test that the attributes of a property that does not have the [[Configurable]] attribute set must not be possible to redefine with Object.defineProperty() (except of its value). Suggestions welcome. PointedEars ___________ ¹ <http://PointedEars.de/es-matrix> -- var bugRiddenCrashPronePieceOfJunk = ( navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1 ) // Plone, register_function.js:16
From: kangax on 18 Jul 2010 08:55 On 7/16/10 8:31 PM, Thomas 'PointedEars' Lahn wrote: > kangax wrote: [...] >> My Safari 4.0.5 [1] on Mac OS X has neither `Object.defineProperty` nor >> `Object.defineProperties`; Safari 5 [2] has both. >> >> [1] Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) >> AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7 >> >> [2] Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) >> AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 >> >> I don't understand how your 4.0.4 ended up with 533.x webkit build. > > JFTR: I had the older version before, but thought it was an error to be > corrected. (So I did. D'oh.) > > Now that you pointed out the version mismatch too, I came to suspect that it > was because I had installed Safari 5.0 in the same Wine subtree. Since I > suddenly had problems running any Safari browser tonight (which might have > to do with a winecfg on the wrong subtree), I have just reinstalled version > 4.0.4 again into a clean subtree, and you are right: > > "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.21.8 > (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10" does not support > Object.defineProperty() or Object.defineProperties(). (See the tests > below.) > > Thank you. (Note to self: Always install a Safari version into its own Wine > subtree.) No problem. You got me worried there for a bit. > > It would appear that I have to double-check all JavaScriptCore test results > for the ECMAScript Support Matrix¹ so far. BTW, those are tests for > functionality, and will be available with the next revision of the Matrix. > As a preview, for those two methods they currently are (PHP code cleaned, > pretty-printed): > > var o = new Object(), > b = isMethod(Object, 'defineProperty') > && Object.defineProperty(o, 'a', { > value: {b: 'c'}, > writable: false, ^^^^^ > configurable: false, ^^^^^ > enumerable: false ^^^^^ > }) Technically, those are default values, so explicitly setting them is redundant (although adds to clarity). > && (typeof o.a == 'object')&& o.a > && (o.a.b == 'c') > && (o.a = 42)&& (o.a != 42); > delete o.a; > b = b&& (typeof o.a != 'undefined'); > if (b) > { > var found = false; > for (var p in o) > { > if (p == 'a') Maybe add `hasOwnProperty` check too? > { > found = true; > break; > } > } > } > b&& !found; > [snip defineProperties test] > > The result of either program determines if the corresponding feature is > considered to be supported by an implementation. A true-value indicates > that it is supported, a false-value that it is not. > > AFAICS, the tests are only incomplete in that they do not test that the > attributes of a property that does not have the [[Configurable]] attribute > set must not be possible to redefine with Object.defineProperty() (except of > its value). Well if we're talking about full conformance, then there are also no tests for `Object.defineProperty` throwing TypeError when first argument is not an object; no test for getters/setters (i.e. "get" and "set" properties in object corresponding to property descriptor); no test for ToPropertyDescriptor which is invoked during `defineProperty` and is, for example, responsible for throwing TypeError when you pass an object that can not be either data descriptor or accessor one: Object.defineProperty({}, 'x', { value: 'y', set: function(){} }); // or Object.defineProperty({}, 'x', { get: function(){}, writable: true }); But then it might make sense to just look into relevant section of ES5 test suite on codeplex (https://es5conform.codeplex.com/). [...] -- kangax
First
|
Prev
|
Pages: 1 2 Prev: Setter/Getter in module pattern? Next: FAQ Topic - What is JScript? (2010-07-16) |