@@ -186,7 +186,8 @@ var maxUnsigned = 4294967295;
186
186
*
187
187
* "jsType": What typeof idlObj[idlName] is supposed to be.
188
188
* "defaultVal": The default value to be returned if the attribute is not
189
- * present and no default is specifically set for this attribute.
189
+ * present and no default is specifically set for this attribute. If
190
+ * it is an array then any value in the array is acceptable.
190
191
* "domTests": What values to test with setAttribute().
191
192
* "domExpected": What values to expect with IDL get after setAttribute().
192
193
* Defaults to the same as domTests.
@@ -761,7 +762,12 @@ ReflectionTests.reflects = function(data, idlName, idlObj, domName, domObj) {
761
762
}
762
763
if ( ! data . customGetter && ( defaultVal !== null || data . isNullable ) ) {
763
764
ReflectionHarness . test ( function ( ) {
765
+ // Tests can pass an array of acceptable values
766
+ if ( Array . isArray ( defaultVal ) ) {
767
+ ReflectionHarness . assertInArray ( idlObj [ idlName ] , defaultVal ) ;
768
+ } else {
764
769
ReflectionHarness . assertEquals ( idlObj [ idlName ] , defaultVal ) ;
770
+ }
765
771
} , "IDL get with DOM attribute unset" ) ;
766
772
}
767
773
@@ -947,8 +953,14 @@ ReflectionTests.reflects = function(data, idlName, idlObj, domName, domObj) {
947
953
domObj . setAttribute ( domName , domTests [ i ] ) ;
948
954
ReflectionHarness . assertEquals ( domObj . getAttribute ( domName ) ,
949
955
String ( domTests [ i ] ) , "getAttribute()" ) ;
950
- ReflectionHarness . assertEquals ( idlObj [ idlName ] , domExpected [ i ] ,
951
- "IDL get" ) ;
956
+ // Tests can pass an array of acceptable values
957
+ if ( Array . isArray ( domExpected [ i ] ) ) {
958
+ ReflectionHarness . assertInArray ( idlObj [ idlName ] , domExpected [ i ] ,
959
+ "IDL get" ) ;
960
+ } else {
961
+ ReflectionHarness . assertEquals ( idlObj [ idlName ] , domExpected [ i ] ,
962
+ "IDL get" ) ;
963
+ }
952
964
} , "setAttribute() to " + ReflectionHarness . stringRep ( domTests [ i ] ) ) ;
953
965
}
954
966
@@ -986,7 +998,14 @@ ReflectionTests.reflects = function(data, idlName, idlObj, domName, domObj) {
986
998
ReflectionHarness . assertEquals ( domObj . getAttribute ( domName ) , expected ,
987
999
"getAttribute()" ) ;
988
1000
}
989
- if ( idlIdlExpected [ i ] !== null || data . isNullable ) {
1001
+ // Ensure enumerated attributes never reflect in their non-canonical representations
1002
+ if ( data . type == "enum" && data . nonCanon [ idlObj [ idlName ] ] ) {
1003
+ ReflectionHarness . assertEquals ( idlObj [ idlName ] , data . nonCanon [ idlObj [ idlName ] ] , "IDL get canonical" ) ;
1004
+ }
1005
+ // Tests can pass an array of acceptable values
1006
+ if ( Array . isArray ( idlIdlExpected [ i ] ) ) {
1007
+ ReflectionHarness . assertInArray ( idlObj [ idlName ] , idlIdlExpected [ i ] , "IDL get" ) ;
1008
+ } else if ( idlIdlExpected [ i ] !== null || data . isNullable ) {
990
1009
ReflectionHarness . assertEquals ( idlObj [ idlName ] , idlIdlExpected [ i ] , "IDL get" ) ;
991
1010
}
992
1011
}
0 commit comments