From 1c4b96816a1e4b466e6e071e954118ca8ffe8a6e Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Fri, 7 Jun 2024 12:46:00 +0200 Subject: [PATCH] test: add a test for ctrlKey on wheel (#12547) --- test/TestExpectations.json | 7 +++++++ test/src/mouse.spec.ts | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 5d06ebe994f..07a5c25d896 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -2183,6 +2183,13 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[mouse.spec] Mouse should set ctrlKey on the wheel event", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["cdp", "firefox"], + "expectations": ["SKIP"], + "comment": "Wheel event is not supported" + }, { "testIdPattern": "[mouse.spec] Mouse should trigger hover state with removed window.Node", "platforms": ["darwin", "linux", "win32"], diff --git a/test/src/mouse.spec.ts b/test/src/mouse.spec.ts index 69229eb1471..b52361acc90 100644 --- a/test/src/mouse.spec.ts +++ b/test/src/mouse.spec.ts @@ -222,6 +222,30 @@ describe('Mouse', function () { height: 230, }); }); + it('should set ctrlKey on the wheel event', async () => { + const {page, server} = await getTestState(); + await page.goto(server.EMPTY_PAGE); + const ctrlKey = page.evaluate(() => { + return new Promise(resolve => { + window.addEventListener( + 'wheel', + event => { + resolve(event.ctrlKey); + }, + { + once: true, + } + ); + }); + }); + await page.keyboard.down('Control'); + await page.mouse.wheel({deltaY: -100}); + // Scroll back to work around + // https://bugzilla.mozilla.org/show_bug.cgi?id=1901211. + await page.mouse.wheel({deltaY: 100}); + await page.keyboard.up('Control'); + expect(await ctrlKey).toBeTruthy(); + }); it('should tween mouse movement', async () => { const {page} = await getTestState();