The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { applyThemeCss } from "./themeCss"; |
| 4 | |
| 5 | it("applies theme CSS and drops every rule that would load a remote file", () => { |
| 6 | const probe = document.createElement("div"); |
| 7 | probe.dataset.themeCssProbe = ""; |
| 8 | document.body.append(probe); |
| 9 | using _probe = { [Symbol.dispose]: () => probe.remove() }; |
| 10 | using _css = { [Symbol.dispose]: () => applyThemeCss(undefined) }; |
| 11 | |
| 12 | applyThemeCss(` |
| 13 | @import url(https://example.com/sheet.css); |
| 14 | @namespace svg url(http://www.w3.org/2000/svg); |
| 15 | @property --registered { syntax: "<url>"; inherits: false; initial-value: url(https://example.com/d); } |
| 16 | @counter-style leak { system: cyclic; symbols: url(https://example.com/f); } |
| 17 | @keyframes leak { to { background-image: url(https://example.com/g); } } |
| 18 | :root { --leak: u\\72l(https://example.com/a); } |
| 19 | [data-theme-css-probe] { |
| 20 | color: rgb(1, 2, 3); |
| 21 | background-image: u\\72l(https://example.com/b); |
| 22 | list-style-image: var(--leak); |
| 23 | border-image-source: var(--registered); |
| 24 | mask-image: v\\61r(--none, u\\72l(https://example.com/e)); |
| 25 | @media (min-width: 0px) { cursor: url(https://example.com/c), auto; } |
| 26 | } |
| 27 | `); |
| 28 | |
| 29 | const style = getComputedStyle(probe); |
| 30 | expect(style.color).toBe("rgb(1, 2, 3)"); |
| 31 | expect(style.backgroundImage).toBe("none"); |
| 32 | expect(style.listStyleImage).toBe("none"); |
| 33 | expect(style.borderImageSource).toBe("none"); |
| 34 | expect(style.maskImage).toBe("none"); |
| 35 | const kept = document.adoptedStyleSheets.flatMap((sheet) => |
| 36 | Array.from(sheet.cssRules, (rule) => rule.cssText), |
| 37 | ); |
| 38 | expect(kept.join("\n")).not.toContain("example.com"); |
| 39 | expect(style.cursor).toBe("auto"); |
| 40 | |
| 41 | applyThemeCss(undefined); |
| 42 | expect(getComputedStyle(probe).color).not.toBe("rgb(1, 2, 3)"); |
| 43 | }); |