chore: add PDF print for BiDi (#9914)

This commit is contained in:
Nikolay Vitkov
2023-03-27 11:39:40 +02:00
committed by GitHub
parent 94f680a046
commit 95c99e84b8
14 changed files with 266 additions and 161 deletions

View File

@@ -59,6 +59,12 @@
"parameters": ["webDriverBiDi"],
"expectations": ["PASS", "TIMEOUT"]
},
{
"testIdPattern": "[page.spec] Page Page.pdf *",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[page.spec] Page Page.setContent *",
"platforms": ["darwin", "linux", "win32"],
@@ -297,7 +303,13 @@
"testIdPattern": "[navigation.spec] navigation Page.goto should navigate to URL with hash and fire requests without hash",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
"expectations": ["FAIL", "TIMEOUT"]
},
{
"testIdPattern": "[navigation.spec] navigation Page.goto should not leak listeners during navigation of 11 pages",
"platforms": ["darwin"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS", "TIMEOUT"]
},
{
"testIdPattern": "[navigation.spec] navigation Page.goto should not throw an error for a 404 response with an empty body",
@@ -315,7 +327,7 @@
"testIdPattern": "[navigation.spec] navigation Page.goto should return last response in redirect chain",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
"expectations": ["FAIL", "TIMEOUT"]
},
{
"testIdPattern": "[navigation.spec] navigation Page.goto should return response when page changes its URL after load",
@@ -351,7 +363,7 @@
"testIdPattern": "[navigation.spec] navigation Page.goto should work when navigating to valid url",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
"expectations": ["FAIL", "TIMEOUT"]
},
{
"testIdPattern": "[navigation.spec] navigation Page.goto should work when page calls history API in beforeunload",
@@ -369,7 +381,7 @@
"testIdPattern": "[navigation.spec] navigation Page.reload should work",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
"expectations": ["FAIL", "TIMEOUT"]
},
{
"testIdPattern": "[oopif.spec] *",

View File

@@ -2051,28 +2051,19 @@ describe('Page', function () {
});
});
describe('printing to PDF', function () {
describe('Page.pdf', function () {
it('can print to PDF and save to file', async () => {
// Printing to pdf is currently only supported in headless
const {isHeadless, page} = getTestState();
if (!isHeadless) {
return;
}
const {page, server} = getTestState();
const outputFile = __dirname + '/../assets/output.pdf';
await page.goto(server.PREFIX + '/pdf.html');
await page.pdf({path: outputFile});
expect(fs.readFileSync(outputFile).byteLength).toBeGreaterThan(0);
fs.unlinkSync(outputFile);
});
it('can print to PDF and stream the result', async () => {
// Printing to pdf is currently only supported in headless
const {isHeadless, page} = getTestState();
if (!isHeadless) {
return;
}
const {page} = getTestState();
const stream = await page.createPDFStream();
let size = 0;
@@ -2083,10 +2074,7 @@ describe('Page', function () {
});
it('should respect timeout', async () => {
const {isHeadless, page, server} = getTestState();
if (!isHeadless) {
return;
}
const {page, server} = getTestState();
await page.goto(server.PREFIX + '/pdf.html');