@@ -13,8 +13,8 @@ import { IntakeRegistry } from './intakeRegistry'
1313import { flushEvents } from './flushEvents'
1414import type { Servers } from './httpServers'
1515import { getTestServers , waitForServersIdle } from './httpServers'
16- import type { SetupFactory , SetupOptions , WorkerImplementationFactory } from './pageSetups'
17- import { workerSetup , html , DEFAULT_SETUPS , npmSetup , reactSetup } from './pageSetups'
16+ import type { SetupFactory , SetupOptions , WorkerOptions } from './pageSetups'
17+ import { buildWorkerScript , html , DEFAULT_SETUPS , npmSetup , reactSetup } from './pageSetups'
1818import { createIntakeServerApp } from './serverApps/intake'
1919import { createMockServerApp } from './serverApps/mock'
2020import type { Extension } from './createExtension'
@@ -59,7 +59,7 @@ class TestBuilder {
5959 logsConfiguration ?: LogsInitConfiguration
6060 } = { }
6161 private hostName ?: string
62- private workerImplementationFactory ?: WorkerImplementationFactory
62+ private workerOptions ?: WorkerOptions
6363
6464 constructor ( private title : string ) { }
6565
@@ -131,15 +131,15 @@ class TestBuilder {
131131 return this
132132 }
133133
134- withWorker ( implementation : WorkerImplementationFactory [ 'implementation '] , options : RegistrationOptions = { } ) {
135- this . workerImplementationFactory = { ...options , implementation }
134+ withWorker ( testCase : WorkerOptions [ 'testCase '] , registrationOptions : RegistrationOptions = { } ) {
135+ this . workerOptions = { ...registrationOptions , testCase }
136136
137137 // Service workers require HTTPS or localhost due to browser security restrictions
138138 this . withHostName ( 'localhost' )
139139 this . withBody ( html `
140140 < script >
141141 if ( ! window . myServiceWorker && 'serviceWorker' in navigator ) {
142- navigator . serviceWorker . register ( '/sw.js' , ${ JSON . stringify ( options ) } ) . then ( ( registration ) => {
142+ navigator . serviceWorker . register ( '/sw.js' , ${ JSON . stringify ( registrationOptions ) } ) . then ( ( registration ) => {
143143 window . myServiceWorker = registration
144144 } )
145145 }
@@ -173,7 +173,7 @@ class TestBuilder {
173173 testFixture : this . testFixture ,
174174 extension : this . extension ,
175175 hostName : this . hostName ,
176- workerImplementationFactory : this . workerImplementationFactory ,
176+ workerOptions : this . workerOptions ,
177177 }
178178
179179 if ( this . alsoRunWithRumSlim ) {
@@ -253,7 +253,7 @@ function declareTest(title: string, setupOptions: SetupOptions, factory: SetupFa
253253 servers . base . bindServerApp (
254254 createMockServerApp ( servers , setup , {
255255 remoteConfiguration : setupOptions . remoteConfiguration ,
256- workerImplementation : setupOptions . workerImplementationFactory && workerSetup ( setupOptions , servers ) ,
256+ workerScript : buildWorkerScript ( setupOptions , servers ) ,
257257 } )
258258 )
259259 servers . crossOrigin . bindServerApp ( createMockServerApp ( servers , setup ) )
0 commit comments