Skip to content

Commit

Permalink
fix(inspector): do not collect action signals while on pause (#5843)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Mar 16, 2021
1 parent 36a61c3 commit d81ebff
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/server/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
progress.log(` element does receive pointer events`);
}

progress.metadata.point = point;
await progress.beforeInputAction(this);

await this._page._frameManager.waitForSignalsCreatedBy(progress, options.noWaitAfter, async () => {
if ((options as any).__testHookBeforePointerAction)
await (options as any).__testHookBeforePointerAction();
Expand All @@ -382,8 +385,6 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
if (options && options.modifiers)
restoreModifiers = await this._page.keyboard._ensureModifiers(options.modifiers);
progress.log(` performing ${actionName} action`);
progress.metadata.point = point;
await progress.beforeInputAction(this);
await action(point);
progress.log(` ${actionName} action done`);
progress.log(' waiting for scheduled navigations to finish');
Expand Down Expand Up @@ -455,10 +456,10 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {

async _selectOption(progress: Progress, elements: ElementHandle[], values: types.SelectOption[], options: types.NavigatingActionWaitOptions): Promise<string[] | 'error:notconnected'> {
const optionsToSelect = [...elements, ...values];
await progress.beforeInputAction(this);
return this._page._frameManager.waitForSignalsCreatedBy(progress, options.noWaitAfter, async () => {
progress.throwIfAborted(); // Avoid action that has side-effects.
progress.log(' selecting specified option(s)');
await progress.beforeInputAction(this);
const poll = await this._evaluateHandleInUtility(([injected, node, optionsToSelect]) => {
return injected.waitForElementStatesAndPerformAction(node, ['visible', 'enabled'], injected.selectOptions.bind(injected, optionsToSelect));
}, optionsToSelect);
Expand All @@ -479,6 +480,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {

async _fill(progress: Progress, value: string, options: types.NavigatingActionWaitOptions): Promise<'error:notconnected' | 'done'> {
progress.log(`elementHandle.fill("${value}")`);
await progress.beforeInputAction(this);
return this._page._frameManager.waitForSignalsCreatedBy(progress, options.noWaitAfter, async () => {
progress.log(' waiting for element to be visible, enabled and editable');
const poll = await this._evaluateHandleInUtility(([injected, node, value]) => {
Expand All @@ -490,7 +492,6 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
if (filled === 'error:notconnected')
return filled;
progress.log(' element is visible, enabled and editable');
await progress.beforeInputAction(this);
if (filled === 'needsinput') {
progress.throwIfAborted(); // Avoid action that has side-effects.
if (value)
Expand Down Expand Up @@ -535,9 +536,9 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
if (typeof multiple === 'string')
return multiple;
assert(multiple || files.length <= 1, 'Non-multiple file input can only accept single file!');
await progress.beforeInputAction(this);
await this._page._frameManager.waitForSignalsCreatedBy(progress, options.noWaitAfter, async () => {
progress.throwIfAborted(); // Avoid action that has side-effects.
await progress.beforeInputAction(this);
await this._page._delegate.setInputFiles(this as any as ElementHandle<HTMLInputElement>, files);
});
await this._page._doSlowMo();
Expand Down Expand Up @@ -569,12 +570,12 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {

async _type(progress: Progress, text: string, options: { delay?: number } & types.NavigatingActionWaitOptions): Promise<'error:notconnected' | 'done'> {
progress.log(`elementHandle.type("${text}")`);
await progress.beforeInputAction(this);
return this._page._frameManager.waitForSignalsCreatedBy(progress, options.noWaitAfter, async () => {
const result = await this._focus(progress, true /* resetSelectionIfNotFocused */);
if (result !== 'done')
return result;
progress.throwIfAborted(); // Avoid action that has side-effects.
await progress.beforeInputAction(this);
await this._page.keyboard.type(text, options);
return 'done';
}, 'input');
Expand All @@ -590,12 +591,12 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {

async _press(progress: Progress, key: string, options: { delay?: number } & types.NavigatingActionWaitOptions): Promise<'error:notconnected' | 'done'> {
progress.log(`elementHandle.press("${key}")`);
await progress.beforeInputAction(this);
return this._page._frameManager.waitForSignalsCreatedBy(progress, options.noWaitAfter, async () => {
const result = await this._focus(progress, true /* resetSelectionIfNotFocused */);
if (result !== 'done')
return result;
progress.throwIfAborted(); // Avoid action that has side-effects.
await progress.beforeInputAction(this);
await this._page.keyboard.press(key, options);
return 'done';
}, 'input');
Expand Down

0 comments on commit d81ebff

Please sign in to comment.