feat(screencast): autoscale to fit requested size (#3730)

This commit is contained in:
Yury Semikhatsky 2020-09-02 10:40:50 -07:00 committed by GitHub
parent 9d999ae1f0
commit 1e64efcad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 15 deletions

View File

@ -8,12 +8,12 @@
},
{
"name": "firefox",
"revision": "1167",
"revision": "1169",
"download": true
},
{
"name": "webkit",
"revision": "1334",
"revision": "1337",
"download": true
}
]

View File

@ -358,7 +358,6 @@ export class FFPage implements PageDelegate {
file: options.outputFile,
width: options.width,
height: options.height,
scale: options.scale,
});
}

View File

@ -55,7 +55,6 @@ export type ScreenshotOptions = ElementScreenshotOptions & {
export type ScreencastOptions = {
width: number,
height: number,
scale?: number,
};
export type PageScreencastOptions = ScreencastOptions & {

View File

@ -721,7 +721,6 @@ export class WKPage implements PageDelegate {
file: options.outputFile,
width: options.width,
height: options.height,
scale: options.scale,
}) as any;
this._browserContext._browser._screencastStarted(screencastId, options.outputFile, this._page);
} catch (e) {

View File

@ -231,18 +231,10 @@ describe('screencast', suite => {
test.flaky(options.WEBKIT && LINUX);
}, async ({page, tmpDir, server, videoPlayer, toImpl}) => {
const videoFile = path.join(tmpDir, 'v.webm');
// Chromium automatically fits all frames to fit specified size. To avoid
// unwanted transformations we set view port size equal to the screencast
// size.
// TODO: support explicit 'scale' parameter in CDP.
if (options.CHROMIUM)
await page.setViewportSize({width: 640, height: 480});
// Set viewport equal to screencast frame size to avoid scaling.
await page.setViewportSize({width: 640, height: 480});
await page.goto(server.PREFIX + '/rotate-z.html');
await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480});
// TODO: in WebKit figure out why video size is not reported correctly for
// static pictures.
if (options.HEADLESS && options.WEBKIT)
await page.setViewportSize({width: 1270, height: 950});
// 300 is not enough for Chromium headful.
await new Promise(r => setTimeout(r, 500));
await toImpl(page)._delegate.stopScreencast();