From b2dc0d2fbdf19c64124225042d34b8e8a8aadcd0 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 16 Oct 2023 09:47:05 -0700 Subject: [PATCH] test: unskip "should keep selection in multiple pages" (#27611) https://github.com/microsoft/playwright/pull/27609 fixed the functionality in WebKit. Fixes https://github.com/microsoft/playwright/issues/27475 --- tests/library/browsercontext-pages.spec.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/library/browsercontext-pages.spec.ts b/tests/library/browsercontext-pages.spec.ts index 79529f3487..e6903303f6 100644 --- a/tests/library/browsercontext-pages.spec.ts +++ b/tests/library/browsercontext-pages.spec.ts @@ -139,9 +139,8 @@ it('should not leak listeners during navigation of 20 pages', async ({ contextFa expect(warning).toBe(null); }); -it('should keep selection in multiple pages', async ({ context, browserName, isLinux, headless }) => { +it('should keep selection in multiple pages', async ({ context }) => { it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27475' }); - it.fixme(browserName === 'webkit' && isLinux && !headless); const page1 = await context.newPage(); const page2 = await context.newPage(); for (const page of [page1, page2]) { @@ -150,15 +149,17 @@ it('should keep selection in multiple pages', async ({ context, browserName, isL const element = document.getElementById('container') as HTMLDivElement; const textNode = element.firstChild as Text; - const range = textNode.ownerDocument.createRange(); + const range = document.createRange(); range.setStart(textNode, 6); range.setEnd(textNode, 11); - const selection = textNode.ownerDocument.defaultView?.getSelection(); + const selection = document.getSelection(); selection?.removeAllRanges(); selection?.addRange(range); }); } + // In WebKit, selection is updated via IPC, give it enough time to take effect. + await new Promise(f => setTimeout(f, 1_000)); for (const page of [page1, page2]) { const range = await page.evaluate(() => { const selection = document.getSelection();