mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 15:19:16 +00:00
* Codex worktree snapshot: startup-cleanup Co-authored-by: Codex * fix(browser): close malformed proxy connections without a reply * feat(browser): embed host browsing in terminal side panels * style(browser): blend compact browser chrome into terminal panels * feat(browser): open terminal links internally with a system browser preference * fix(browser): retain the first terminal link during panel mount replay * fix(browser): release contexts when their split pane closes * style(browser): remove the downloads panel shadow * fix(browser): ignore late downloads after panel closure * fix(browser): mount browser content on terminal auto-open * fix(browser): preserve empty-vault recovery with bookmarks * fix(browser): expose actions for supported terminal types * fix(browser): retain open requests before the panel mounts * fix(browser): align vault actions with supported hosts * fix(browser): share download controls across host contexts * fix(browser): keep vault browser requests on visible sessions * fix(browser): release contexts after workspace detach * fix(browser): enforce WebRTC routing on page contents * fix(browser): skip unsupported sessions in open requests * style(browser): encode glyphs in ASCII-safe source
43 lines
1.8 KiB
JavaScript
43 lines
1.8 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
const test = require("node:test");
|
|
const { readFileSync } = require("node:fs");
|
|
const vm = require("node:vm");
|
|
const { normalizeBrowserUrl } = require("./hostBrowserManager.cjs");
|
|
|
|
test("browser addresses accept bare localhost and domain ports", () => {
|
|
assert.equal(normalizeBrowserUrl("localhost:3000"), "http://localhost:3000/");
|
|
assert.equal(normalizeBrowserUrl("localhost:3000/app"), "http://localhost:3000/app");
|
|
assert.equal(normalizeBrowserUrl("127.0.0.1:8080"), "http://127.0.0.1:8080/");
|
|
assert.equal(normalizeBrowserUrl("example.com:8080"), "https://example.com:8080/");
|
|
assert.equal(normalizeBrowserUrl("https://example.com/app"), "https://example.com/app");
|
|
});
|
|
|
|
test("browser addresses keep rejecting external protocols and credentials", () => {
|
|
for (const url of ["file:///etc/passwd", "javascript:alert(1)", "mailto:test@example.com", "https://user:password@example.com/"]) {
|
|
assert.throws(() => normalizeBrowserUrl(url));
|
|
}
|
|
});
|
|
|
|
test("late download notifications ignore closed browser chrome in a live terminal", () => {
|
|
const source = readFileSync(require.resolve("./hostBrowserManager.cjs"), "utf8");
|
|
const start = source.indexOf("const notifyDownloads =");
|
|
const end = source.indexOf("const snapshot =", start);
|
|
assert.ok(start > 0 && end > start);
|
|
const record = {
|
|
hostId: "host",
|
|
win: { isDestroyed: () => false },
|
|
chromeContents: {
|
|
isDestroyed: () => true,
|
|
send: () => { throw new Error("Object has been destroyed"); },
|
|
},
|
|
downloadsPanelOpen: false,
|
|
};
|
|
const notify = vm.runInNewContext(`${source.slice(start, end)};notifyDownloads;`, {
|
|
downloadStore: { list: () => [] },
|
|
windows: new Map([["closed", record]]),
|
|
});
|
|
assert.doesNotThrow(() => notify(record));
|
|
});
|