Skip to content

[BUG]ZIP file containing binaries will not be downloaded complete with WebKit #6286

@RFC2109

Description

@RFC2109

Context:

  • Playwright Version: [email protected]
  • Operating System: Windows
  • Node.js version: v14.15.1
  • Browser: Chromium, Firefox, WebKit
  • Extra: [any specific details about your environment]

Code Snippet

 it.only('should download binary.zip complete', async ({browser, server, browserName}) => {
    const page = await browser.newPage({ acceptDownloads: true });
    await page.goto(server.PREFIX + '/empty.html');
    await page.setContent(`<a href="${server.PREFIX}/binary.zip" download="binary.zip">download</a>`);
    const [ download ] = await Promise.all([
      page.waitForEvent('download'),
      page.click('a')
    ]);
    const downloadPath = await download.path();
    const downloadFileSize = fs.statSync(downloadPath).size;
    const originalFileSize = fs.statSync(path.join(__dirname, 'assets','binary.zip')).size;
    expect(downloadFileSize).toEqual(originalFileSize);
    await page.close();
  });

You can generate the zip file with the following command

head -c 1m </dev/urandom >binary.dat
zip -q  binary.zip binary.dat

Describe the bug

the result

npm run test

> [email protected] test E:\projects\playwright
> folio --config=tests/config/default.config.ts


Running 3 tests using 2 workers
  1) download.spec.ts:65:6 › [webkit] download event should download binary.zip complete ===========

    Error: expect(received).toEqual(expected) // deep equality

    Expected: 1048906
    Received: 524

      74 |     const downloadFileSize = fs.statSync(downloadPath).size;
      75 |     const originalFileSize = fs.statSync(path.join(__dirname, 'assets','binary.zip')).size;
    > 76 |     expect(downloadFileSize).toEqual(originalFileSize);
         |                              ^
      77 |     await page.close();
      78 |   });
      79 | 

        at Spec.fn (E:\projects\playwright\tests\download.spec.ts:76:30)
        at WorkerRunner._runTestWithBeforeHooks (E:\projects\playwright\node_modules\folio\out\workerRunner.js:299:13)

  2 passed (33s)
  1 failed      
    download.spec.ts:65:6 › [webkit] download event should download binary.zip complete ============

  Slow test: download.spec.ts (19s)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions