@@ -1135,10 +1135,12 @@ IdlInterface.prototype.test_member_const = function(member)
1135
1135
//@ }
1136
1136
IdlInterface . prototype . test_member_attribute = function ( member )
1137
1137
//@{
1138
- {
1139
- test ( function ( )
1138
+ {
1139
+ var a_test = async_test ( this . name + " interface: attribute " + member . name ) ;
1140
+ a_test . step ( function ( )
1140
1141
{
1141
1142
if ( this . is_callback ( ) && ! this . has_constants ( ) ) {
1143
+ a_test . done ( )
1142
1144
return ;
1143
1145
}
1144
1146
@@ -1151,6 +1153,7 @@ IdlInterface.prototype.test_member_attribute = function(member)
1151
1153
assert_own_property ( self [ this . name ] , member . name ,
1152
1154
"The interface object must have a property " +
1153
1155
format_value ( member . name ) ) ;
1156
+ a_test . done ( ) ;
1154
1157
} else if ( this . is_global ( ) ) {
1155
1158
assert_own_property ( self , member . name ,
1156
1159
"The global object must have a property " +
@@ -1179,23 +1182,42 @@ IdlInterface.prototype.test_member_attribute = function(member)
1179
1182
"Gets on a global should not require an explicit this" ) ;
1180
1183
}
1181
1184
1182
- this . do_interface_attribute_asserts ( self , member ) ;
1185
+ // do_interface_attribute_asserts must be the last thing we do,
1186
+ // since it will call done() on a_test.
1187
+ this . do_interface_attribute_asserts ( self , member , a_test ) ;
1183
1188
} else {
1184
1189
assert_true ( member . name in self [ this . name ] . prototype ,
1185
1190
"The prototype object must have a property " +
1186
1191
format_value ( member . name ) ) ;
1187
1192
1188
1193
if ( ! member . has_extended_attribute ( "LenientThis" ) ) {
1189
- assert_throws ( new TypeError ( ) , function ( ) {
1190
- self [ this . name ] . prototype [ member . name ] ;
1191
- } . bind ( this ) , "getting property on prototype object must throw TypeError" ) ;
1194
+ if ( member . idlType . generic !== "Promise" ) {
1195
+ assert_throws ( new TypeError ( ) , function ( ) {
1196
+ self [ this . name ] . prototype [ member . name ] ;
1197
+ } . bind ( this ) , "getting property on prototype object must throw TypeError" ) ;
1198
+ // do_interface_attribute_asserts must be the last thing we
1199
+ // do, since it will call done() on a_test.
1200
+ this . do_interface_attribute_asserts ( self [ this . name ] . prototype , member , a_test ) ;
1201
+ } else {
1202
+ promise_rejects ( a_test , new TypeError ( ) ,
1203
+ self [ this . name ] . prototype [ member . name ] )
1204
+ . then ( function ( ) {
1205
+ // do_interface_attribute_asserts must be the last
1206
+ // thing we do, since it will call done() on a_test.
1207
+ this . do_interface_attribute_asserts ( self [ this . name ] . prototype ,
1208
+ member , a_test ) ;
1209
+ } . bind ( this ) ) ;
1210
+ }
1192
1211
} else {
1193
1212
assert_equals ( self [ this . name ] . prototype [ member . name ] , undefined ,
1194
1213
"getting property on prototype object must return undefined" ) ;
1214
+ // do_interface_attribute_asserts must be the last thing we do,
1215
+ // since it will call done() on a_test.
1216
+ this . do_interface_attribute_asserts ( self [ this . name ] . prototype , member , a_test ) ;
1195
1217
}
1196
- this . do_interface_attribute_asserts ( self [ this . name ] . prototype , member ) ;
1218
+
1197
1219
}
1198
- } . bind ( this ) , this . name + " interface: attribute " + member . name ) ;
1220
+ } . bind ( this ) ) ;
1199
1221
} ;
1200
1222
1201
1223
//@ }
@@ -1596,12 +1618,13 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
1596
1618
var member = this . members [ i ] ;
1597
1619
if ( member . type == "attribute" && member . isUnforgeable )
1598
1620
{
1599
- test ( function ( )
1600
- {
1621
+ var a_test = async_test ( this . name + " interface: " + desc + ' must have own property "' + member . name + '"' ) ;
1622
+ a_test . step ( function ( ) {
1601
1623
assert_equals ( exception , null , "Unexpected exception when evaluating object" ) ;
1602
1624
assert_equals ( typeof obj , expected_typeof , "wrong typeof object" ) ;
1603
- this . do_interface_attribute_asserts ( obj , member ) ;
1604
- } . bind ( this ) , this . name + " interface: " + desc + ' must have own property "' + member . name + '"' ) ;
1625
+ // Call do_interface_attribute_asserts last, since it will call a_test.done()
1626
+ this . do_interface_attribute_asserts ( obj , member , a_test ) ;
1627
+ } . bind ( this ) ) ;
1605
1628
}
1606
1629
else if ( member . type == "operation" &&
1607
1630
member . name &&
@@ -1720,7 +1743,7 @@ IdlInterface.prototype.has_stringifier = function()
1720
1743
} ;
1721
1744
1722
1745
//@ }
1723
- IdlInterface . prototype . do_interface_attribute_asserts = function ( obj , member )
1746
+ IdlInterface . prototype . do_interface_attribute_asserts = function ( obj , member , a_test )
1724
1747
//@{
1725
1748
{
1726
1749
// This function tests WebIDL as of 2015-01-27.
@@ -1730,6 +1753,8 @@ IdlInterface.prototype.do_interface_attribute_asserts = function(obj, member)
1730
1753
// it is not a global, and the global otherwise, and by test_interface_of()
1731
1754
// with the object as obj.
1732
1755
1756
+ var pendingPromises = [ ] ;
1757
+
1733
1758
// "For each exposed attribute of the interface, whether it was declared on
1734
1759
// the interface itself or one of its consequential interfaces, there MUST
1735
1760
// exist a corresponding property. The characteristics of this property are
@@ -1769,9 +1794,15 @@ IdlInterface.prototype.do_interface_attribute_asserts = function(obj, member)
1769
1794
// attribute, then return undefined.
1770
1795
// "Otherwise, throw a TypeError."
1771
1796
if ( ! member . has_extended_attribute ( "LenientThis" ) ) {
1772
- assert_throws ( new TypeError ( ) , function ( ) {
1773
- desc . get . call ( { } ) ;
1774
- } . bind ( this ) , "calling getter on wrong object type must throw TypeError" ) ;
1797
+ if ( member . idlType . generic !== "Promise" ) {
1798
+ assert_throws ( new TypeError ( ) , function ( ) {
1799
+ desc . get . call ( { } ) ;
1800
+ } . bind ( this ) , "calling getter on wrong object type must throw TypeError" ) ;
1801
+ } else {
1802
+ pendingPromises . push (
1803
+ promise_rejects ( a_test , new TypeError ( ) , desc . get . call ( { } ) ,
1804
+ "calling getter on wrong object type must reject the return promise with TypeError" ) ) ;
1805
+ }
1775
1806
} else {
1776
1807
assert_equals ( desc . get . call ( { } ) , undefined ,
1777
1808
"calling getter on wrong object type must return undefined" ) ;
@@ -1822,6 +1853,8 @@ IdlInterface.prototype.do_interface_attribute_asserts = function(obj, member)
1822
1853
// value 1."
1823
1854
assert_equals ( desc . set . length , 1 , "setter length must be 1" ) ;
1824
1855
}
1856
+
1857
+ Promise . all ( pendingPromises ) . then ( a_test . done . bind ( a_test ) ) ;
1825
1858
}
1826
1859
//@ }
1827
1860
0 commit comments