aboutsummaryrefslogtreecommitdiff
path: root/test/profile/browser-process-test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/profile/browser-process-test.ts')
-rw-r--r--test/profile/browser-process-test.ts26
1 files changed, 1 insertions, 25 deletions
diff --git a/test/profile/browser-process-test.ts b/test/profile/browser-process-test.ts
index 7a86c74..efcb9c8 100644
--- a/test/profile/browser-process-test.ts
+++ b/test/profile/browser-process-test.ts
@@ -1,14 +1,3 @@
-/**
- * Unit tests for browser-process parsing and candidate ranking — no browser.
- *
- * Ranking exists because a machine can run several Chromium browsers at once.
- * Picking the wrong one means launching a profile window into a browser the
- * harness is not connected to: the agent sees nothing, and a browser the user
- * never pointed us at gets a new window. (That is exactly what happened during
- * development before ranking existed.)
- *
- * Run: npm test
- */
import { test, before, after, describe } from "node:test";
import assert from "node:assert/strict";
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
@@ -23,7 +12,6 @@ import {
} from "../../src/profile/browser-process";
describe("browser-process parsing and candidate ranking", () => {
- // B1: --user-data-dir parsing
test("B1: bare value parsed", () => {
assert.equal(parseUserDataDirFlag("/opt/google/chrome/chrome --user-data-dir=/tmp/x --foo"), "/tmp/x");
});
@@ -47,7 +35,6 @@ describe("browser-process parsing and candidate ranking", () => {
assert.equal(parseUserDataDirFlag("chrome --user-data-dir="), undefined);
});
- // B2: an explicit --user-data-dir is decisive in both directions
test("B2: exact user-data-dir match outranks a flagless process", () => {
const target = "/tmp/pi-e2e-abc";
const match = rankBrowserCandidate({ exePath: "/opt/google/chrome/chrome", explicitUserDataDir: target }, target);
@@ -74,7 +61,6 @@ describe("browser-process parsing and candidate ranking", () => {
assert.equal(other, 0);
});
- // B3: browser family match decides between flagless processes
test("B3: Brave wins for a Brave user-data-dir", () => {
const braveDir = join(homedir(), ".config/BraveSoftware/Brave-Browser");
const brave = rankBrowserCandidate({ exePath: "/usr/bin/brave-browser" }, braveDir);
@@ -98,7 +84,6 @@ describe("browser-process parsing and candidate ranking", () => {
);
});
- // B4: no preference expressed → every candidate is equally acceptable
test("B4: without a target dir, candidates rank equally", () => {
assert.equal(
rankBrowserCandidate({ exePath: "/usr/bin/brave-browser" }),
@@ -106,7 +91,6 @@ describe("browser-process parsing and candidate ranking", () => {
);
});
- // B5: Windows path comparison ignores case and separator style
test("B5 win: case and separator differences still match", { skip: process.platform !== "win32" }, () => {
assert.equal(
rankBrowserCandidate(
@@ -120,9 +104,6 @@ describe("browser-process parsing and candidate ranking", () => {
);
});
- // B6: Linux's deleted-binary marker. An in-place `google-chrome` upgrade
- // unlinks the running binary, after which /proc/<pid>/exe reads
- // "…/chrome (deleted)" — a path spawn() rejects with ENOENT.
test("B6: marker stripped from a replaced binary's path", () => {
assert.equal(stripDeletedSuffix("/opt/google/chrome/chrome (deleted)"), "/opt/google/chrome/chrome");
});
@@ -135,7 +116,6 @@ describe("browser-process parsing and candidate ranking", () => {
assert.equal(stripDeletedSuffix(" (deleted)"), undefined);
});
- // B7: only a path that is actually on disk may be handed on as spawnable.
describe("B7", () => {
let root: string;
let real: string;
@@ -168,9 +148,6 @@ describe("browser-process parsing and candidate ranking", () => {
assert.equal(await spawnableExePath(""), undefined);
});
- // The launch gate must never pass on a path it cannot spawn — that is
- // what produced a 15s "couldn't open a window" timeout instead of a
- // named error.
test("B7: resolveBrowserExecutable repairs a replaced-binary path", async () => {
assert.equal(await resolveBrowserExecutable({ running: true, exePath: `${real} (deleted)` }), real);
});
@@ -183,8 +160,7 @@ describe("browser-process parsing and candidate ranking", () => {
},
);
- // A binary genuinely named "… (deleted)" must win over the stripped form.
- // Created last, so the checks above see only the ordinary case.
+ // A binary genuinely named "… (deleted)" must win over the stripped form; created last so the checks above see only the ordinary case.
test("B7: a real file named '… (deleted)' is preferred over stripping", async () => {
literal = join(root, "chrome (deleted)");
writeFileSync(literal, "#!/bin/sh\n");