fix(chromium): support main resource request interception for popups (#1449)

This commit is contained in:
Yury Semikhatsky 2020-03-20 16:13:42 -07:00 committed by GitHub
parent 053bab1afd
commit bae56ea9d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import * as network from '../network';
import * as frames from '../frames';
import * as platform from '../platform';
import { Credentials } from '../types';
import { CRTarget } from './crTarget';
export class CRNetworkManager {
private _client: CRSession;
@ -165,7 +166,16 @@ export class CRNetworkManager {
redirectedFrom = request.request;
}
}
const frame = event.frameId ? this._page._frameManager.frame(event.frameId) : workerFrame;
let frame = event.frameId ? this._page._frameManager.frame(event.frameId) : workerFrame;
// Check if it's main resource request interception (targetId === main frame id).
if (!frame && interceptionId && event.frameId === CRTarget.fromPage(this._page)._targetId) {
// Main resource request for the page is being intercepted so the Frame is not created
// yet. Precreate it here for the purposes of request interception. It will be updated
// later as soon as the request contnues and we receive frame tree from the page.
frame = this._page._frameManager.frameAttached(event.frameId, null);
}
if (!frame) {
if (interceptionId)
this._client.send('Fetch.continueRequest', { requestId: interceptionId }).catch(debugError);

View File

@ -39,7 +39,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE
expect(userAgent).toBe('hey');
expect(request.headers['user-agent']).toBe('hey');
});
it.fail(CHROMIUM || FFOX)('should respect routes from browser context', async function({browser, server}) {
it.fail(FFOX)('should respect routes from browser context', async function({browser, server}) {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);