fix(inspector): do not swallow keyup when not recording (#10842)
This commit is contained in:
parent
8cc862c614
commit
a52c6219a7
|
|
@ -477,7 +477,7 @@ export class Recorder {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this._mode !== 'recording')
|
if (this._mode !== 'recording')
|
||||||
return true;
|
return;
|
||||||
if (!this._shouldGenerateKeyPressFor(event))
|
if (!this._shouldGenerateKeyPressFor(event))
|
||||||
return;
|
return;
|
||||||
if (this._actionInProgress(event)) {
|
if (this._actionInProgress(event)) {
|
||||||
|
|
@ -509,6 +509,8 @@ export class Recorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onKeyUp(event: KeyboardEvent) {
|
private _onKeyUp(event: KeyboardEvent) {
|
||||||
|
if (this._mode === 'none')
|
||||||
|
return;
|
||||||
if (!this._shouldGenerateKeyPressFor(event))
|
if (!this._shouldGenerateKeyPressFor(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,46 @@ it.describe('pause', () => {
|
||||||
await recorderPage.click('[title=Resume]');
|
await recorderPage.click('[title=Resume]');
|
||||||
await scriptPromise;
|
await scriptPromise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not prevent key events', async ({ page, recorderPageGetter }) => {
|
||||||
|
await page.setContent('<div>Hello</div>');
|
||||||
|
await page.evaluate(() => {
|
||||||
|
(window as any).log = [];
|
||||||
|
for (const event of ['keydown', 'keyup', 'keypress'])
|
||||||
|
window.addEventListener(event, e => (window as any).log.push(e.type));
|
||||||
|
});
|
||||||
|
const scriptPromise = (async () => {
|
||||||
|
await page.pause();
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.keyboard.press('A');
|
||||||
|
await page.keyboard.press('Shift+A');
|
||||||
|
})();
|
||||||
|
const recorderPage = await recorderPageGetter();
|
||||||
|
await recorderPage.waitForSelector(`.source-line-paused:has-text("page.pause")`);
|
||||||
|
await recorderPage.click('[title="Step over"]');
|
||||||
|
await recorderPage.waitForSelector(`.source-line-paused:has-text("press('Enter')")`);
|
||||||
|
await recorderPage.click('[title="Step over"]');
|
||||||
|
await recorderPage.waitForSelector(`.source-line-paused:has-text("press('A')")`);
|
||||||
|
await recorderPage.click('[title="Step over"]');
|
||||||
|
await recorderPage.waitForSelector(`.source-line-paused:has-text("press('Shift+A')")`);
|
||||||
|
await recorderPage.click('[title=Resume]');
|
||||||
|
await scriptPromise;
|
||||||
|
|
||||||
|
const log = await page.evaluate(() => (window as any).log);
|
||||||
|
expect(log).toEqual([
|
||||||
|
'keydown',
|
||||||
|
'keypress',
|
||||||
|
'keyup',
|
||||||
|
'keydown',
|
||||||
|
'keypress',
|
||||||
|
'keyup',
|
||||||
|
'keydown',
|
||||||
|
'keydown',
|
||||||
|
'keypress',
|
||||||
|
'keyup',
|
||||||
|
'keyup',
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function sanitizeLog(recorderPage: Page): Promise<string[]> {
|
async function sanitizeLog(recorderPage: Page): Promise<string[]> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue