browser(firefox): fix file chooser in iframes #8510 (#8510)

References #8016
This commit is contained in:
Andrey Lushnikov 2021-08-27 19:28:24 +03:00 committed by GitHub
parent 768a97cfdc
commit 5901cb321d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 8 deletions

View File

@ -1,2 +1,2 @@
1284
Changed: lushnikov@chromium.org Wed 25 Aug 2021 08:50:22 AM PDT
1285
Changed: lushnikov@chromium.org Fri 27 Aug 2021 09:23:19 AM PDT

View File

@ -246,9 +246,9 @@ class PageAgent {
}
_filePickerShown(inputElement) {
if (inputElement.ownerGlobal.docShell !== this._docShell)
return;
const frame = this._findFrameForNode(inputElement);
if (!frame)
return;
this._browserPage.emit('pageFileChooserOpened', {
executionContextId: frame.mainExecutionContext().id(),
element: frame.mainExecutionContext().rawValueToRemoteObject(inputElement)

View File

@ -1,2 +1,2 @@
1288
Changed: joel.einbinder@gmail.com Wed 25 Aug 2021 08:41:36 AM PDT
1289
Changed: lushnikov@chromium.org Fri 27 Aug 2021 09:23:19 AM PDT

View File

@ -246,9 +246,9 @@ class PageAgent {
}
_filePickerShown(inputElement) {
if (inputElement.ownerGlobal.docShell !== this._docShell)
return;
const frame = this._findFrameForNode(inputElement);
if (!frame)
return;
this._browserPage.emit('pageFileChooserOpened', {
executionContextId: frame.mainExecutionContext().id(),
element: frame.mainExecutionContext().rawValueToRemoteObject(inputElement)

View File

@ -16,6 +16,7 @@
*/
import { test as it, expect } from './pageTest';
import { attachFrame } from '../config/utils';
import path from 'path';
import fs from 'fs';
@ -69,6 +70,17 @@ it('should emit event once', async ({page, server}) => {
expect(chooser).toBeTruthy();
});
it('should emit event for iframe', async ({page, server, browserName}) => {
it.skip(browserName === 'firefox');
const frame = await attachFrame(page, 'frame1', server.EMPTY_PAGE);
await frame.setContent(`<input type=file>`);
const [chooser] = await Promise.all([
new Promise(f => page.once('filechooser', f)),
frame.click('input'),
]);
expect(chooser).toBeTruthy();
});
it('should emit event on/off', async ({page, server}) => {
await page.setContent(`<input type=file>`);
const [chooser] = await Promise.all([