跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

cursor-fallback.test.mjs

27 行 · 1.2 KB历史下载
1import { test } from 'node:test';
2import assert from 'node:assert/strict';
3import { readFile } from 'node:fs/promises';
4import vm from 'node:vm';
5
6test('empty cursor uses opt-in fallback and real cursor shapes still win', async () => {
7 const source = (await readFile(new URL('../vendor/novnc/core/util/cursor.js', import.meta.url), 'utf8'))
8 .replace(/^import .*;$/m, 'const supportsCursorURIs = true, isTouchDevice = false;')
9 .replace('export default class Cursor', 'globalThis.Cursor = class Cursor');
10 const context = vm.createContext({
11 document: { createElement: () => ({ style: {}, width: 0, height: 0,
12 getContext: () => ({ clearRect() {}, putImageData() {} }),
13 toDataURL: () => 'data:image/png;base64,test' }) },
14 ImageData: class {}, Uint8ClampedArray,
15 });
16 vm.runInContext(source, context);
17 for (const fallback of ['default', 'none']) {
18 const target = { style: {} };
19 const cursor = new context.Cursor(fallback);
20 cursor.attach(target);
21 assert.equal(target.style.cursor, fallback);
22 cursor.change(new Uint8Array([0, 0, 0, 255]), 0, 0, 1, 1);
23 assert.match(target.style.cursor, /^url\(/);
24 cursor.change(new Uint8Array(), 0, 0, 0, 0);
25 assert.equal(target.style.cursor, fallback);
26 }
27});