fix: turn on PdfOopif for PDF viewer (#12370)

Refs: #12292, #10696, #12172
This commit is contained in:
Alex Rudenko 2024-05-02 13:27:18 +02:00 committed by GitHub
parent 44fb53eb33
commit 73d7692ae9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 55 additions and 2 deletions

View File

@ -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 => {

View File

@ -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"],

View File

@ -0,0 +1,3 @@
<!DOCTYPE html>
<iframe src="sample.pdf"></iframe>

BIN
test/assets/sample.pdf Normal file

Binary file not shown.

View File

@ -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;