Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: turn on PdfOopif for PDF viewer #12370

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"],
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
"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