Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions apps/codex-plus-manager/src/image-overlay.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { it } from "node:test";

const source = await readFile(new URL("../../../assets/inject/renderer-inject.js", import.meta.url), "utf8");

function functionSource(name: string) {
const match = source.match(new RegExp(`^ function ${name}\\([^]*?^ \\}`, "m"));
assert.ok(match, name);
return match[0];
}

it('uses native scroll timelines and releases owned animations', () => {
const foreground = functionSource('installCodexPlusImageOverlayForeground');
for (const fragment of ['new ScrollTimeline', 'typeof ScrollTimeline',
'clearScrollLayers(record)', 'xAnimation?.cancel()', 'yAnimation?.cancel()']) {
assert.ok(foreground.includes(fragment), fragment);
}
assert.ok(!foreground.includes('preventDefault('));
});

it("keeps the complete upstream tint layer and its configured opacity", () => {
const install = functionSource("installCodexPlusImageOverlay");
assert.match(install, /width: "100vw"/);
assert.match(install, /height: "100vh"/);
assert.match(install, /opacity: String\(opacity\)/);
assert.match(install, /zIndex: "2147483646"/);
assert.match(install, /pointerEvents: "none"/);
assert.doesNotMatch(install, /clipPath|clip-path|maskImage|mask-image/);
});

it("does not rewrite native palettes, foreground paint, or the ordinary app shell", () => {
const foreground = functionSource("installCodexPlusImageOverlayForeground");
assert.doesNotMatch(foreground, /styleSheets|cssRules/);
assert.doesNotMatch(foreground, /--composer-[\w-]+\s*:/);
assert.doesNotMatch(foreground, /document\.querySelectorAll\([^)]*body/);
assert.match(foreground, /img, video, canvas/);
assert.match(foreground, /data-browser-sidebar-webview/);
assert.match(foreground, /image-preview-dismiss-area/);
});

it("uses bounded media geometry updates and restores every owned resource", () => {
const foreground = functionSource("installCodexPlusImageOverlayForeground");
assert.match(foreground, /getBoundingClientRect/);
assert.match(foreground, /requestAnimationFrame/);
assert.match(foreground, /addEventListener\("scroll"/);
assert.match(foreground, /new ResizeObserver/);
assert.match(foreground, /record\.plane\.remove\(\)/);
assert.match(foreground, /resizeObserver\.disconnect\(\)/);
assert.match(foreground, /target\.removeEventListener/);
assert.doesNotMatch(foreground, /setInterval|setTimeout/);
});

it("retains native media parents and uses the original video for playback controls", () => {
const foreground = functionSource("installCodexPlusImageOverlayForeground");
assert.doesNotMatch(foreground, /anchor-name|positionAnchor|anchor-size|anchor\(/);
assert.match(foreground, /document\.documentElement\.appendChild\(plane\)/);
assert.match(foreground, /pointer-events: none/);
assert.match(foreground, /drawImage\(source/);
assert.match(foreground, /native\.host\.showPopover\(\)/);
assert.doesNotMatch(foreground, /appendChild\(source\)|append\(source\)/);
assert.doesNotMatch(foreground, /copy\.src\s*=\s*record\.source\.currentSrc/);
});
Loading
Loading