license import { zoneSymbol } from '../../lib/common/utils' ; import { asyncTest , ifEnvSupports } from '../test-util' ; function workerSupport ( ) { const Worker = ( window as any ) [ 'Worker' ] ; if ( ! Worker ) { return false ; } const desc = Object . getOwnPropertyDescriptor ( Worker . prototype , 'onmessage' ) ; if ( ! desc || ! desc . configurable ) { return false ; } return true ; } ( workerSupport as any ) . message = 'Worker Support' ; describe ( 'Worker API' , ifEnvSupports ( workerSupport , function ( ) { it ( 'Worker API should be patched by Zone' , asyncTest ( ( done ) => { const zone = Zone . current . fork ( { name : 'worker' } ) ; zone . run ( ( ) => { const worker = new Worker ( '/base/test/assets/worker.js' ) ; worker . onmessage = function ( evt ) { expect ( evt . data ) . toEqual ( 'worker' ) ; expect ( Zone . current . name ) . toEqual ( 'worker' ) ; done ( ) ; } ; } ) ; } , Zone . root ) ) ; } ) ) ;