fix(focus): make sure strictness is respected (#10685)
This commit is contained in:
parent
f583f1604c
commit
aef0444ff5
|
|
@ -1088,10 +1088,10 @@ export class Frame extends SdkObject {
|
|||
}, this._page._timeoutSettings.timeout(options));
|
||||
}
|
||||
|
||||
async focus(metadata: CallMetadata, selector: string, options: types.TimeoutOptions = {}) {
|
||||
async focus(metadata: CallMetadata, selector: string, options: types.TimeoutOptions & types.StrictOptions = {}) {
|
||||
const controller = new ProgressController(metadata, this);
|
||||
await controller.run(async progress => {
|
||||
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, undefined, handle => handle._focus(progress)));
|
||||
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, handle => handle._focus(progress)));
|
||||
await this._page._doSlowMo();
|
||||
}, this._page._timeoutSettings.timeout(options));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ it('should focus a button', async ({ page, server }) => {
|
|||
expect(await button.evaluate(button => document.activeElement === button)).toBe(true);
|
||||
});
|
||||
|
||||
it('focus should respect strictness', async ({ page, server }) => {
|
||||
await page.setContent('<div>A</div><div>B</div>');
|
||||
const error = await page.locator('div').focus().catch(e => e);
|
||||
expect(error.message).toContain('strict mode violation');
|
||||
});
|
||||
|
||||
it('should dispatch click event via ElementHandles', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
const button = page.locator('button');
|
||||
|
|
|
|||
Loading…
Reference in a new issue