fix(webkit): filechooer interception after process swap (#11415)

This commit is contained in:
Yury Semikhatsky 2022-01-14 17:33:07 -08:00 committed by GitHub
parent 26da1cc2cd
commit cfb86a74fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -75,6 +75,7 @@ export class WKPage implements PageDelegate {
private _nextWindowOpenPopupFeatures?: string[];
private _recordingVideoFile: string | null = null;
private _screencastGeneration: number = 0;
private _interceptingFileChooser = false;
constructor(browserContext: WKBrowserContext, pageProxySession: WKSession, opener: WKPage | null) {
this._pageProxySession = pageProxySession;
@ -205,6 +206,8 @@ export class WKPage implements PageDelegate {
promises.push(session.send('Page.setTimeZone', { timeZone: contextOptions.timezoneId }).
catch(e => { throw new Error(`Invalid timezone ID: ${contextOptions.timezoneId}`); }));
}
if (this._interceptingFileChooser)
promises.push(session.send('Page.setInterceptFileChooserDialog', { enabled: true }));
promises.push(session.send('Page.overrideSetting', { setting: 'DeviceOrientationEventEnabled' as any, value: contextOptions.isMobile }));
promises.push(session.send('Page.overrideSetting', { setting: 'FullScreenEnabled' as any, value: !contextOptions.isMobile }));
promises.push(session.send('Page.overrideSetting', { setting: 'NotificationsEnabled' as any, value: !contextOptions.isMobile }));
@ -685,6 +688,7 @@ export class WKPage implements PageDelegate {
}
async setFileChooserIntercepted(enabled: boolean) {
this._interceptingFileChooser = enabled;
await this._session.send('Page.setInterceptFileChooserDialog', { enabled }).catch(e => {}); // target can be closed.
}

View file

@ -400,7 +400,7 @@ it('should work for "webkitdirectory"', async ({ page, server }) => {
it('should emit event after navigation', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/11375' });
it.fixme(browserName === 'chromium' || browserName === 'webkit');
it.fixme(browserName === 'chromium');
const logs = [];
page.on('filechooser', () => logs.push('filechooser'));