From 73d7692ae93959239f909cdee6ee849f8a70b7e5 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Thu, 2 May 2024 13:27:18 +0200 Subject: [PATCH] fix: turn on PdfOopif for PDF viewer (#12370) Refs: #12292, #10696, #12172 --- .../puppeteer-core/src/node/ChromeLauncher.ts | 1 + test/TestExpectations.json | 18 ++++++++- test/assets/pdf-viewer.html | 3 ++ test/assets/sample.pdf | Bin 0 -> 7443 bytes test/src/oopif.spec.ts | 35 ++++++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 test/assets/pdf-viewer.html create mode 100644 test/assets/sample.pdf diff --git a/packages/puppeteer-core/src/node/ChromeLauncher.ts b/packages/puppeteer-core/src/node/ChromeLauncher.ts index 58d15ace211..887fa81d4ad 100644 --- a/packages/puppeteer-core/src/node/ChromeLauncher.ts +++ b/packages/puppeteer-core/src/node/ChromeLauncher.ts @@ -192,6 +192,7 @@ export class ChromeLauncher extends ProductLauncher { // Merge default enabled features with user-provided ones, if any. const enabledFeatures = [ + 'PdfOopif', // Add features to enable by default here. ...userEnabledFeatures, ].filter(feature => { diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 66cd6236499..ecbbf63b83c 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -576,6 +576,13 @@ "expectations": ["SKIP"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[oopif.spec] OOPIF should evaluate on a page with a PDF viewer", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["chrome-headless-shell"], + "expectations": ["FAIL"], + "comment": "chrome-headless-shell does not have a PDF viewer" + }, { "testIdPattern": "[page.spec] Page Page.addScriptTag should throw when added with content to the CSP page", "platforms": ["darwin", "linux", "win32"], @@ -1437,10 +1444,10 @@ }, { "testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.clickablePoint should work for iframes", - "platforms": ["linux", "win32"], + "platforms": ["linux", "win32", "win32"], "parameters": ["cdp", "chrome"], "expectations": ["FAIL", "PASS"], - "comment": "Flaky on Windows and Linux" + "comment": "Flaky with fieldtrial testing config" }, { "testIdPattern": "[elementhandle.spec] ElementHandle specs ElementHandle.isIntersectingViewport should work", @@ -2924,6 +2931,13 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, + { + "testIdPattern": "[oopif.spec] OOPIF should evaluate on a page with a PDF viewer", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox", "webDriverBiDi"], + "expectations": ["SKIP"], + "comment": "chrome-specific test" + }, { "testIdPattern": "[oopif.spec] OOPIF should expose events within OOPIFs", "platforms": ["darwin", "linux", "win32"], diff --git a/test/assets/pdf-viewer.html b/test/assets/pdf-viewer.html new file mode 100644 index 00000000000..0c8796c87f9 --- /dev/null +++ b/test/assets/pdf-viewer.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/assets/sample.pdf b/test/assets/sample.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a1eed6df6f184d5cbe4661ec0e84ab929b6247f5 GIT binary patch literal 7443 zcmaJ`2RPLKA5TT4>}2O#lI`}L5z098>`igp;W&4kvn54RG7^y_l`^t-84X!ck%o~` zW}#3a^Zz~SSHJo{zvFRt@9%rRU+<6Sd40rNSy%cc7%Zp63B0A}l=nxbFBac9XhWa|@I0IRLO!6QC+C*m$ zDyXPK#1qIwA0G`j8r72sfx(gTP{t2nhIhf!NI#6hWQ=K4g0C|X%*M=vgol8Y0G^=s z&ooI?iYA^8mY}Hwhr*FiBmxRmgri_^87Nc&`~~%JRKkC&sH(CODFjAG5WhO(j0a$> z5Oo{?F{IKw@#J4hs9#E05}6LB2EmfS95ji}R05F|VnC$0(%k?U5~ZpN_|U;-da?$j z;bQe!!w>U^&ns%ZKCQIYrl5M*ej%H_?vg_*5yDt%6 zy);fvQM!IYT~ri_5Y)Jz!Rei&lXkX>FqW`-x}vZnXczx9vogy;YevOCa{Ey`{8w4# zfnG!aVvKhMt1%_|P~Zz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/oopif.spec.ts b/test/src/oopif.spec.ts index aa9f3774522..a36a8bc8673 100644 --- a/test/src/oopif.spec.ts +++ b/test/src/oopif.spec.ts @@ -425,6 +425,41 @@ describe('OOPIF', function () { ).toEqual([true, true, false]); }); + it('should exposeFunction on a page with a PDF viewer', async () => { + const {page, server} = state; + + await page.goto(server.PREFIX + '/pdf-viewer.html', { + waitUntil: 'networkidle2', + }); + + await page.exposeFunction('test', () => { + console.log('test'); + }); + }); + + it('should evaluate on a page with a PDF viewer', async () => { + const {page, server} = state; + + await page.goto(server.PREFIX + '/pdf-viewer.html', { + waitUntil: 'networkidle2', + }); + + expect( + await Promise.all( + page.frames().map(async frame => { + return await frame.evaluate(() => { + return window.location.pathname; + }); + }) + ) + ).toEqual([ + '/pdf-viewer.html', + '/sample.pdf', + '/index.html', + '/sample.pdf', + ]); + }); + describe('waitForFrame', () => { it('should resolve immediately if the frame already exists', async () => { const {server, page} = state;