Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix: support blob downloads (#1954)

Yury Semikhatsky7c9762fae981
diff --git a/package.json b/package.json
index d35bc8688d..ef515b9ad3 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/webkit/wkBrowser.ts b/src/webkit/wkBrowser.ts
index f5355d419f..1f8d68c577 100644
--- a/src/webkit/wkBrowser.ts
+++ b/src/webkit/wkBrowser.ts
@@ -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);
}
diff --git a/test/download.spec.js b/test/download.spec.js
index f160ec6a94..f69d479fe4 100644
--- a/test/download.spec.js
+++ b/test/download.spec.js
@@ -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) => {
@@ -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 => {