fix: support blob downloads (#1954)
This commit is contained in:
parent
21dc346b16
commit
7c9762fae9
|
|
@ -9,8 +9,8 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"playwright": {
|
"playwright": {
|
||||||
"chromium_revision": "759546",
|
"chromium_revision": "759546",
|
||||||
"firefox_revision": "1085",
|
"firefox_revision": "1086",
|
||||||
"webkit_revision": "1208"
|
"webkit_revision": "1209"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",
|
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,14 @@ export class WKBrowser extends BrowserBase {
|
||||||
const page = this._wkPages.get(payload.pageProxyId);
|
const page = this._wkPages.get(payload.pageProxyId);
|
||||||
if (!page)
|
if (!page)
|
||||||
return;
|
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);
|
this._downloadCreated(page._page, payload.uuid, payload.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
|
||||||
|
|
||||||
describe('Download', function() {
|
describe('Download', function() {
|
||||||
beforeEach(async(state) => {
|
beforeEach(async(state) => {
|
||||||
|
|
@ -83,7 +83,7 @@ describe('Download', function() {
|
||||||
expect(fs.readFileSync(path).toString()).toBe('Hello world');
|
expect(fs.readFileSync(path).toString()).toBe('Hello world');
|
||||||
await page.close();
|
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 page = await browser.newPage({ acceptDownloads: true });
|
||||||
const onDownloadPath = new Promise((res) => {
|
const onDownloadPath = new Promise((res) => {
|
||||||
page.on('download', dl => {
|
page.on('download', dl => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue