Skip to content

Commit

Permalink
chore: calculate video size in a single place (#5942)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman committed Mar 24, 2021
1 parent 8e97607 commit 6b3f4cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/server/chromium/crPage.ts
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/server/firefox/ffBrowser.ts
Expand Up @@ -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
});
Expand Down
4 changes: 2 additions & 2 deletions src/server/webkit/wkPage.ts
Expand Up @@ -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,
});
}));
Expand Down

0 comments on commit 6b3f4cd

Please sign in to comment.