@@ -1142,41 +1142,46 @@ IdlInterface.prototype.test_self = function()
1142
1142
}
1143
1143
} . bind ( this ) , this . name + " interface: existence and properties of interface object" ) ;
1144
1144
1145
- if ( this . has_extended_attribute ( "Constructor" ) )
1146
- {
1147
- test ( function ( )
1148
- {
1145
+ if ( ! this . is_callback ( ) ) {
1146
+ test ( function ( ) {
1147
+ // This function tests WebIDL as of 2013-08-25.
1148
+ // http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call
1149
+
1149
1150
assert_own_property ( window , this . name ,
1150
1151
"window does not have own property " + format_value ( this . name ) ) ;
1151
1152
1152
- // "Interface objects for interfaces declared with a [Constructor]
1153
- // extended attribute must have a property named “length” with
1154
- // attributes { [[Writable]]: false, [[Enumerable]]: false,
1155
- // [[Configurable]]: false } whose value is a Number determined as
1156
- // follows: . . .
1157
- // "Return the length of the shortest argument list of the entries
1158
- // in S."
1159
- // TODO: Variadic constructors. Should generalize this so that it
1160
- // works for testing operation length too (currently we just don't
1161
- // support multiple operations with the same identifier).
1162
- var expected_length = this . extAttrs
1163
- . filter ( function ( attr ) { return attr . name == "Constructor" ; } )
1164
- . map ( function ( attr ) {
1165
- return attr . arguments ? attr . arguments . filter (
1166
- function ( arg ) {
1167
- return ! arg . optional ;
1168
- } ) . length : 0 ;
1169
- } )
1170
- . reduce ( function ( m , n ) { return Math . min ( m , n ) ; } ) ;
1153
+ // "Interface objects for non-callback interfaces MUST have a
1154
+ // property named “length” with attributes { [[Writable]]: false,
1155
+ // [[Enumerable]]: false, [[Configurable]]: false } whose value is
1156
+ // a Number."
1171
1157
assert_own_property ( window [ this . name ] , "length" ) ;
1172
- assert_equals ( window [ this . name ] . length , expected_length , "wrong value for " + this . name + ".length" ) ;
1173
1158
var desc = Object . getOwnPropertyDescriptor ( window [ this . name ] , "length" ) ;
1174
1159
assert_false ( "get" in desc , this . name + ".length has getter" ) ;
1175
1160
assert_false ( "set" in desc , this . name + ".length has setter" ) ;
1176
1161
assert_false ( desc . writable , this . name + ".length is writable" ) ;
1177
1162
assert_false ( desc . enumerable , this . name + ".length is enumerable" ) ;
1178
1163
assert_false ( desc . configurable , this . name + ".length is configurable" ) ;
1179
- } . bind ( this ) , this . name + " interface constructor" ) ;
1164
+
1165
+ var constructors = this . extAttrs
1166
+ . filter ( function ( attr ) { return attr . name == "Constructor" ; } ) ;
1167
+ var expected_length ;
1168
+ if ( ! constructors . length ) {
1169
+ // "If the [Constructor] extended attribute, does not appear on
1170
+ // the interface definition, then the value is 0."
1171
+ expected_length = 0 ;
1172
+ } else {
1173
+ // "Otherwise, the value is determined as follows: . . .
1174
+ // "Return the length of the shortest argument list of the
1175
+ // entries in S."
1176
+ expected_length = constructors . map ( function ( attr ) {
1177
+ return attr . arguments ? attr . arguments . filter ( function ( arg ) {
1178
+ return ! arg . optional ;
1179
+ } ) . length : 0 ;
1180
+ } )
1181
+ . reduce ( function ( m , n ) { return Math . min ( m , n ) ; } ) ;
1182
+ }
1183
+ assert_equals ( window [ this . name ] . length , expected_length , "wrong value for " + this . name + ".length" ) ;
1184
+ } . bind ( this ) , this . name + " interface object length" ) ;
1180
1185
}
1181
1186
1182
1187
// TODO: Test named constructors if I find any interfaces that have them.
0 commit comments