@@ -18,7 +18,6 @@ import { browserTest as it, expect } from './config/browserTest';
18
18
import fs from 'fs' ;
19
19
import path from 'path' ;
20
20
import crypto from 'crypto' ;
21
- import { chromiumVersionLessThan } from './config/utils' ;
22
21
23
22
it . describe ( 'download event' , ( ) => {
24
23
it . beforeEach ( async ( { server} ) => {
@@ -272,12 +271,7 @@ it.describe('download event', () => {
272
271
await page . close ( ) ;
273
272
} ) ;
274
273
275
- it ( 'should report new window downloads' , async ( { browser, server, browserName, headless} ) => {
276
- it . fixme ( browserName === 'chromium' && ! headless ) ;
277
-
278
- // TODO: - the test fails in headed Chromium as the popup page gets closed along
279
- // with the session before download completed event arrives.
280
- // - WebKit doesn't close the popup page
274
+ it ( 'should report new window downloads' , async ( { browser, server} ) => {
281
275
const page = await browser . newPage ( { acceptDownloads : true } ) ;
282
276
await page . setContent ( `<a target=_blank href="${ server . PREFIX } /download">download</a>` ) ;
283
277
const [ download ] = await Promise . all ( [
@@ -360,7 +354,7 @@ it.describe('download event', () => {
360
354
expect ( fs . existsSync ( path . join ( path1 , '..' ) ) ) . toBeFalsy ( ) ;
361
355
} ) ;
362
356
363
- it ( 'should close the context without awaiting the failed download' , async ( { browser, server, httpsServer, browserName, browserVersion } , testInfo ) => {
357
+ it ( 'should close the context without awaiting the failed download' , async ( { browser, server, httpsServer, browserName, headless } , testInfo ) => {
364
358
it . skip ( browserName !== 'chromium' , 'Only Chromium downloads on alt-click' ) ;
365
359
366
360
const page = await browser . newPage ( { acceptDownloads : true } ) ;
@@ -378,13 +372,10 @@ it.describe('download event', () => {
378
372
page . context ( ) . close ( ) ,
379
373
] ) ;
380
374
expect ( downloadPath ) . toBe ( null ) ;
381
- if ( chromiumVersionLessThan ( browserVersion , '91.0.4472.0' ) )
382
- expect ( saveError . message ) . toContain ( 'File deleted upon browser context closure.' ) ;
383
- else
384
- expect ( saveError . message ) . toContain ( 'File not found on disk. Check download.failure() for details.' ) ;
375
+ expect ( saveError . message ) . toContain ( 'File not found on disk. Check download.failure() for details.' ) ;
385
376
} ) ;
386
377
387
- it ( 'should close the context without awaiting the download' , async ( { browser, server, browserName, platform} , testInfo ) => {
378
+ it ( 'should close the context without awaiting the download' , async ( { browser, server, browserName, platform, headless } , testInfo ) => {
388
379
it . skip ( browserName === 'webkit' && platform === 'linux' , 'WebKit on linux does not convert to the download immediately upon receiving headers' ) ;
389
380
390
381
server . setRoute ( '/downloadStall' , ( req , res ) => {
@@ -408,7 +399,10 @@ it.describe('download event', () => {
408
399
page . context ( ) . close ( ) ,
409
400
] ) ;
410
401
expect ( downloadPath ) . toBe ( null ) ;
411
- expect ( saveError . message ) . toContain ( 'File deleted upon browser context closure.' ) ;
402
+ if ( browserName === 'chromium' && headless )
403
+ expect ( saveError . message ) . toContain ( '.saveAs: canceled' ) ;
404
+ else
405
+ expect ( saveError . message ) . toContain ( 'File deleted upon browser context closure.' ) ;
412
406
} ) ;
413
407
414
408
it ( 'should throw if browser dies' , async ( { server, browserType, browserName, browserOptions, platform} , testInfo ) => {
0 commit comments