@@ -236,7 +236,11 @@ IdlArray.prototype.is_excluded_by_options = function (name, options)
236236
237237IdlArray . prototype . add_dependency_idls = function ( raw_idls , options )
238238{
239- const parsed_idls = WebIDL2 . parse ( raw_idls ) ;
239+ return this . add_dependency_idls_parsed ( WebIDL2 . parse ( raw_idls ) , options ) ;
240+ } ;
241+
242+ IdlArray . prototype . add_dependency_idls_parsed = function ( parsed_idls , options )
243+ {
240244 const new_options = { only : [ ] }
241245
242246 const all_deps = new Set ( ) ;
@@ -3288,15 +3292,24 @@ function idl_test(srcs, deps, idl_setup_func) {
32883292 deps = ( deps instanceof Array ) ? deps : [ deps ] || [ ] ;
32893293 var setup_error = null ;
32903294 return Promise . all (
3291- srcs . concat ( deps ) . map ( function ( spec ) {
3292- return fetch_spec ( spec ) ;
3293- } ) )
3294- . then ( function ( idls ) {
3295+ srcs . concat ( deps ) . map ( fetch_spec ) )
3296+ . then ( function ( results ) {
3297+ const astArray = results . map ( result =>
3298+ WebIDL2 . parse ( result . idl , { sourceName : result . spec } )
3299+ ) ;
3300+ const validations = WebIDL2 . validate ( astArray ) ;
3301+ if ( validations . length ) {
3302+ const message = validations . join ( "\n\n" ) ;
3303+ throw new Error ( message ) ;
3304+ }
3305+ return astArray ;
3306+ } )
3307+ . then ( function ( astArray ) {
32953308 for ( var i = 0 ; i < srcs . length ; i ++ ) {
3296- idl_array . add_idls ( idls [ i ] ) ;
3309+ idl_array . internal_add_idls ( astArray [ i ] ) ;
32973310 }
32983311 for ( var i = srcs . length ; i < srcs . length + deps . length ; i ++ ) {
3299- idl_array . add_dependency_idls ( idls [ i ] ) ;
3312+ idl_array . add_dependency_idls_parsed ( astArray [ i ] ) ;
33003313 }
33013314 } )
33023315 . then ( function ( ) {
@@ -3331,6 +3344,6 @@ function fetch_spec(spec) {
33313344 throw new IdlHarnessError ( "Error fetching " + url + "." ) ;
33323345 }
33333346 return r . text ( ) ;
3334- } ) ;
3347+ } ) . then ( idl => ( { spec , idl } ) ) ;
33353348}
33363349// vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@ } foldmethod=marker:
0 commit comments