Files
hyperframes/packages/player/tests/browser/player-box.ts
Miguel Ángel 46cb5ca446 fix(player): an embed without a height shows its film, and heavy films are measured in Safari (#5932)
* test(player): measure heavy films in real Safari and Chrome on macOS

* test(player): count runtime media seeks and rate writes during the Safari bench

* test(player): compare the Safari bench against native playback of the same media

* test(player): split Safari control playback into per-frame media writes and per-frame transforms

* perf(core): write media volume and mute only when they change

* test(player): presented frame rate and compositor-animation controls in the Safari bench

* perf(core): keep the media volume guard without a new comment line

* test(player): derive presented frames from playback counters and snapshot video state

* test(player): control page plays only listed media, and anchor the Safari process match

* test(player): send the bench as code, and write only validated numbers from the browser

* fix(player): perf host page gives the player a real box, so films are on screen when measured

* fix(player): a player with no height set takes its film's shape instead of collapsing to nothing

The player box had no intrinsic height, so an embed that set only a width (or nothing) was 0 px tall
and showed no picture. An in-flow sizer now carries the composition's aspect ratio; a height the
embed sets still wins, and a height-only embed keeps its full width.

* test(player): label each embed on the player box page
2026-10-20 15:05:46 +00:00

30 lines
1.2 KiB
TypeScript

import assert from "node:assert/strict";
import { launchBrowser } from "../perf/runner.js";
import { startServer } from "../perf/server.js";
// An embed that sets no height, only a height, only a width, or both, gets the box it asks for.
const server = startServer({ noCache: true });
const browser = await launchBrowser({ width: 1280, height: 1200 });
type BoxCase = { name: string; width: number; height: number; ok: boolean };
try {
const page = await browser.newPage();
await page.goto(`${server.origin}/fixtures/_control/player-box.html`);
await page.waitForFunction(() => (window as { __box?: unknown }).__box, { timeout: 30_000 });
const { cases, ratioHeightOnlyWidth } = (await page.evaluate(
() => (window as { __box?: unknown }).__box,
)) as { cases: BoxCase[]; ratioHeightOnlyWidth: number };
console.log(
`a plain block with aspect-ratio and only a height is ${ratioHeightOnlyWidth}px wide`,
);
for (const c of cases) {
assert(c.ok, `${c.name}: player box is ${c.width}x${c.height}`);
}
console.log(`player takes the box its embed asks for (${cases.length} embeds): PASS`);
} finally {
await browser.close();
await server.stop();
}