mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: fix keyboard.sendCharacter (#12088)
This commit is contained in:
parent
e867dd435f
commit
26376224d5
@ -13,8 +13,8 @@ import type {BoundingBox} from '../api/ElementHandle.js';
|
|||||||
import type {WaitForOptions} from '../api/Frame.js';
|
import type {WaitForOptions} from '../api/Frame.js';
|
||||||
import type {HTTPResponse} from '../api/HTTPResponse.js';
|
import type {HTTPResponse} from '../api/HTTPResponse.js';
|
||||||
import type {
|
import type {
|
||||||
MediaFeature,
|
|
||||||
GeolocationOptions,
|
GeolocationOptions,
|
||||||
|
MediaFeature,
|
||||||
PageEvents,
|
PageEvents,
|
||||||
} from '../api/Page.js';
|
} from '../api/Page.js';
|
||||||
import {
|
import {
|
||||||
@ -27,8 +27,12 @@ import {Accessibility} from '../cdp/Accessibility.js';
|
|||||||
import {Coverage} from '../cdp/Coverage.js';
|
import {Coverage} from '../cdp/Coverage.js';
|
||||||
import {EmulationManager} from '../cdp/EmulationManager.js';
|
import {EmulationManager} from '../cdp/EmulationManager.js';
|
||||||
import {Tracing} from '../cdp/Tracing.js';
|
import {Tracing} from '../cdp/Tracing.js';
|
||||||
import type {Cookie, CookieParam, CookieSameSite} from '../common/Cookie.js';
|
import type {
|
||||||
import type {DeleteCookiesRequest} from '../common/Cookie.js';
|
Cookie,
|
||||||
|
CookieParam,
|
||||||
|
CookieSameSite,
|
||||||
|
DeleteCookiesRequest,
|
||||||
|
} from '../common/Cookie.js';
|
||||||
import {UnsupportedOperation} from '../common/Errors.js';
|
import {UnsupportedOperation} from '../common/Errors.js';
|
||||||
import {EventEmitter} from '../common/EventEmitter.js';
|
import {EventEmitter} from '../common/EventEmitter.js';
|
||||||
import type {PDFOptions} from '../common/PDFOptions.js';
|
import type {PDFOptions} from '../common/PDFOptions.js';
|
||||||
@ -43,7 +47,6 @@ import type {BidiBrowser} from './Browser.js';
|
|||||||
import type {BidiBrowserContext} from './BrowserContext.js';
|
import type {BidiBrowserContext} from './BrowserContext.js';
|
||||||
import type {BidiCdpSession} from './CDPSession.js';
|
import type {BidiCdpSession} from './CDPSession.js';
|
||||||
import type {BrowsingContext} from './core/BrowsingContext.js';
|
import type {BrowsingContext} from './core/BrowsingContext.js';
|
||||||
import {BidiElementHandle} from './ElementHandle.js';
|
|
||||||
import {BidiFrame} from './Frame.js';
|
import {BidiFrame} from './Frame.js';
|
||||||
import type {BidiHTTPResponse} from './HTTPResponse.js';
|
import type {BidiHTTPResponse} from './HTTPResponse.js';
|
||||||
import {BidiKeyboard, BidiMouse, BidiTouchscreen} from './Input.js';
|
import {BidiKeyboard, BidiMouse, BidiTouchscreen} from './Input.js';
|
||||||
@ -161,21 +164,28 @@ export class BidiPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async focusedFrame(): Promise<BidiFrame> {
|
async focusedFrame(): Promise<BidiFrame> {
|
||||||
using frame = await this.mainFrame()
|
using handle = (await this.mainFrame()
|
||||||
.isolatedRealm()
|
.isolatedRealm()
|
||||||
.evaluateHandle(() => {
|
.evaluateHandle(() => {
|
||||||
let frame: HTMLIFrameElement | undefined;
|
let win = window;
|
||||||
let win: Window | null = window;
|
while (
|
||||||
while (win?.document.activeElement instanceof HTMLIFrameElement) {
|
win.document.activeElement instanceof win.HTMLIFrameElement ||
|
||||||
frame = win.document.activeElement;
|
win.document.activeElement instanceof win.HTMLFrameElement
|
||||||
win = frame.contentWindow;
|
) {
|
||||||
|
if (win.document.activeElement.contentWindow === null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
win = win.document.activeElement.contentWindow as typeof win;
|
||||||
}
|
}
|
||||||
return frame;
|
return win;
|
||||||
});
|
})) as BidiJSHandle<Window & typeof globalThis>;
|
||||||
if (!(frame instanceof BidiElementHandle)) {
|
const value = handle.remoteValue();
|
||||||
return this.mainFrame();
|
assert(value.type === 'window');
|
||||||
}
|
const frame = this.frames().find(frame => {
|
||||||
return await frame.contentFrame();
|
return frame._id === value.value.context;
|
||||||
|
});
|
||||||
|
assert(frame);
|
||||||
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
override frames(): BidiFrame[] {
|
override frames(): BidiFrame[] {
|
||||||
|
@ -474,13 +474,6 @@
|
|||||||
"expectations": ["FAIL"],
|
"expectations": ["FAIL"],
|
||||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[keyboard.spec] Keyboard should send a character with sendCharacter in iframe",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["webDriverBiDi"],
|
|
||||||
"expectations": ["SKIP"],
|
|
||||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Browser.disconnect *",
|
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Browser.disconnect *",
|
||||||
"platforms": ["win32"],
|
"platforms": ["win32"],
|
||||||
|
Loading…
Reference in New Issue
Block a user