fix(inspector): do not swallow keyup when not recording (#10842)

This commit is contained in:
Dmitry Gozman 2021-12-09 17:15:38 -08:00 committed by GitHub
parent 8cc862c614
commit a52c6219a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -477,7 +477,7 @@ export class Recorder {
return;
}
if (this._mode !== 'recording')
return true;
return;
if (!this._shouldGenerateKeyPressFor(event))
return;
if (this._actionInProgress(event)) {
@ -509,6 +509,8 @@ export class Recorder {
}
private _onKeyUp(event: KeyboardEvent) {
if (this._mode === 'none')
return;
if (!this._shouldGenerateKeyPressFor(event))
return;

View File

@ -318,6 +318,46 @@ it.describe('pause', () => {
await recorderPage.click('[title=Resume]');
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[]> {