fix(webkit): filechooer interception after process swap (#11415)
This commit is contained in:
parent
26da1cc2cd
commit
cfb86a74fa
|
|
@ -75,6 +75,7 @@ export class WKPage implements PageDelegate {
|
||||||
private _nextWindowOpenPopupFeatures?: string[];
|
private _nextWindowOpenPopupFeatures?: string[];
|
||||||
private _recordingVideoFile: string | null = null;
|
private _recordingVideoFile: string | null = null;
|
||||||
private _screencastGeneration: number = 0;
|
private _screencastGeneration: number = 0;
|
||||||
|
private _interceptingFileChooser = false;
|
||||||
|
|
||||||
constructor(browserContext: WKBrowserContext, pageProxySession: WKSession, opener: WKPage | null) {
|
constructor(browserContext: WKBrowserContext, pageProxySession: WKSession, opener: WKPage | null) {
|
||||||
this._pageProxySession = pageProxySession;
|
this._pageProxySession = pageProxySession;
|
||||||
|
|
@ -205,6 +206,8 @@ export class WKPage implements PageDelegate {
|
||||||
promises.push(session.send('Page.setTimeZone', { timeZone: contextOptions.timezoneId }).
|
promises.push(session.send('Page.setTimeZone', { timeZone: contextOptions.timezoneId }).
|
||||||
catch(e => { throw new Error(`Invalid timezone ID: ${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: '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: 'FullScreenEnabled' as any, value: !contextOptions.isMobile }));
|
||||||
promises.push(session.send('Page.overrideSetting', { setting: 'NotificationsEnabled' 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) {
|
async setFileChooserIntercepted(enabled: boolean) {
|
||||||
|
this._interceptingFileChooser = enabled;
|
||||||
await this._session.send('Page.setInterceptFileChooserDialog', { enabled }).catch(e => {}); // target can be closed.
|
await this._session.send('Page.setInterceptFileChooserDialog', { enabled }).catch(e => {}); // target can be closed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,7 @@ it('should work for "webkitdirectory"', async ({ page, server }) => {
|
||||||
|
|
||||||
it('should emit event after navigation', async ({ page, server, browserName }) => {
|
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.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 = [];
|
const logs = [];
|
||||||
page.on('filechooser', () => logs.push('filechooser'));
|
page.on('filechooser', () => logs.push('filechooser'));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue