diff --git a/tests/library/inspector/cli-codegen-3.spec.ts b/tests/library/inspector/cli-codegen-3.spec.ts index 2c0fff974a..8ad14c87b9 100644 --- a/tests/library/inspector/cli-codegen-3.spec.ts +++ b/tests/library/inspector/cli-codegen-3.spec.ts @@ -559,6 +559,60 @@ await page.GetByLabel("Coun\\"try").ClickAsync();`); ]); }); + test('should consume contextmenu events, despite a custom context menu', async ({ page, openRecorder }) => { + const recorder = await openRecorder(); + + await recorder.setContentAndWait(` + +
+ + `); + + await recorder.hoverOverElement('button'); + expect(await page.evaluate('log')).toEqual(['button: pointermove', 'button: mousemove']); + + const [message] = await Promise.all([ + page.waitForEvent('console', msg => msg.type() !== 'error'), + recorder.waitForOutput('JavaScript', `button: 'right'`), + recorder.trustedClick({ button: 'right' }), + ]); + expect(message.text()).toBe('right-clicked'); + expect(await page.evaluate('log')).toEqual([ + // hover + 'button: pointermove', + 'button: mousemove', + // trusted right click + 'button: pointerup', + 'button: pointermove', + 'button: mousemove', + 'button: pointerdown', + 'button: mousedown', + 'button: contextmenu', + 'menu: pointerup', + 'menu: mouseup' + ]); + }); + test('should assert value', async ({ openRecorder }) => { const recorder = await openRecorder(); diff --git a/tests/library/inspector/inspectorTest.ts b/tests/library/inspector/inspectorTest.ts index 1d5e30825a..f5eae5153a 100644 --- a/tests/library/inspector/inspectorTest.ts +++ b/tests/library/inspector/inspectorTest.ts @@ -186,9 +186,12 @@ class Recorder { await this.page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); } - async trustedClick() { - await this.page.mouse.down(); - await this.page.mouse.up(); + async trustedClick(options?: { + button?: 'left' | 'right' | 'middle'; + clickCount?: number; + }) { + await this.page.mouse.down(options); + await this.page.mouse.up(options); } async focusElement(selector: string): Promise