跳到主要内容

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

浏览文件

remote-cursor.test.mjs

60 行 · 2.0 KB历史下载
1import assert from "node:assert/strict";
2import test from "node:test";
3import { installLocalCursorFallback } from "./remote-cursor.mjs";
4
5function cursorStub() {
6 return {
7 _target: { style: { cursor: "none" } },
8 changes: [],
9 change(...args) {
10 this.changes.push(args);
11 this._target.style.cursor = "remote";
12 },
13 clear() {
14 this._target.style.cursor = "none";
15 },
16 };
17}
18
19const visibleShape = [0, 0, 0, 255];
20
21test("macOS browser fallback remains visible before a remote cursor arrives", () => {
22 const cursor = cursorStub();
23 cursor._target = null; // RFB attaches its cursor asynchronously after construction.
24 installLocalCursorFallback(cursor, true);
25 cursor._target = { style: { cursor: "none" } };
26 cursor.clear();
27 assert.equal(cursor._target.style.cursor, "default");
28 assert.deepEqual(cursor.changes, []);
29});
30
31test("macOS browser fallback replaces an empty or transparent remote cursor", () => {
32 const cursor = cursorStub();
33 installLocalCursorFallback(cursor, true);
34 for (const rgba of [[], [0, 0, 0, 0], [255, 255, 255, 0, 0, 0, 0, 0]]) {
35 cursor.change(rgba, 0, 0, rgba.length / 4, 1);
36 assert.equal(cursor._target.style.cursor, "default");
37 }
38 assert.deepEqual(cursor.changes, []);
39});
40
41test("a real remote cursor shape is preserved without fallback pixels", () => {
42 const cursor = cursorStub();
43 installLocalCursorFallback(cursor, true);
44 cursor.change(visibleShape, 2, 3, 1, 1);
45 assert.equal(cursor._target.style.cursor, "remote");
46 assert.deepEqual(cursor.changes, [[visibleShape, 2, 3, 1, 1]]);
47});
48
49test("non-target displays retain noVNC cursor behavior", () => {
50 const cursor = cursorStub();
51 const change = cursor.change;
52 const clear = cursor.clear;
53 installLocalCursorFallback(cursor, false);
54 assert.equal(cursor.change, change);
55 assert.equal(cursor.clear, clear);
56 cursor.clear();
57 assert.equal(cursor._target.style.cursor, "none");
58 cursor.change([], 0, 0, 0, 0);
59 assert.equal(cursor._target.style.cursor, "remote");
60});