Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Dmitry Gozman6b3f4cd12b11
diff --git a/src/server/chromium/crPage.ts b/src/server/chromium/crPage.ts
index 75bb585085..e08fdda7f8 100644
--- a/src/server/chromium/crPage.ts
+++ b/src/server/chromium/crPage.ts
@@ -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();
diff --git a/src/server/firefox/ffBrowser.ts b/src/server/firefox/ffBrowser.ts
index f3f247404d..e3314d0075 100644
--- a/src/server/firefox/ffBrowser.ts
+++ b/src/server/firefox/ffBrowser.ts
@@ -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
});
diff --git a/src/server/webkit/wkPage.ts b/src/server/webkit/wkPage.ts
index 18e2927ee6..5adf305383 100644
--- a/src/server/webkit/wkPage.ts
+++ b/src/server/webkit/wkPage.ts
@@ -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,
});
}));