惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
博客园_首页
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
The Cloudflare Blog
V
Visual Studio Blog
罗磊的独立博客
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
D
Docker
Last Week in AI
Last Week in AI
B
Blog RSS Feed
C
Check Point Blog
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
博客园 - 聂微东
MongoDB | Blog
MongoDB | Blog
雷峰网
雷峰网

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test(canvas): isolate A2UI host fixtures · openclaw/openc...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main

@@ -108,9 +108,13 @@ async function captureHandlerResponse(

108108

return await captureHttpResponse(handler.handleHttpRequest, url, method);

109109

}

110110111-

async function captureA2uiResponse(url: string, method = "GET"): Promise<CapturedResponse> {

112-

const { handleA2uiHttpRequest } = await import("./a2ui.js");

113-

return await captureHttpResponse(handleA2uiHttpRequest, url, method);

111+

async function captureA2uiFixtureResponse(

112+

rootDir: string,

113+

url: string,

114+

method = "GET",

115+

): Promise<CapturedResponse> {

116+

const { createA2uiHttpRequestHandler } = await import("./a2ui.js");

117+

return await captureHttpResponse(createA2uiHttpRequestHandler({ rootDir }), url, method);

114118

}

115119116120

describe("canvas host", () => {

@@ -439,46 +443,56 @@ describe("canvas host", () => {

439443

});

440444441445

it("serves A2UI scaffold and blocks traversal/symlink escapes", async () => {

442-

const a2uiRoot = path.resolve(process.cwd(), "extensions/canvas/src/host/a2ui");

443-

const bundlePath = path.join(a2uiRoot, "a2ui.bundle.js");

446+

const a2uiRoot = await createCaseDir();

447+

const nestedAssetDir = path.join(a2uiRoot, "assets", "demo");

444448

const linkName = `test-link-${Date.now()}-${Math.random().toString(16).slice(2)}.txt`;

445449

const linkPath = path.join(a2uiRoot, linkName);

446-

let createdBundle = false;

447-448-

try {

449-

await fs.stat(bundlePath);

450-

} catch {

451-

await fs.writeFile(bundlePath, "window.openclawA2UI = {};", "utf8");

452-

createdBundle = true;

453-

}

454450451+

await fs.mkdir(nestedAssetDir, { recursive: true });

452+

await fs.writeFile(

453+

path.join(a2uiRoot, "index.html"),

454+

`<openclaw-a2ui-host></openclaw-a2ui-host>

455+

<script>openclawCanvasA2UIAction</script>`,

456+

"utf8",

457+

);

458+

await fs.writeFile(path.join(a2uiRoot, "a2ui.bundle.js"), "window.openclawA2UI = {};", "utf8");

459+

await fs.writeFile(path.join(nestedAssetDir, "sample.txt"), "nested asset", "utf8");

455460

await fs.symlink(path.join(process.cwd(), "package.json"), linkPath);

456461457462

try {

458-

const res = await captureA2uiResponse(`${A2UI_PATH}/`);

463+

const res = await captureA2uiFixtureResponse(a2uiRoot, `${A2UI_PATH}/`);

459464

const html = res.body;

460465

expect(res.status).toBe(200);

461466

expect(html).toContain("openclaw-a2ui-host");

462467

expect(html).toContain("openclawCanvasA2UIAction");

463468464-

const bundleRes = await captureA2uiResponse(`${A2UI_PATH}/a2ui.bundle.js`);

469+

const bundleRes = await captureA2uiFixtureResponse(a2uiRoot, `${A2UI_PATH}/a2ui.bundle.js`);

465470

const js = bundleRes.body;

466471

expect(bundleRes.status).toBe(200);

467472

expect(js).toContain("openclawA2UI");

468-

const traversalRes = await captureA2uiResponse(`${A2UI_PATH}/%2e%2e%2fpackage.json`);

473+474+

const assetRes = await captureA2uiFixtureResponse(

475+

a2uiRoot,

476+

`${A2UI_PATH}/assets/demo/sample.txt`,

477+

);

478+

expect(assetRes.status).toBe(200);

479+

expect(assetRes.headers["content-type"]).toBe("text/plain");

480+

expect(assetRes.body).toBe("nested asset");

481+482+

const traversalRes = await captureA2uiFixtureResponse(

483+

a2uiRoot,

484+

`${A2UI_PATH}/%2e%2e%2fpackage.json`,

485+

);

469486

expect(traversalRes.status).toBe(404);

470487

expect(traversalRes.body).toBe("not found");

471-

const malformedRes = await captureA2uiResponse(`${A2UI_PATH}/%E0%A4%A`);

488+

const malformedRes = await captureA2uiFixtureResponse(a2uiRoot, `${A2UI_PATH}/%E0%A4%A`);

472489

expect(malformedRes.status).toBe(404);

473490

expect(malformedRes.body).toBe("not found");

474-

const symlinkRes = await captureA2uiResponse(`${A2UI_PATH}/${linkName}`);

491+

const symlinkRes = await captureA2uiFixtureResponse(a2uiRoot, `${A2UI_PATH}/${linkName}`);

475492

expect(symlinkRes.status).toBe(404);

476493

expect(symlinkRes.body).toBe("not found");

477494

} finally {

478495

await fs.rm(linkPath, { force: true });

479-

if (createdBundle) {

480-

await fs.rm(bundlePath, { force: true });

481-

}

482496

}

483497

});

484498

});