Skip to content

Commit

Permalink
fix: support blob downloads (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s authored Apr 24, 2020
1 parent 21dc346 commit 7c9762f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "index.js",
"playwright": {
"chromium_revision": "759546",
"firefox_revision": "1085",
"webkit_revision": "1208"
"firefox_revision": "1086",
"webkit_revision": "1209"
},
"scripts": {
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",
Expand Down
8 changes: 8 additions & 0 deletions src/webkit/wkBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ export class WKBrowser extends BrowserBase {
const page = this._wkPages.get(payload.pageProxyId);
if (!page)
return;
const frameManager = page._page._frameManager;
const frame = frameManager.frame(payload.frameId);
if (frame) {
// In some cases, e.g. blob url download, we receive only frameScheduledNavigation
// but no signals that the navigation was canceled and replaced by download. Fix it
// here by simulating cancelled provisional load which matches downloads from network.
frameManager.provisionalLoadFailed(frame, '', 'Download is starting');
}
this._downloadCreated(page._page, payload.uuid, payload.url);
}

Expand Down
4 changes: 2 additions & 2 deletions test/download.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const fs = require('fs');
const path = require('path');
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);

describe('Download', function() {
beforeEach(async(state) => {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('Download', function() {
expect(fs.readFileSync(path).toString()).toBe('Hello world');
await page.close();
})
it.fail(FFOX || WEBKIT)(`should report download path within page.on('download', …) handler for Blobs`, async({browser, server}) => {
it.fail(WEBKIT && MAC)(`should report download path within page.on('download', …) handler for Blobs`, async({browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
const onDownloadPath = new Promise((res) => {
page.on('download', dl => {
Expand Down

0 comments on commit 7c9762f

Please sign in to comment.