browser(firefox): support relative paths for firefox videos (#27099)

Firefox protocol requires absolute paths for video recording.

Fixes https://github.com/microsoft/playwright/issues/27086
This commit is contained in:
Andrey Lushnikov 2023-09-15 10:26:20 -07:00 committed by GitHub
parent c914d62c69
commit a34030be80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -20,6 +20,7 @@ import { Frame } from './frame';
import * as network from './network';
import type * as channels from '@protocol/channels';
import fs from 'fs';
import path from 'path';
import { ChannelOwner } from './channelOwner';
import { evaluationScript } from './clientHelper';
import { Browser } from './browser';
@ -469,6 +470,8 @@ export async function prepareBrowserContextParams(options: BrowserContextOptions
size: options.videoSize
};
}
if (contextParams.recordVideo && contextParams.recordVideo.dir)
contextParams.recordVideo.dir = path.resolve(process.cwd(), contextParams.recordVideo.dir);
return contextParams;
}

View file

@ -310,6 +310,23 @@ it.describe('screencast', () => {
expect(fs.existsSync(path)).toBeTruthy();
});
it('should work with relative path for recordVideo.dir', async ({ browser }, testInfo) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27086' });
const videosPath = path.relative(process.cwd(), testInfo.outputPath(''));
const size = { width: 320, height: 240 };
const context = await browser.newContext({
recordVideo: {
dir: videosPath,
size
},
viewport: size,
});
const page = await context.newPage();
const videoPath = await page.video()!.path();
await context.close();
expect(fs.existsSync(videoPath)).toBeTruthy();
});
it('should expose video path blank popup', async ({ browser }, testInfo) => {
const videosPath = testInfo.outputPath('');
const size = { width: 320, height: 240 };