Skip to content

Commit

Permalink
fix: turn on PdfOopif for PDF viewer (#12370)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed May 2, 2024
1 parent 44fb53e commit 73d7692
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/puppeteer-core/src/node/ChromeLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
18 changes: 16 additions & 2 deletions test/TestExpectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"],
Expand Down
3 changes: 3 additions & 0 deletions test/assets/pdf-viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!DOCTYPE html>

<iframe src="sample.pdf"></iframe>
Binary file added test/assets/sample.pdf
Binary file not shown.
35 changes: 35 additions & 0 deletions test/src/oopif.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

1 comment on commit 73d7692

@o0101
Copy link

@o0101 o0101 commented on 73d7692 May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Please sign in to comment.