fix(player): a film ready before load no longer times the frame's next own document from it (#8634)

This commit is contained in:
Miguel Ángel
2026-11-24 04:20:08 +00:00
committed by GitHub
parent 66eeb13a92
commit 779bed5c0a
3 changed files with 22 additions and 0 deletions
+4
View File
@@ -117,6 +117,10 @@ export class CompositionProbe {
this._timedFromNavigation = true;
}
endNavigation(): void {
this._navigationPending = false;
}
get limitMs(): number {
return this._limitMs;
}
@@ -1563,6 +1563,7 @@ class HyperframesPlayer extends HTMLElement {
private _dispatchReady(): void {
this._readyDocument = this._getSameOriginIframeDocument();
this.probe.endNavigation();
const detail = {
duration: this._duration,
compositionWidth: this._compositionWidth,
+17
View File
@@ -185,6 +185,23 @@ describe("a film past its load limit", () => {
expect(readies.map((ready) => ready.readyMs)).toEqual([700]);
});
// fails without the fix: a timeline posted before load left the navigation marked, so the next document the frame
// opened itself was timed from that old navigation.
it("reports no load time for a document the frame opens after a film that was ready before load", () => {
const { iframe, readies, postTimeline } = navigatedPlayer();
vi.advanceTimersByTime(1_200);
postTimeline();
iframe.dispatchEvent(new Event("load"));
vi.spyOn(iframe, "contentDocument", "get").mockReturnValue(
document.implementation.createHTMLDocument(),
);
vi.advanceTimersByTime(4_000);
iframe.dispatchEvent(new Event("load"));
vi.advanceTimersByTime(300);
postTimeline();
expect(readies.map((ready) => ready.readyMs)).toEqual([1_200, null]);
});
it("reports no load time for a document the frame opened itself", () => {
const { readies, postTimeline } = mountPlayer();
vi.advanceTimersByTime(1_200);