Browse Source

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

pull/11426/head
Yury Semikhatsky 4 days ago
committed by GitHub
parent
commit
cfb86a74fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/playwright-core/src/server/webkit/wkPage.ts
  2. 2
      tests/page/page-set-input-files.spec.ts

4
packages/playwright-core/src/server/webkit/wkPage.ts

@ -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.
}

2
tests/page/page-set-input-files.spec.ts

@ -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'));

Loading…
Cancel
Save