Skip to content

Commit 7c9762f

Browse files
authored
fix: support blob downloads (#1954)
1 parent 21dc346 commit 7c9762f

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"main": "index.js",
1010
"playwright": {
1111
"chromium_revision": "759546",
12-
"firefox_revision": "1085",
13-
"webkit_revision": "1208"
12+
"firefox_revision": "1086",
13+
"webkit_revision": "1209"
1414
},
1515
"scripts": {
1616
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",

src/webkit/wkBrowser.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ export class WKBrowser extends BrowserBase {
9999
const page = this._wkPages.get(payload.pageProxyId);
100100
if (!page)
101101
return;
102+
const frameManager = page._page._frameManager;
103+
const frame = frameManager.frame(payload.frameId);
104+
if (frame) {
105+
// In some cases, e.g. blob url download, we receive only frameScheduledNavigation
106+
// but no signals that the navigation was canceled and replaced by download. Fix it
107+
// here by simulating cancelled provisional load which matches downloads from network.
108+
frameManager.provisionalLoadFailed(frame, '', 'Download is starting');
109+
}
102110
this._downloadCreated(page._page, payload.uuid, payload.url);
103111
}
104112

test/download.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
const fs = require('fs');
1818
const path = require('path');
19-
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
19+
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
2020

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

0 commit comments

Comments
 (0)