test(firefox): make headful screencast tests work under xvfb (#3421)

This commit is contained in:
Yury Semikhatsky 2020-08-12 16:07:01 -07:00 committed by GitHub
parent 06ddacd7be
commit f0fcdc8f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View File

@ -38,7 +38,7 @@ jobs:
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
# Wrap `npm run` in a subshell to redirect STDERR to file. # Wrap `npm run` in a subshell to redirect STDERR to file.
# Enable core dumps in the subshell. # Enable core dumps in the subshell.
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000 && npm run coverage" - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000 && npm run coverage"
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
DEBUG: "pw:*,-pw:wrapped*,-pw:test*" DEBUG: "pw:*,-pw:wrapped*,-pw:test*"
@ -160,7 +160,7 @@ jobs:
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
# Wrap `npm run` in a subshell to redirect STDERR to file. # Wrap `npm run` in a subshell to redirect STDERR to file.
# Enable core dumps in the subshell. # Enable core dumps in the subshell.
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000" - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000"
if: ${{ always() }} if: ${{ always() }}
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
@ -194,7 +194,7 @@ jobs:
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
# Wrap `npm run` in a subshell to redirect STDERR to file. # Wrap `npm run` in a subshell to redirect STDERR to file.
# Enable core dumps in the subshell. # Enable core dumps in the subshell.
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000" - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000"
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
DEBUG: "pw:*,-pw:wrapped*,-pw:test*" DEBUG: "pw:*,-pw:wrapped*,-pw:test*"

View File

@ -148,6 +148,17 @@ class VideoPlayer {
}, timestamp); }, timestamp);
} }
async seekFirstNonEmptyFrame() {
let time = 0;
for (let i = 0; i < 10; i++) {
await this.seek(time);
const pixels = await this.pixels();
if (!pixels.every(p => p === 255))
return;
time += 0.1;
}
}
async seekLastNonEmptyFrame() { async seekLastNonEmptyFrame() {
const duration = await this.duration(); const duration = await this.duration();
let time = duration - 0.01; let time = duration - 0.01;
@ -176,8 +187,7 @@ class VideoPlayer {
} }
} }
// TODO: the test fails in headful Firefox when running under xvfb. it.fail(CHROMIUM)('should capture static page', async({page, persistentDirectory, videoPlayer, toImpl}) => {
it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture static page', async({page, persistentDirectory, videoPlayer, toImpl}) => {
if (!toImpl) if (!toImpl)
return; return;
const videoFile = path.join(persistentDirectory, 'v.webm'); const videoFile = path.join(persistentDirectory, 'v.webm');
@ -204,7 +214,7 @@ it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture static page', async({pa
}); });
// TODO: the test fails in headful Firefox when running under xvfb. // TODO: the test fails in headful Firefox when running under xvfb.
it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture navigation', async({page, persistentDirectory, server, videoPlayer, toImpl}) => { it.fail(CHROMIUM)('should capture navigation', async({page, persistentDirectory, server, videoPlayer, toImpl}) => {
if (!toImpl) if (!toImpl)
return; return;
const videoFile = path.join(persistentDirectory, 'v.webm'); const videoFile = path.join(persistentDirectory, 'v.webm');
@ -225,7 +235,7 @@ it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture navigation', async({pag
expect(duration).toBeGreaterThan(0); expect(duration).toBeGreaterThan(0);
{ {
await videoPlayer.seek(0); await videoPlayer.seekFirstNonEmptyFrame();
const pixels = await videoPlayer.pixels(); const pixels = await videoPlayer.pixels();
expectAll(pixels, almostBlack); expectAll(pixels, almostBlack);
} }