chore: calculate video size in a single place (#5942)

This commit is contained in:
Dmitry Gozman 2021-03-24 10:56:20 -07:00 committed by GitHub
parent 8e97607389
commit 6b3f4cd12b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -404,11 +404,11 @@ class FrameSession {
let screencastOptions: types.PageScreencastOptions | undefined;
if (this._isMainFrame() && this._crPage._browserContext._options.recordVideo && hasUIWindow) {
const size = this._crPage._browserContext._options.recordVideo.size || this._crPage._browserContext._options.viewport || { width: 1280, height: 720 };
const screencastId = createGuid();
const outputFile = path.join(this._crPage._browserContext._options.recordVideo.dir, screencastId + '.webm');
screencastOptions = {
...size,
// validateBrowserContextOptions ensures correct video size.
...this._crPage._browserContext._options.recordVideo.size!,
outputFile,
};
await this._crPage._browserContext._ensureVideosPath();

View file

@ -194,10 +194,10 @@ export class FFBrowserContext extends BrowserContext {
if (this._options.colorScheme)
promises.push(this._browser._connection.send('Browser.setColorScheme', { browserContextId, colorScheme: this._options.colorScheme }));
if (this._options.recordVideo) {
const size = this._options.recordVideo.size || this._options.viewport || { width: 1280, height: 720 };
promises.push(this._ensureVideosPath().then(() => {
return this._browser._connection.send('Browser.setScreencastOptions', {
...size,
// validateBrowserContextOptions ensures correct video size.
...this._options.recordVideo!.size!,
dir: this._options.recordVideo!.dir,
browserContextId: this._browserContextId
});

View file

@ -116,11 +116,11 @@ export class WKPage implements PageDelegate {
promises.push(this._grantPermissions(key, value));
}
if (this._browserContext._options.recordVideo) {
const size = this._browserContext._options.recordVideo.size || this._browserContext._options.viewport || { width: 1280, height: 720 };
const outputFile = path.join(this._browserContext._options.recordVideo.dir, createGuid() + '.webm');
promises.push(this._browserContext._ensureVideosPath().then(() => {
return this._startScreencast({
...size,
// validateBrowserContextOptions ensures correct video size.
...this._browserContext._options.recordVideo!.size!,
outputFile,
});
}));