Skip to content

Commit

Permalink
browser(firefox): support relative paths for firefox videos (microsof…
Browse files Browse the repository at this point in the history
…t#27099)

Firefox protocol requires absolute paths for video recording.

Fixes microsoft#27086
  • Loading branch information
aslushnikov authored and Germandrummer92 committed Oct 27, 2023
1 parent dcfd2d6 commit 7704289
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/playwright-core/src/client/browserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}

Expand Down
17 changes: 17 additions & 0 deletions tests/library/video.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 7704289

Please sign in to comment.