chore: calculate video size in a single place (#5942)
This commit is contained in:
parent
8e97607389
commit
6b3f4cd12b
|
|
@ -404,11 +404,11 @@ class FrameSession {
|
||||||
|
|
||||||
let screencastOptions: types.PageScreencastOptions | undefined;
|
let screencastOptions: types.PageScreencastOptions | undefined;
|
||||||
if (this._isMainFrame() && this._crPage._browserContext._options.recordVideo && hasUIWindow) {
|
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 screencastId = createGuid();
|
||||||
const outputFile = path.join(this._crPage._browserContext._options.recordVideo.dir, screencastId + '.webm');
|
const outputFile = path.join(this._crPage._browserContext._options.recordVideo.dir, screencastId + '.webm');
|
||||||
screencastOptions = {
|
screencastOptions = {
|
||||||
...size,
|
// validateBrowserContextOptions ensures correct video size.
|
||||||
|
...this._crPage._browserContext._options.recordVideo.size!,
|
||||||
outputFile,
|
outputFile,
|
||||||
};
|
};
|
||||||
await this._crPage._browserContext._ensureVideosPath();
|
await this._crPage._browserContext._ensureVideosPath();
|
||||||
|
|
|
||||||
|
|
@ -194,10 +194,10 @@ export class FFBrowserContext extends BrowserContext {
|
||||||
if (this._options.colorScheme)
|
if (this._options.colorScheme)
|
||||||
promises.push(this._browser._connection.send('Browser.setColorScheme', { browserContextId, colorScheme: this._options.colorScheme }));
|
promises.push(this._browser._connection.send('Browser.setColorScheme', { browserContextId, colorScheme: this._options.colorScheme }));
|
||||||
if (this._options.recordVideo) {
|
if (this._options.recordVideo) {
|
||||||
const size = this._options.recordVideo.size || this._options.viewport || { width: 1280, height: 720 };
|
|
||||||
promises.push(this._ensureVideosPath().then(() => {
|
promises.push(this._ensureVideosPath().then(() => {
|
||||||
return this._browser._connection.send('Browser.setScreencastOptions', {
|
return this._browser._connection.send('Browser.setScreencastOptions', {
|
||||||
...size,
|
// validateBrowserContextOptions ensures correct video size.
|
||||||
|
...this._options.recordVideo!.size!,
|
||||||
dir: this._options.recordVideo!.dir,
|
dir: this._options.recordVideo!.dir,
|
||||||
browserContextId: this._browserContextId
|
browserContextId: this._browserContextId
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -116,11 +116,11 @@ export class WKPage implements PageDelegate {
|
||||||
promises.push(this._grantPermissions(key, value));
|
promises.push(this._grantPermissions(key, value));
|
||||||
}
|
}
|
||||||
if (this._browserContext._options.recordVideo) {
|
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');
|
const outputFile = path.join(this._browserContext._options.recordVideo.dir, createGuid() + '.webm');
|
||||||
promises.push(this._browserContext._ensureVideosPath().then(() => {
|
promises.push(this._browserContext._ensureVideosPath().then(() => {
|
||||||
return this._startScreencast({
|
return this._startScreencast({
|
||||||
...size,
|
// validateBrowserContextOptions ensures correct video size.
|
||||||
|
...this._browserContext._options.recordVideo!.size!,
|
||||||
outputFile,
|
outputFile,
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue