From f0fcdc8f51dcbb30cc80c10c9d2fddd52501392b Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 12 Aug 2020 16:07:01 -0700 Subject: [PATCH] test(firefox): make headful screencast tests work under xvfb (#3421) --- .github/workflows/tests.yml | 6 +++--- test/screencast.spec.ts | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16bdb483a6..c55aac3858 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,7 +38,7 @@ jobs: # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # Wrap `npm run` in a subshell to redirect STDERR to file. # 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: BROWSER: ${{ matrix.browser }} DEBUG: "pw:*,-pw:wrapped*,-pw:test*" @@ -160,7 +160,7 @@ jobs: # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # Wrap `npm run` in a subshell to redirect STDERR to file. # 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() }} env: BROWSER: ${{ matrix.browser }} @@ -194,7 +194,7 @@ jobs: # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # Wrap `npm run` in a subshell to redirect STDERR to file. # 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: BROWSER: ${{ matrix.browser }} DEBUG: "pw:*,-pw:wrapped*,-pw:test*" diff --git a/test/screencast.spec.ts b/test/screencast.spec.ts index 04170ce130..f93bc143c3 100644 --- a/test/screencast.spec.ts +++ b/test/screencast.spec.ts @@ -148,6 +148,17 @@ class VideoPlayer { }, 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() { const duration = await this.duration(); 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 || (FFOX && !HEADLESS))('should capture static page', async({page, persistentDirectory, videoPlayer, toImpl}) => { +it.fail(CHROMIUM)('should capture static page', async({page, persistentDirectory, videoPlayer, toImpl}) => { if (!toImpl) return; 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. -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) return; 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); { - await videoPlayer.seek(0); + await videoPlayer.seekFirstNonEmptyFrame(); const pixels = await videoPlayer.pixels(); expectAll(pixels, almostBlack); }