From 7c9762fae9811fa25874d4135ae9f2908308aa57 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 23 Apr 2020 20:04:19 -0700 Subject: [PATCH] fix: support blob downloads (#1954) --- package.json | 4 ++-- src/webkit/wkBrowser.ts | 8 ++++++++ test/download.spec.js | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d35bc8688d216..ef515b9ad3d26 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 f5355d419f564..1f8d68c577e9a 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 f160ec6a949b0..f69d479fe465d 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 => {