@@ -21,9 +21,13 @@ const PAGES: Record<string, string> = {
2121 '/login' : '<!doctype html><html><body><h1 id="login">fixture-login</h1></body></html>' ,
2222}
2323
24+ /** `User-Agent` of every request the fixture origin has served, in arrival order. */
25+ const requestUserAgents : string [ ] = [ ]
26+
2427function startFixtureServer ( ) : Promise < { server : Server ; origin : string } > {
2528 return new Promise ( ( resolvePromise ) => {
2629 const server = createServer ( ( request , response ) => {
30+ requestUserAgents . push ( request . headers [ 'user-agent' ] ?? '' )
2731 const path = new URL ( request . url ?? '/' , 'http://127.0.0.1' ) . pathname
2832 const sessionCookie = request . headers . cookie
2933 ?. split ( ';' )
@@ -85,6 +89,21 @@ test.describe('desktop shell smoke', () => {
8589 expect ( window . url ( ) ) . toBe ( `${ origin } /home` )
8690 } )
8791
92+ test ( 'presents one stock Chrome user agent on every request from the first load' , async ( ) => {
93+ requestUserAgents . length = 0
94+ app = await launchApp ( origin )
95+ const window = await app . firstWindow ( )
96+ await expect ( window . locator ( '#app' ) ) . toHaveText ( 'fixture-app' )
97+ await window . evaluate ( ( ) => fetch ( '/home' ) . then ( ( response ) => response . text ( ) ) )
98+
99+ const pageUserAgent = await window . evaluate ( ( ) => navigator . userAgent )
100+ expect ( pageUserAgent ) . toMatch (
101+ / ^ M o z i l l a \/ 5 \. 0 \( .+ \) A p p l e W e b K i t \/ 5 3 7 \. 3 6 \( K H T M L , l i k e G e c k o \) C h r o m e \/ \d + \. 0 \. 0 \. 0 S a f a r i \/ 5 3 7 \. 3 6 $ /
102+ )
103+ expect ( requestUserAgents . length ) . toBeGreaterThanOrEqual ( 2 )
104+ expect ( new Set ( requestUserAgents ) ) . toEqual ( new Set ( [ pageUserAgent ] ) )
105+ } )
106+
88107 test ( 'internal window.open creates an independent full Sim window' , async ( ) => {
89108 app = await launchApp ( origin )
90109 const window = await app . firstWindow ( )
0 commit comments