From ed240973511dee39bc52b2bb2981cb1ab52d2920 Mon Sep 17 00:00:00 2001 From: "Ross A. Wollman" Date: Sun, 26 Jul 2020 18:56:13 -0700 Subject: [PATCH] test(iframes): Add cross-origin clicks (#3170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changeset adds two tests aimed at reproducing #3170 where a link in a cross-domain iframe fails to get clicked even though the element is found. In addition to the cross-domain test, we add a `srcdoc` test to baseline the source of failing behavior. In the matrix of {Firefox, Chromium, Webkit } X { srcdoc, cross-domain } X { Headfull, Headless }, only the Chromium Headfull test with cross-domain iframe fails. Notably, it fails while logging the same message as reported in the original issue: ``` pw:api retrying click action [] +0ms pw:api waiting for element to be visible, enabled and not moving [] +0ms pw:api element is visible, enabled and does not move [] +25ms pw:api scrolling into view if needed [] +0ms pw:api done scrolling [] +1ms pw:api checking that element receives pointer events at (35.32,17) [] +1ms pw:api element does not receive pointer events [] … ``` --- test/assets/frames/link.html | 14 +++++++++ test/click.jest.js | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 test/assets/frames/link.html diff --git a/test/assets/frames/link.html b/test/assets/frames/link.html new file mode 100644 index 0000000000000..ef61a94680bf4 --- /dev/null +++ b/test/assets/frames/link.html @@ -0,0 +1,14 @@ + + + + Page with Link + + + + click me + + diff --git a/test/click.jest.js b/test/click.jest.js index 976a10191d991..561b3b0d4a956 100644 --- a/test/click.jest.js +++ b/test/click.jest.js @@ -307,6 +307,61 @@ describe('Page.click', function() { await frame.click('button'); expect(await frame.evaluate(() => window.result)).toBe('Clicked'); }); + it('should click the visible link in a iframe (srcdoc) in fixed position div', async({page, server}) => { + const clickNotification = new Promise(fulfill => { + page.on('dialog', dialog => { + fulfill(dialog.message()); + dialog.accept(); + }); + }); + await page.goto(server.EMPTY_PAGE); + await page.setViewportSize({width:1920, height:1080}); + await page.setContent(` +
+ +
+ `) + const frame = page.frames()[1]; + const link = await frame.$("#link-target"); + await link.click(); + const msg = await clickNotification; + expect(msg).toBe("47"); + }) + it.fail(CHROMIUM && !HEADLESS)('should click the visible link in an iframe (cross-origin) in fixed position div', async({page, server}) => { + const clickNotification = new Promise(fulfill => { + page.on('dialog', dialog => { + fulfill(dialog.message()); + dialog.accept(); + }); + }); + await page.goto(server.EMPTY_PAGE); + await page.setViewportSize({width:1920, height:1080}); + await page.setContent(` +
+ +
+ `) + const frame = page.frames()[1]; + const link = await frame.$("#link-target"); + await link.click(); + const msg = await clickNotification; + expect(msg).toBe("47"); + }) it('should click the button with deviceScaleFactor set', async({browser, server}) => { const context = await browser.newContext({ viewport: { width: 400, height: 400 }, deviceScaleFactor: 5 }); const page = await context.newPage();