import { describe, it, expect, beforeEach, afterEach } from "vitest"; import { patchWebGLVideoTextureCompat } from "./video-texture-compat"; // Minimal fake WebGL2 context that records the source passed to texImage2D / // texSubImage2D, so we can assert the patch substitutes the injected frame. class FakeGL2 { lastImageArgs: unknown[] | null = null; lastSubArgs: unknown[] | null = null; texImage2D(...args: unknown[]) { this.lastImageArgs = args; } texSubImage2D(...args: unknown[]) { this.lastSubArgs = args; } } function makeInjectedImage(): HTMLImageElement { const img = document.createElement("img"); img.classList.add("__render_frame__"); Object.defineProperty(img, "complete", { value: true, configurable: true }); Object.defineProperty(img, "naturalWidth", { value: 16, configurable: true }); return img; } describe("patchWebGLVideoTextureCompat", () => { let originalGL2: unknown; beforeEach(() => { originalGL2 = (globalThis as Record).WebGL2RenderingContext; (globalThis as Record).WebGL2RenderingContext = FakeGL2; document.body.innerHTML = ""; }); afterEach(() => { (globalThis as Record).WebGL2RenderingContext = originalGL2; document.body.innerHTML = ""; }); it("substitutes the decoded __render_frame__ image when uploading a