mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 16:37:32 +00:00
fix(player): a film ready before load no longer times the frame's next own document from it (#8634)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user