Skip to content

test: run the browser pages in Chromium, Firefox and WebKit with Playwright - #73

Merged
Project516 merged 7 commits into
masterfrom
test/playwright-browsers
Oct 6, 2026
Merged

Project516 merged 7 commits into
masterfrom
test/playwright-browsers

Conversation

@Project516

@Project516 Project516 commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Goal

Run the existing Mocha browser pages in Chromium, Firefox and WebKit, and test the st core on a page with no SharedArrayBuffer. Failures print test titles and messages.

What changed

  • scripts/test-browser.mjs <chromium|firefox|webkit> <isolated|plain>: starts the static server in-process, opens each page with Playwright, wraps mocha.run() through an init script to collect pass counts and failures (window.__mochaResult), and prints failing titles and errors, plus the page console on failure. It asserts crossOriginIsolated matches the mode so a plain run cannot silently be isolated.
  • scripts/serve.mjs: exports serve(port, { isolated }); the CLI gains --no-isolation. Default behavior is unchanged.
  • tests/ffmpeg-{st,mt,esm-fallback}.test.html: core URLs use location.origin instead of http://localhost:3000, so any port works. The Mocha test files are untouched.
  • CI: new tests-browsers job, matrix of 3 browsers x {isolated, plain}. plain runs the three st pages; isolated also runs mt. The job has continue-on-error: true and is not a required check.
  • The required tests job and mocha-headless-chrome are untouched for now.

Results

The first CI run passed all six combinations. WebKit isolated ran ffmpeg-core-st (24 tests), ffmpeg-st (16), ffmpeg-esm-fallback (1) and ffmpeg-mt (16) with no failures, so the mocha hook fires and the pages run in every engine. Rebased on #80, with this job's actions pinned to the same SHAs as the rest of CI.

Not verified locally

Nothing browser-related was run locally (no browsers on the Pi). Lint passes. Expected trouble to look for in the first runs:

  • WebKit: mt core (1 GB initial shared memory, 32 pool workers) may hit memory limits, and crossOriginIsolated on WebKit Linux may be false, which the runner reports as a page failure.
  • Firefox/WebKit: module workers and the UMD-to-ESM fallback in the esm-fallback page.
  • Whether the window.mocha setter hook fires in all three engines (a missing hook shows up as a timeout on (page)).

Switch the required tests job over, and drop mocha-headless-chrome, puppeteer-core and scripts/dump-test-page.mjs, once this job is green.

Review

Review-bot did not review this PR, so a Sonnet subagent reviewed head 1676099. It found that a hung page lost all failure output, because reading the partial result and closing the page had no timeout. It also found that a page that ran zero tests counted as passing, and that a non-Error rejection would crash the report. All three are fixed in 0d8951c, along with a package.json spacing slip. It also noted that all pages run at once in one browser. That matches the existing tests job, so it stays.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 7772c3b8-1592-4b9f-bab3-5fe6cf503899
📥 Commits

Reviewing files that changed from the base of the PR and between 99a5cc5 and c84ce8f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .github/workflows/CI.yml
  • package.json
  • scripts/serve.mjs
  • scripts/test-browser.mjs
  • tests/ffmpeg-esm-fallback.test.html
  • tests/ffmpeg-mt.test.html
  • tests/ffmpeg-st.test.html
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Project516
Project516 force-pushed the test/playwright-browsers branch from 133b1f5 to 1676099 Compare October 6, 2026 01:37
@Project516
Project516 marked this pull request as ready for review October 6, 2026 01:37

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds Playwright-based cross-browser testing (Chromium, Firefox, WebKit) for the existing Mocha browser pages, with isolated (COOP/COEP) and plain modes. The new tests-browsers CI job runs as a non-blocking matrix. The serve.mjs script is refactored to export a reusable function with an --no-isolation flag. Test HTML files now use location.origin for core URLs so any port works. The implementation correctly wraps mocha.run() via an init script to collect results, validates crossOriginIsolated matches the mode, and handles timeouts/hangs with a within helper. All three issues noted by the prior review (hung page output loss, zero-test false pass, non-Error rejection crash) are fixed in this diff.

Not approved: the check on these comments could not run, so they are unverified.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict comment

Comment thread scripts/test-browser.mjs Resolved
Comment thread scripts/test-browser.mjs Resolved
Comment thread scripts/test-browser.mjs Resolved
Comment thread scripts/serve.mjs Resolved

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a new Playwright-based browser test job (tests-browsers) that runs Mocha test pages in Chromium, Firefox, and WebKit with both isolated (COOP/COEP) and plain modes. The scripts/serve.mjs is refactored to export a reusable serve() function with an --no-isolation flag. Test HTML files now use location.origin for core URLs. The job is non-blocking (continue-on-error: true). Several defects exist in the new test runner: non-Error rejections crash the reporter, skipped tests are misreported as 'no tests ran', default arguments allow silent runs, and server/browser cleanup lacks awaits/timeouts.

Not approved: the check on these comments could not run, so they are unverified.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict comment

Comment thread scripts/test-browser.mjs
const partial = await within(page.evaluate(() => window.__mochaResult).catch(() => null));
result = {
passes: partial?.passes ?? 0,
failures: [...(partial?.failures ?? []), { title: "(page)", message: err.message }],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If err is not an Error (e.g., a string rejection), err.message is undefined and the failure annotation becomes useless. Use String(err?.message ?? err) as done on line 36.

Comment thread scripts/test-browser.mjs
timeout: PAGE_TIMEOUT_MS,
});
result = await page.evaluate(() => window.__mochaResult);
if (result.passes === 0 && !result.failures.length) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A page with only skipped tests (Mocha "pending" events) has zero passes and zero failures but did run tests. Add a runner.on("pending", ...) listener in collectResults to track pending count, or check runner.stats.pending on end.

Comment thread scripts/test-browser.mjs
import { chromium, firefox, webkit } from "playwright";
import { serve } from "./serve.mjs";

const [browserName = "chromium", mode = "isolated"] = process.argv.slice(2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running node scripts/test-browser.mjs without arguments silently defaults to chromium/isolated. Require both args and exit with usage when process.argv.length < 4.

Comment thread scripts/test-browser.mjs
failed ||= failures.length > 0;
}
await browser.close();
server.close();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server.close() returns a Promise; not awaiting it means the process exits before the server finishes closing. Use await new Promise(resolve => server.close(resolve)) for clean shutdown.

Comment thread scripts/test-browser.mjs
};

const server = serve(0, { isolated });
await new Promise((resolve) => server.on("listening", resolve));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No timeout on server startup. If the server fails to listen (e.g., permission error), this hangs indefinitely. Add a timeout via within() or Promise.race.

Comment thread scripts/test-browser.mjs
const server = serve(0, { isolated });
await new Promise((resolve) => server.on("listening", resolve));
const origin = `http://localhost:${server.address().port}`;
const browser = await launcher.launch();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No timeout on browser launch. If Playwright fails to start the browser, this hangs indefinitely. Wrap with a timeout.

@Project516
Project516 merged commit 3bd544f into master Oct 6, 2026
25 checks passed
@Project516
Project516 deleted the test/playwright-browsers branch October 6, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant