Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off - Builds a Chromium-shaped cookie
2// table with the same native bindings the source reads.
3import * as NodePath from "node:path";
4import * as NodeServices from "@effect/platform-node/NodeServices";
5import { assert, describe, it } from "@effect/vitest";
6import {
7 HostProcessEnvironment,
8 HostProcessHostname,
9 HostProcessPlatform,
10} from "@t3tools/shared/hostProcess";
11import * as Effect from "effect/Effect";
12import * as FileSystem from "effect/FileSystem";
13import * as Path from "effect/Path";
14import * as PlatformError from "effect/PlatformError";
15import * as Scope from "effect/Scope";
16import * as Stream from "effect/Stream";
17import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
18import * as NodeSqlite from "node:sqlite";
19
20import type { BrowserImportPathContext } from "./Sources.ts";
21import {
22 BROWSER_IMPORT_SOURCES,
23 chromiumProcessIsAlive,
24 chromiumSingletonLockIsHeld,
25 cookieDatabaseCandidatePaths,
26 firefoxSymlinkLockIsHeld,
27 resolveCookieDatabase,
28 isSourceInstalled,
29 isSourceRunning,
30 isWindowsLockHeldError,
31 posixLockIsHeld,
32 listSourceProfiles,
33 sourcePathContext,
34 windowsChromiumCookiesAreHeld,
35} from "./Sources.ts";
36import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
37
38const helium = BROWSER_IMPORT_SOURCES.find((source) => source.id === "helium")!;
39
40describe("Linux Chromium secret applications", () => {
41 it("pins the libsecret application attribute for each supported fork", () => {
42 assert.deepEqual(
43 Object.fromEntries(
44 BROWSER_IMPORT_SOURCES.filter((source) => source.platforms.includes("linux")).map(
45 (source) => [source.id, source.linuxSecretApplication],
46 ),
47 ),
48 {
49 chrome: "chrome",
50 edge: "msedge",
51 brave: "brave",
52 vivaldi: "vivaldi",
53 opera: "opera",
54 helium: "chromium",
55 firefox: undefined,
56 },
57 );
58 });
59});
60
61const platformError = (reasonTag: string): PlatformError.PlatformError =>
62 ({ _tag: "PlatformError", reason: { _tag: reasonTag } }) as never;
63
64describe("Windows browser lock errors", () => {
65 it("treats sharing and lock violations reported as Busy as held", () => {
66 assert.isTrue(isWindowsLockHeldError(platformError("Busy")));
67 });
68
69 it("does not treat access denied as proof of an active lock", () => {
70 assert.isFalse(isWindowsLockHeldError(platformError("PermissionDenied")));
71 });
72
73 it("does not treat a missing lock file as held", () => {
74 assert.isFalse(isWindowsLockHeldError(platformError("NotFound")));
75 });
76});
77
78/** A scratch home with the source's user-data directory already created. */
79const withSourceHome = Effect.fnUntraced(function* () {
80 const fileSystem = yield* FileSystem.FileSystem;
81 const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-sources-" });
82 const context = yield* sourcePathContext.pipe(
83 Effect.provideService(HostProcessEnvironment, { HOME: home }),
84 Effect.provideService(HostProcessPlatform, "darwin"),
85 );
86 yield* fileSystem.makeDirectory(userDataDirectory(context), { recursive: true });
87 return context;
88});
89
90/** Every case here runs on darwin, where Helium always resolves a directory. */
91const userDataDirectory = (context: BrowserImportPathContext) => {
92 const root = helium.userDataDirectory(context);
93 if (root === undefined) throw new Error("Helium has no macOS user-data directory");
94 return root;
95};
96
97const run = <A, E>(
98 effect: Effect.Effect<
99 A,
100 E,
101 FileSystem.FileSystem | Path.Path | Scope.Scope | ChildProcessSpawner.ChildProcessSpawner
102 >,
103) => effect.pipe(Effect.provide(NodeServices.layer), Effect.scoped);
104
105/** Writes a Chromium-shaped cookie table with `count` rows. */
106const writeCookieDatabase = (file: string, count: number) =>
107 Effect.sync(() => {
108 const database = new NodeSqlite.DatabaseSync(file);
109 database.exec("create table cookies (host_key text, name text)");
110 const insert = database.prepare("insert into cookies (host_key, name) values (?, ?)");
111 for (let index = 0; index < count; index += 1) insert.run("example.test", `c${index}`);
112 database.close();
113 });
114
115const writeFirefoxCookieDatabase = (
116 file: string,
117 defaultContainerCount: number,
118 containerCount: number,
119) =>
120 Effect.sync(() => {
121 const database = new NodeSqlite.DatabaseSync(file);
122 database.exec("create table moz_cookies (originAttributes text not null)");
123 const insert = database.prepare("insert into moz_cookies (originAttributes) values (?)");
124 for (let index = 0; index < defaultContainerCount; index += 1) insert.run("");
125 for (let index = 0; index < containerCount; index += 1) insert.run("^userContextId=2");
126 database.close();
127 });
128
129describe("Helium on Linux", () => {
130 it.effect.skipIf(!symlinksSupported)("discovers its profiles and checks the user-data lock", () =>
131 run(
132 Effect.gen(function* () {
133 const fileSystem = yield* FileSystem.FileSystem;
134 const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-helium-linux-" });
135 const context = yield* sourcePathContext.pipe(
136 Effect.provideService(HostProcessEnvironment, { HOME: home }),
137 Effect.provideService(HostProcessPlatform, "linux"),
138 );
139 const root = `${home}/.config/net.imput.helium`;
140 yield* fileSystem.makeDirectory(`${root}/Default`, { recursive: true });
141 yield* writeCookieDatabase(`${root}/Default/Cookies`, 3);
142 yield* fileSystem.writeFileString(
143 `${root}/Local State`,
144 '{"profile":{"info_cache":{"Default":{"name":"Personal"}}}}',
145 );
146
147 assert.include(helium.platforms, "linux");
148 assert.isTrue(yield* isSourceInstalled(helium, context));
149 assert.deepEqual(yield* listSourceProfiles(helium, context), [
150 { directory: "Default", name: "Personal", cookieCount: 3 },
151 ]);
152 assert.isFalse(yield* isSourceRunning(helium, context));
153 yield* fileSystem.symlink("foreign-host-4242", `${root}/SingletonLock`);
154 assert.isTrue(yield* isSourceRunning(helium, context));
155 }),
156 ),
157 );
158});
159
160describe("Helium on Windows", () => {
161 it.effect("uses Helium's local app-data profile while other Chromium forks stay disabled", () =>
162 run(
163 Effect.gen(function* () {
164 const context = yield* sourcePathContext.pipe(
165 Effect.provideService(HostProcessEnvironment, {
166 USERPROFILE: "C:\\Users\\browser-user",
167 LOCALAPPDATA: "C:\\Users\\browser-user\\AppData\\Local",
168 }),
169 Effect.provideService(HostProcessPlatform, "win32"),
170 );
171
172 assert.include(helium.platforms, "win32");
173 assert.equal(
174 helium.userDataDirectory(context),
175 context.path.join(
176 "C:\\Users\\browser-user\\AppData\\Local",
177 "imput",
178 "Helium",
179 "User Data",
180 ),
181 );
182 for (const source of BROWSER_IMPORT_SOURCES) {
183 if (source.engine === "chromium" && source.id !== "helium") {
184 assert.notInclude(source.platforms, "win32");
185 }
186 }
187 }),
188 ),
189 );
190});
191
192describe("isSourceRunning", () => {
193 it.effect("uses the held cookie database as Chromium's Windows running signal", () =>
194 run(
195 Effect.gen(function* () {
196 const fileSystem = yield* FileSystem.FileSystem;
197 const home = yield* fileSystem.makeTempDirectoryScoped({
198 prefix: "t3code-helium-windows-lock-",
199 });
200 const context = yield* sourcePathContext.pipe(
201 Effect.provideService(HostProcessEnvironment, {
202 HOME: home,
203 LOCALAPPDATA: home,
204 }),
205 Effect.provideService(HostProcessPlatform, "win32"),
206 );
207 const profile = context.path.join(helium.userDataDirectory(context)!, "Default");
208 const database = context.path.join(profile, "Network", "Cookies");
209 yield* fileSystem.makeDirectory(context.path.join(profile, "Network"), { recursive: true });
210 yield* writeCookieDatabase(database, 1);
211
212 const probed: string[] = [];
213 assert.isTrue(
214 yield* windowsChromiumCookiesAreHeld(helium, context, (path) =>
215 Effect.sync(() => {
216 probed.push(path);
217 return true;
218 }),
219 ),
220 );
221 assert.deepEqual(probed, [database]);
222 }),
223 ),
224 );
225
226 it.effect.skipIf(!symlinksSupported)(
227 "reads Chromium's dangling SingletonLock symlink as a running browser",
228 () =>
229 run(
230 Effect.gen(function* () {
231 const fileSystem = yield* FileSystem.FileSystem;
232 const context = yield* withSourceHome();
233 assert.isFalse(yield* isSourceRunning(helium, context));
234
235 // Chromium points the lock at `<host>-<pid>`, a target that never
236 // exists on disk. A check that follows the link reports a running
237 // browser as closed, letting an import read a live, mid-write database.
238 yield* fileSystem.symlink(
239 "host-that-does-not-exist-1234",
240 `${userDataDirectory(context)}/SingletonLock`,
241 );
242
243 assert.isTrue(yield* isSourceRunning(helium, context));
244 }),
245 ),
246 );
247
248 it.effect.skipIf(!symlinksSupported)(
249 "uses the provided hostname to classify Chromium locks",
250 () =>
251 run(
252 Effect.gen(function* () {
253 const fileSystem = yield* FileSystem.FileSystem;
254 const paths = yield* withSourceHome();
255 yield* fileSystem.symlink(
256 "lock-owner-99999999",
257 `${helium.userDataDirectory(paths)}/SingletonLock`,
258 );
259
260 assert.isTrue(
261 yield* isSourceRunning(helium, paths).pipe(
262 Effect.provideService(HostProcessHostname, "another-host"),
263 ),
264 );
265 assert.isFalse(
266 yield* isSourceRunning(helium, paths).pipe(
267 Effect.provideService(HostProcessHostname, "lock-owner"),
268 ),
269 );
270 }),
271 ),
272 );
273});
274
275describe("chromiumSingletonLockIsHeld", () => {
276 it.effect("ignores a positively dead PID on the current host", () =>
277 Effect.gen(function* () {
278 const checked: number[] = [];
279 const held = yield* chromiumSingletonLockIsHeld("current-host-4321", "current-host", (pid) =>
280 Effect.sync(() => {
281 checked.push(pid);
282 return false;
283 }),
284 );
285 assert.isFalse(held);
286 assert.deepEqual(checked, [4321]);
287 }),
288 );
289
290 it.effect("keeps a live PID on the current host", () =>
291 chromiumSingletonLockIsHeld("current-host-4321", "current-host", () =>
292 Effect.succeed(true),
293 ).pipe(Effect.tap((held) => Effect.sync(() => assert.isTrue(held)))),
294 );
295
296 it.effect("keeps foreign-host and malformed targets without probing a PID", () =>
297 Effect.gen(function* () {
298 let probes = 0;
299 const probe = (_pid: number) =>
300 Effect.sync(() => {
301 probes += 1;
302 return false;
303 });
304 assert.isTrue(yield* chromiumSingletonLockIsHeld("another-host-4321", "current-host", probe));
305 assert.isTrue(
306 yield* chromiumSingletonLockIsHeld("current-host-no-pid", "current-host", probe),
307 );
308 assert.isTrue(yield* chromiumSingletonLockIsHeld("current-host-0", "current-host", probe));
309 assert.strictEqual(probes, 0);
310 }),
311 );
312});
313
314describe("chromiumProcessIsAlive", () => {
315 it.effect("returns false only when signal 0 reports a missing process", () =>
316 Effect.gen(function* () {
317 const missing = Object.assign(new Error("missing"), { code: "ESRCH" });
318 const denied = Object.assign(new Error("denied"), { code: "EPERM" });
319 assert.isFalse(
320 yield* chromiumProcessIsAlive(4321, () => {
321 throw missing;
322 }),
323 );
324 assert.isTrue(
325 yield* chromiumProcessIsAlive(4321, () => {
326 throw denied;
327 }),
328 );
329 assert.isTrue(
330 yield* chromiumProcessIsAlive(4321, () => {
331 throw undefined;
332 }),
333 );
334 assert.isTrue(
335 yield* chromiumProcessIsAlive(4321, () => {
336 throw "unknown failure";
337 }),
338 );
339 assert.isTrue(
340 yield* chromiumProcessIsAlive(4321, () => {
341 throw null;
342 }),
343 );
344 assert.isTrue(yield* chromiumProcessIsAlive(4321, () => true));
345 }),
346 );
347});
348
349describe("isSourceInstalled", () => {
350 it.effect("ignores a user-data directory that holds no cookie database", () =>
351 run(
352 Effect.gen(function* () {
353 const fileSystem = yield* FileSystem.FileSystem;
354 const context = yield* withSourceHome();
355 const root = userDataDirectory(context);
356
357 // Installers for native messaging hosts create an empty user-data
358 // directory for every Chromium fork they know about, so treating the
359 // directory as evidence lists browsers the user does not have.
360 yield* fileSystem.makeDirectory(`${root}/NativeMessagingHosts`, { recursive: true });
361 assert.isFalse(yield* isSourceInstalled(helium, context));
362
363 yield* fileSystem.makeDirectory(`${root}/Default`, { recursive: true });
364 yield* fileSystem.writeFileString(`${root}/Default/Cookies`, "db");
365 assert.isTrue(yield* isSourceInstalled(helium, context));
366
367 // A real install whose cookies live outside `Default` still counts:
368 // reporting it as absent hides the source from the menu entirely.
369 yield* fileSystem.remove(`${root}/Default`, { recursive: true });
370 yield* fileSystem.makeDirectory(`${root}/Profile 1`, { recursive: true });
371 yield* fileSystem.writeFileString(`${root}/Profile 1/Cookies`, "db");
372 assert.isTrue(yield* isSourceInstalled(helium, context));
373
374 yield* fileSystem.remove(root, { recursive: true });
375 assert.isFalse(yield* isSourceInstalled(helium, context));
376 }),
377 ),
378 );
379
380 it.effect("detects a Chromium 127+ install with cookies under Network/", () =>
381 run(
382 Effect.gen(function* () {
383 const fileSystem = yield* FileSystem.FileSystem;
384 const context = yield* withSourceHome();
385 const root = userDataDirectory(context);
386
387 yield* fileSystem.makeDirectory(`${root}/Default/Network`, { recursive: true });
388 yield* fileSystem.writeFileString(`${root}/Default/Network/Cookies`, "db");
389 assert.isTrue(yield* isSourceInstalled(helium, context));
390 }),
391 ),
392 );
393
394 it.effect.skipIf(!symlinksSupported)(
395 "follows cookie database symlinks when detecting profiles",
396 () =>
397 run(
398 Effect.gen(function* () {
399 const fileSystem = yield* FileSystem.FileSystem;
400 const context = yield* withSourceHome();
401 const root = userDataDirectory(context);
402 yield* fileSystem.makeDirectory(`${root}/Default`, { recursive: true });
403 yield* fileSystem.symlink("missing-cookies", `${root}/Default/Cookies`);
404
405 assert.deepEqual(yield* listSourceProfiles(helium, context), []);
406 assert.isFalse(yield* isSourceInstalled(helium, context));
407
408 yield* fileSystem.writeFileString(`${root}/Default/missing-cookies`, "db");
409 assert.deepEqual(yield* listSourceProfiles(helium, context), [
410 { directory: "Default", name: "Default" },
411 ]);
412 assert.isTrue(yield* isSourceInstalled(helium, context));
413 }),
414 ),
415 );
416});
417
418describe("listSourceProfiles", () => {
419 it.effect("ignores a profile whose Cookies entry is not a file", () =>
420 run(
421 Effect.gen(function* () {
422 const fileSystem = yield* FileSystem.FileSystem;
423 const paths = yield* withSourceHome();
424 const root = helium.userDataDirectory(paths);
425 // A directory named `Cookies` would list as importable and then fail
426 // the SQLite open, so only a regular file counts as a database.
427 yield* fileSystem.makeDirectory(`${root}/Broken/Cookies`, { recursive: true });
428 yield* fileSystem.makeDirectory(`${root}/Real`, { recursive: true });
429 yield* fileSystem.writeFileString(`${root}/Real/Cookies`, "db");
430
431 assert.deepEqual(yield* listSourceProfiles(helium, paths), [
432 { directory: "Real", name: "Real" },
433 ]);
434 assert.isTrue(yield* isSourceInstalled(helium, paths));
435 }),
436 ),
437 );
438
439 it.effect("discovers profiles by their cookie database when Local State is absent", () =>
440 run(
441 Effect.gen(function* () {
442 const fileSystem = yield* FileSystem.FileSystem;
443 const context = yield* withSourceHome();
444 const root = userDataDirectory(context);
445 // Assuming `Default` would report a browser whose cookies live in
446 // `Profile 1` as having nothing to import, and it is then hidden.
447 yield* fileSystem.makeDirectory(`${root}/Profile 1`, { recursive: true });
448 yield* fileSystem.writeFileString(`${root}/Profile 1/Cookies`, "db");
449 yield* fileSystem.makeDirectory(`${root}/NativeMessagingHosts`, { recursive: true });
450
451 assert.deepEqual(yield* listSourceProfiles(helium, context), [
452 { directory: "Profile 1", name: "Profile 1" },
453 ]);
454 }),
455 ),
456 );
457
458 it.effect("reads the profile names the browser shows", () =>
459 run(
460 Effect.gen(function* () {
461 const fileSystem = yield* FileSystem.FileSystem;
462 const context = yield* withSourceHome();
463 yield* fileSystem.writeFileString(
464 `${userDataDirectory(context)}/Local State`,
465 `{"profile":{"info_cache":{"Default":{"name":"You"},"Profile 2":{"name":" "}}}}`,
466 );
467
468 assert.deepEqual(yield* listSourceProfiles(helium, context), [
469 { directory: "Default", name: "You" },
470 // Blank display name falls back to the directory rather than
471 // rendering an empty row.
472 { directory: "Profile 2", name: "Profile 2" },
473 ]);
474 }),
475 ),
476 );
477
478 it.effect("scans for profiles when Local State is malformed", () =>
479 run(
480 Effect.gen(function* () {
481 const fileSystem = yield* FileSystem.FileSystem;
482 const context = yield* withSourceHome();
483 const root = userDataDirectory(context);
484 yield* fileSystem.writeFileString(`${root}/Local State`, "{not-json");
485 yield* fileSystem.makeDirectory(`${root}/Default`, { recursive: true });
486 yield* fileSystem.writeFileString(`${root}/Default/Cookies`, "db");
487
488 assert.deepEqual(yield* listSourceProfiles(helium, context), [
489 { directory: "Default", name: "Default" },
490 ]);
491 }),
492 ),
493 );
494
495 it.effect("reports nothing when no directory holds a cookie database", () =>
496 run(
497 Effect.gen(function* () {
498 const context = yield* withSourceHome();
499 assert.deepEqual(yield* listSourceProfiles(helium, context), []);
500 }),
501 ),
502 );
503
504 it.effect("drops Firefox profiles that hold no cookie database", () =>
505 run(
506 Effect.gen(function* () {
507 const fileSystem = yield* FileSystem.FileSystem;
508 const context = yield* withSourceHome();
509 const root = firefox.userDataDirectory(context)!;
510 yield* fileSystem.makeDirectory(root, { recursive: true });
511 yield* fileSystem.writeFileString(
512 `${root}/profiles.ini`,
513 `[Profile0]
514Name=original
515IsRelative=1
516Path=Profiles/abcd.default-release
517Default=1
518
519[Profile1]
520Name=empty
521IsRelative=1
522Path=Profiles/wxyz.empty
523`,
524 );
525 yield* fileSystem.makeDirectory(`${root}/Profiles/abcd.default-release`, {
526 recursive: true,
527 });
528 yield* fileSystem.writeFileString(
529 `${root}/Profiles/abcd.default-release/cookies.sqlite`,
530 "db",
531 );
532 yield* fileSystem.makeDirectory(`${root}/Profiles/wxyz.empty`, { recursive: true });
533
534 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
535 { directory: context.path.join("Profiles", "abcd.default-release"), name: "original" },
536 ]);
537 }),
538 ),
539 );
540
541 it.effect("drops empty profiles when falling back to the Profiles/ scan", () =>
542 run(
543 Effect.gen(function* () {
544 const fileSystem = yield* FileSystem.FileSystem;
545 const context = yield* withSourceHome();
546 const root = firefox.userDataDirectory(context)!;
547 yield* fileSystem.makeDirectory(`${root}/Profiles/filled.default`, { recursive: true });
548 yield* fileSystem.writeFileString(`${root}/Profiles/filled.default/cookies.sqlite`, "db");
549 yield* fileSystem.makeDirectory(`${root}/Profiles/empty.default`, { recursive: true });
550
551 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
552 {
553 directory: context.path.join("Profiles", "filled.default"),
554 name: "filled.default",
555 },
556 ]);
557 }),
558 ),
559 );
560
561 it.effect("discovers profiles with cookies under Network/ (Chromium 127+)", () =>
562 run(
563 Effect.gen(function* () {
564 const fileSystem = yield* FileSystem.FileSystem;
565 const context = yield* withSourceHome();
566 const root = userDataDirectory(context);
567 yield* fileSystem.makeDirectory(`${root}/Default/Network`, { recursive: true });
568 yield* fileSystem.writeFileString(`${root}/Default/Network/Cookies`, "db");
569
570 assert.deepEqual(yield* listSourceProfiles(helium, context), [
571 { directory: "Default", name: "Default" },
572 ]);
573 }),
574 ),
575 );
576
577 it.effect("counts a profile's cookies without decrypting them", () =>
578 run(
579 Effect.gen(function* () {
580 const fileSystem = yield* FileSystem.FileSystem;
581 const paths = yield* withSourceHome();
582 const root = helium.userDataDirectory(paths);
583 yield* fileSystem.makeDirectory(`${root}/Default`, { recursive: true });
584 yield* writeCookieDatabase(`${root}/Default/Cookies`, 3);
585
586 const [profile] = yield* listSourceProfiles(helium, paths);
587 assert.equal(profile?.cookieCount, 3);
588 }),
589 ),
590 );
591
592 it.effect("falls through to the legacy database when Network/Cookies is a directory", () =>
593 run(
594 Effect.gen(function* () {
595 const fileSystem = yield* FileSystem.FileSystem;
596 const paths = yield* withSourceHome();
597 const root = helium.userDataDirectory(paths);
598 // A folder squatting on the preferred candidate path must not shadow
599 // the real legacy database behind it.
600 yield* fileSystem.makeDirectory(`${root}/Default/Network/Cookies`, { recursive: true });
601 yield* writeCookieDatabase(`${root}/Default/Cookies`, 2);
602
603 const [profile] = yield* listSourceProfiles(helium, paths);
604 assert.equal(profile?.directory, "Default");
605 assert.equal(profile?.cookieCount, 2);
606 }),
607 ),
608 );
609});
610
611describe("cookieDatabaseCandidatePaths", () => {
612 it.effect("prefers Network/Cookies and falls back to the legacy Cookies", () =>
613 run(
614 Effect.gen(function* () {
615 const context = yield* withSourceHome();
616 const profile = context.path.join(
617 context.home,
618 "Library",
619 "Application Support",
620 "net.imput.helium",
621 "Profile 1",
622 );
623 assert.deepEqual(cookieDatabaseCandidatePaths(helium, context, "Profile 1"), [
624 context.path.join(profile, "Network", "Cookies"),
625 context.path.join(profile, "Cookies"),
626 ]);
627 }),
628 ),
629 );
630
631 it.effect("resolves the live Network/ jar over a leftover root Cookies", () =>
632 run(
633 Effect.gen(function* () {
634 const fileSystem = yield* FileSystem.FileSystem;
635 const context = yield* withSourceHome();
636 const root = userDataDirectory(context);
637 // Chromium 96+ keeps sessions in Network/; a root Cookies left behind
638 // by the move is stale and must not be the one imported.
639 yield* fileSystem.makeDirectory(`${root}/Default/Network`, { recursive: true });
640 yield* fileSystem.writeFileString(`${root}/Default/Network/Cookies`, "live");
641 yield* fileSystem.writeFileString(`${root}/Default/Cookies`, "stale");
642
643 assert.equal(
644 yield* resolveCookieDatabase(helium, context, "Default"),
645 context.path.join(root, "Default", "Network", "Cookies"),
646 );
647 // A fresh install with only the Network/ jar is installed, not hidden.
648 yield* fileSystem.remove(`${root}/Default/Cookies`);
649 assert.isTrue(yield* isSourceInstalled(helium, context));
650 }),
651 ),
652 );
653
654 it.effect("returns only cookies.sqlite for Firefox", () =>
655 run(
656 Effect.gen(function* () {
657 const path = yield* Path.Path;
658 const context = yield* sourcePathContext.pipe(
659 Effect.provideService(HostProcessEnvironment, { HOME: "/tmp/test" }),
660 Effect.provideService(HostProcessPlatform, "darwin"),
661 );
662 const candidates = cookieDatabaseCandidatePaths(firefox, context, "Profiles/abc.default");
663 assert.deepEqual(candidates, [
664 path.join(
665 "/tmp/test",
666 "Library/Application Support/Firefox/Profiles/abc.default/cookies.sqlite",
667 ),
668 ]);
669 }),
670 ),
671 );
672});
673
674const firefox = BROWSER_IMPORT_SOURCES.find((source) => source.id === "firefox")!;
675
676describe("Firefox Snap profiles", () => {
677 it.effect.skipIf(!symlinksSupported)(
678 "finds Snap profiles with or without profiles.ini and checks their locks",
679 () =>
680 run(
681 Effect.gen(function* () {
682 const fileSystem = yield* FileSystem.FileSystem;
683 const home = yield* fileSystem.makeTempDirectoryScoped({
684 prefix: "t3code-firefox-snap-",
685 });
686 const context = yield* sourcePathContext.pipe(
687 Effect.provideService(HostProcessEnvironment, { HOME: home }),
688 Effect.provideService(HostProcessPlatform, "linux"),
689 );
690 const root = context.path.join(home, "snap", "firefox", "common", ".mozilla", "firefox");
691 const directory = context.path.join(root, "abcd.default");
692 yield* fileSystem.makeDirectory(directory, { recursive: true });
693 yield* writeFirefoxCookieDatabase(`${directory}/cookies.sqlite`, 2, 1);
694 yield* fileSystem.writeFileString(
695 `${root}/profiles.ini`,
696 "[Profile0]\nName=Personal\nIsRelative=1\nPath=abcd.default\n",
697 );
698
699 assert.isTrue(yield* isSourceInstalled(firefox, context));
700 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
701 { directory, name: "Personal", cookieCount: 2 },
702 ]);
703 assert.equal(
704 yield* resolveCookieDatabase(firefox, context, directory),
705 context.path.join(directory, "cookies.sqlite"),
706 );
707 assert.isFalse(yield* isSourceRunning(firefox, context));
708 yield* fileSystem.symlink("foreign-host:+4242", `${directory}/lock`);
709 assert.isTrue(yield* isSourceRunning(firefox, context));
710 yield* fileSystem.remove(`${directory}/lock`);
711 assert.isFalse(yield* isSourceRunning(firefox, context));
712
713 yield* fileSystem.remove(`${root}/profiles.ini`);
714 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
715 { directory, name: "abcd.default", cookieCount: 2 },
716 ]);
717 }),
718 ),
719 );
720
721 it.effect("keeps matching profile names in native and Snap installs distinct", () =>
722 run(
723 Effect.gen(function* () {
724 const fileSystem = yield* FileSystem.FileSystem;
725 const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-firefox-snap-" });
726 const context = yield* sourcePathContext.pipe(
727 Effect.provideService(HostProcessEnvironment, { HOME: home }),
728 Effect.provideService(HostProcessPlatform, "linux"),
729 );
730 const native = context.path.join(home, ".mozilla", "firefox");
731 const snap = context.path.join(home, "snap", "firefox", "common", ".mozilla", "firefox");
732 for (const root of [native, snap]) {
733 yield* fileSystem.makeDirectory(`${root}/abcd.default`, { recursive: true });
734 yield* writeFirefoxCookieDatabase(`${root}/abcd.default/cookies.sqlite`, 1, 0);
735 yield* fileSystem.writeFileString(
736 `${root}/profiles.ini`,
737 "[Profile0]\nName=Personal\nIsRelative=1\nPath=abcd.default\n" +
738 `[Profile1]\nName=Shared\nIsRelative=0\nPath=${snap}/abcd.default\n`,
739 );
740 }
741
742 const profiles = yield* listSourceProfiles(firefox, context);
743 assert.deepEqual(
744 profiles.map((profile) => profile.directory),
745 ["abcd.default", context.path.join(snap, "abcd.default")],
746 );
747 const databases = yield* Effect.forEach(profiles, (profile) =>
748 resolveCookieDatabase(firefox, context, profile.directory),
749 );
750 assert.deepEqual(databases, [
751 context.path.join(native, "abcd.default", "cookies.sqlite"),
752 context.path.join(snap, "abcd.default", "cookies.sqlite"),
753 ]);
754 }),
755 ),
756 );
757});
758
759describe("listSourceProfiles Firefox fallback", () => {
760 const cases = [
761 { platform: "linux" as const, profileDirectory: "linux.default" },
762 { platform: "darwin" as const, profileDirectory: NodePath.join("Profiles", "macos.default") },
763 { platform: "win32" as const, profileDirectory: NodePath.join("Profiles", "windows.default") },
764 ];
765
766 for (const { platform, profileDirectory } of cases) {
767 it.effect(`scans the ${platform} profile location and excludes stale entries`, () =>
768 run(
769 Effect.gen(function* () {
770 const fileSystem = yield* FileSystem.FileSystem;
771 const path = yield* Path.Path;
772 const home = yield* fileSystem.makeTempDirectoryScoped({
773 prefix: `t3code-firefox-${platform}-`,
774 });
775 const appData = path.join(home, "AppData", "Roaming");
776 const context = yield* sourcePathContext.pipe(
777 Effect.provideService(HostProcessEnvironment, {
778 HOME: home,
779 APPDATA: appData,
780 }),
781 Effect.provideService(HostProcessPlatform, platform),
782 );
783 const root = firefox.userDataDirectory(context)!;
784 const scanRoot = platform === "linux" ? root : path.join(root, "Profiles");
785 yield* fileSystem.makeDirectory(path.join(root, profileDirectory), { recursive: true });
786 yield* fileSystem.writeFileString(
787 path.join(root, profileDirectory, "cookies.sqlite"),
788 "db",
789 );
790 yield* fileSystem.makeDirectory(path.join(scanRoot, "stale.default"), {
791 recursive: true,
792 });
793 yield* fileSystem.writeFileString(path.join(scanRoot, "stale-file.default"), "not-dir");
794
795 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
796 {
797 directory: profileDirectory,
798 name: path.basename(profileDirectory),
799 },
800 ]);
801 }),
802 ),
803 );
804 }
805
806 it.effect("scans for profiles when profiles.ini declares only ones without cookies", () =>
807 run(
808 Effect.gen(function* () {
809 const fileSystem = yield* FileSystem.FileSystem;
810 const path = yield* Path.Path;
811 const home = yield* fileSystem.makeTempDirectoryScoped({
812 prefix: "t3code-firefox-stale-ini-",
813 });
814 const context = yield* sourcePathContext.pipe(
815 Effect.provideService(HostProcessEnvironment, { HOME: home }),
816 Effect.provideService(HostProcessPlatform, "darwin"),
817 );
818 const root = firefox.userDataDirectory(context)!;
819 // `profiles.ini` names a profile that was never launched (no cookie
820 // database), while the real cookies sit in an undeclared one.
821 yield* fileSystem.makeDirectory(path.join(root, "Profiles", "stale.default"), {
822 recursive: true,
823 });
824 const realDirectory = path.join(root, "Profiles", "real.default");
825 yield* fileSystem.makeDirectory(realDirectory, { recursive: true });
826 yield* writeFirefoxCookieDatabase(path.join(realDirectory, "cookies.sqlite"), 3, 0);
827 yield* fileSystem.writeFileString(
828 path.join(root, "profiles.ini"),
829 ["[Profile0]", "Name=Stale", "IsRelative=1", "Path=Profiles/stale.default"].join("\n"),
830 );
831
832 // Returning the empty declared list would hide the browser entirely.
833 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
834 {
835 directory: path.join("Profiles", "real.default"),
836 name: "real.default",
837 cookieCount: 3,
838 },
839 ]);
840 assert.isTrue(yield* isSourceInstalled(firefox, context));
841 }),
842 ),
843 );
844
845 it.effect("counts only importable cookies for declared and fallback profiles", () =>
846 run(
847 Effect.gen(function* () {
848 const fileSystem = yield* FileSystem.FileSystem;
849 const path = yield* Path.Path;
850 const home = yield* fileSystem.makeTempDirectoryScoped({
851 prefix: "t3code-firefox-counts-",
852 });
853 const context = yield* sourcePathContext.pipe(
854 Effect.provideService(HostProcessEnvironment, { HOME: home }),
855 Effect.provideService(HostProcessPlatform, "darwin"),
856 );
857 const root = firefox.userDataDirectory(context)!;
858 const declaredDirectory = path.join(root, "Profiles", "declared.default");
859 yield* fileSystem.makeDirectory(declaredDirectory, { recursive: true });
860 yield* writeFirefoxCookieDatabase(path.join(declaredDirectory, "cookies.sqlite"), 2, 3);
861 yield* fileSystem.writeFileString(
862 path.join(root, "profiles.ini"),
863 ["[Profile0]", "Name=Declared", "IsRelative=1", "Path=Profiles/declared.default"].join(
864 "\n",
865 ),
866 );
867
868 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
869 {
870 directory: path.join("Profiles", "declared.default"),
871 name: "Declared",
872 cookieCount: 2,
873 },
874 ]);
875
876 yield* fileSystem.remove(path.join(root, "profiles.ini"));
877 const fallbackDirectory = path.join(root, "Profiles", "fallback.default");
878 yield* fileSystem.makeDirectory(fallbackDirectory, { recursive: true });
879 yield* writeFirefoxCookieDatabase(path.join(fallbackDirectory, "cookies.sqlite"), 1, 4);
880
881 assert.deepEqual(yield* listSourceProfiles(firefox, context), [
882 {
883 directory: path.join("Profiles", "declared.default"),
884 name: "declared.default",
885 cookieCount: 2,
886 },
887 {
888 directory: path.join("Profiles", "fallback.default"),
889 name: "fallback.default",
890 cookieCount: 1,
891 },
892 ]);
893 }),
894 ),
895 );
896});
897
898describe("isSourceRunning for Firefox", () => {
899 it.effect.skipIf(!symlinksSupported)("finds the lock inside the profile, not at the root", () =>
900 run(
901 Effect.gen(function* () {
902 const fileSystem = yield* FileSystem.FileSystem;
903 const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-firefox-" });
904 const context = yield* sourcePathContext.pipe(
905 Effect.provideService(HostProcessEnvironment, { HOME: home }),
906 Effect.provideService(HostProcessPlatform, "darwin"),
907 );
908 const root = firefox.userDataDirectory(context)!;
909 const profile = `${root}/Profiles/abcd.default-release`;
910 yield* fileSystem.makeDirectory(profile, { recursive: true });
911 yield* fileSystem.writeFileString(`${profile}/cookies.sqlite`, "db");
912
913 assert.isFalse(yield* isSourceRunning(firefox, context));
914
915 // Firefox keeps its locks per profile. A root-level lock is not one,
916 // and looking there was why a running Firefox read as importable.
917 yield* fileSystem.writeFileString(`${root}/lock`, "");
918 assert.isFalse(yield* isSourceRunning(firefox, context));
919
920 // `.parentlock` is deliberately left on disk after a clean exit as a
921 // last-used marker, so an unlocked one is not evidence of a running
922 // browser — treating it as one blocked every import after first use.
923 yield* fileSystem.writeFileString(`${profile}/.parentlock`, "");
924 assert.isFalse(yield* isSourceRunning(firefox, context));
925
926 // The `lock` symlink is what Firefox removes on exit; a live pid in
927 // its target means the profile is held.
928 yield* fileSystem.symlink(`127.0.0.1:+${process.pid}`, `${profile}/lock`);
929 assert.isTrue(yield* isSourceRunning(firefox, context));
930 }),
931 ),
932 );
933
934 it.effect("reports not-held when no interpreter can run the fcntl probe", () =>
935 run(
936 Effect.gen(function* () {
937 const fileSystem = yield* FileSystem.FileSystem;
938 const directory = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-lock-" });
939 const lock = `${directory}/.parentlock`;
940 yield* fileSystem.writeFileString(lock, "");
941 // A Mac without the developer tools has only Apple's shim, which
942 // refuses to run the script; a machine with no python at all has
943 // nothing. Either way the probe is unavailable, not the lock held —
944 // treating it as held would block Firefox import on that machine for
945 // good.
946 assert.isFalse(yield* posixLockIsHeld(lock, ["/nonexistent/python3"]));
947 // And a fake "interpreter" that exits non-zero without a verdict, as
948 // the shim does, is the same case.
949 assert.isFalse(yield* posixLockIsHeld(lock, ["/usr/bin/false"]));
950 }),
951 ),
952 );
953
954 // Holds the lock with python3's fcntl, which does not exist on Windows.
955 it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32")(
956 "detects a live fcntl lock on .parentlock, as macOS Firefox leaves it",
957 () =>
958 run(
959 Effect.gen(function* () {
960 const fileSystem = yield* FileSystem.FileSystem;
961 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
962 const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-firefox-" });
963 const context = yield* sourcePathContext.pipe(
964 Effect.provideService(HostProcessEnvironment, { HOME: home }),
965 Effect.provideService(HostProcessPlatform, "darwin"),
966 );
967 const root = firefox.userDataDirectory(context)!;
968 const profile = `${root}/Profiles/abcd.default-release`;
969 yield* fileSystem.makeDirectory(profile, { recursive: true });
970 yield* fileSystem.writeFileString(`${profile}/cookies.sqlite`, "db");
971 const parentLock = `${profile}/.parentlock`;
972 yield* fileSystem.writeFileString(parentLock, "");
973
974 // Hold the lock from a child the way Firefox does (F_SETLK, write),
975 // and keep it until the scope closes.
976 const holder = yield* spawner.spawn(
977 ChildProcess.make(
978 "python3",
979 [
980 "-c",
981 "import fcntl,os,sys,time\n" +
982 "fd=os.open(sys.argv[1],os.O_WRONLY)\n" +
983 "fcntl.lockf(fd,fcntl.LOCK_EX|fcntl.LOCK_NB)\n" +
984 "print('locked',flush=True)\n" +
985 "time.sleep(30)",
986 parentLock,
987 ],
988 { stdin: "ignore" },
989 ),
990 );
991 // Wait for the child to confirm it holds the lock before probing.
992 yield* holder.stdout.pipe(
993 Stream.decodeText(),
994 Stream.splitLines,
995 Stream.filter((line) => line.trim() === "locked"),
996 Stream.take(1),
997 Stream.runDrain,
998 );
999
1000 assert.isTrue(yield* isSourceRunning(firefox, context));
1001 yield* holder.kill();
1002 }),
1003 ),
1004 );
1005
1006 it.effect("reads a Firefox lock symlink's pid to tell live from crashed", () =>
1007 Effect.gen(function* () {
1008 const alive = (pid: number) => Effect.succeed(pid === 4242);
1009 // The resolver may hand Firefox any of the machine's addresses, not
1010 // just 127.0.0.1 — 127.0.1.1 on Debian-style hosts, a LAN address
1011 // elsewhere — so every local address counts as ours.
1012 const local = new Set(["127.0.0.1", "127.0.1.1", "192.168.1.20"]);
1013 // Both the plain and the fcntl-marked (`+`) forms carry the pid.
1014 assert.isTrue(yield* firefoxSymlinkLockIsHeld("127.0.0.1:4242", local, alive));
1015 assert.isTrue(yield* firefoxSymlinkLockIsHeld("127.0.1.1:+4242", local, alive));
1016 assert.isTrue(yield* firefoxSymlinkLockIsHeld("192.168.1.20:+4242", local, alive));
1017 // A crash leaves the symlink behind with a dead pid, on any local address.
1018 assert.isFalse(yield* firefoxSymlinkLockIsHeld("127.0.0.1:+9999", local, alive));
1019 assert.isFalse(yield* firefoxSymlinkLockIsHeld("192.168.1.20:+9999", local, alive));
1020 // Anything unparseable stays conservative.
1021 assert.isTrue(yield* firefoxSymlinkLockIsHeld("garbage", local, alive));
1022 // A foreign owner (a shared profile locked from another machine) names
1023 // a pid we cannot probe, so it is held regardless of local liveness.
1024 assert.isTrue(yield* firefoxSymlinkLockIsHeld("10.0.0.7:+9999", local, alive));
1025 }),
1026 );
1027
1028 it.effect("does not treat a stale parent.lock file as a running browser", () =>
1029 run(
1030 Effect.gen(function* () {
1031 const fileSystem = yield* FileSystem.FileSystem;
1032 const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-firefox-" });
1033 const context = yield* sourcePathContext.pipe(
1034 // Firefox's win32 root hangs off %APPDATA%; without it the root is
1035 // undefined and the fixture would escape the sandbox into the repo.
1036 Effect.provideService(HostProcessEnvironment, {
1037 HOME: home,
1038 APPDATA: `${home}/AppData/Roaming`,
1039 }),
1040 Effect.provideService(HostProcessPlatform, "win32"),
1041 );
1042 const root = firefox.userDataDirectory(context)!;
1043 const profile = `${root}/Profiles/gx7x7fqx.default-release`;
1044 yield* fileSystem.makeDirectory(profile, { recursive: true });
1045 yield* fileSystem.writeFileString(`${profile}/cookies.sqlite`, "db");
1046
1047 // On Windows, Firefox creates parent.lock as a regular file that
1048 // persists after the process exits. The file is only locked while
1049 // Firefox is running; the old stat-based check always found it.
1050 yield* fileSystem.writeFileString(`${profile}/parent.lock`, "");
1051 assert.isFalse(yield* isSourceRunning(firefox, context));
1052 }),
1053 ),
1054 );
1055});
1056
1057describe("Windows user-data directories", () => {
1058 it.effect("keeps app-bound Chromium forks unsupported on win32", () =>
1059 Effect.sync(() => {
1060 // Helium retains the older DPAPI-backed store. Other Chromium forks use
1061 // App-Bound Encryption, so omitting win32 makes `unavailableReason`
1062 // report `unsupportedPlatform` and keeps them out of the menu.
1063 for (const source of BROWSER_IMPORT_SOURCES) {
1064 if (source.engine === "chromium" && source.id !== "helium") {
1065 assert.notInclude(source.platforms, "win32");
1066 }
1067 }
1068 }),
1069 );
1070});
1071
1072describe("listSourceProfiles hardening", () => {
1073 it.effect("drops profile directories that are not a single plain segment", () =>
1074 run(
1075 Effect.gen(function* () {
1076 const fileSystem = yield* FileSystem.FileSystem;
1077 const context = yield* withSourceHome();
1078 // `Local State` is writable by anything running as the user, so a
1079 // crafted key must not reach `cookieDatabasePath` and read a database
1080 // outside the browser's user-data directory.
1081 yield* fileSystem.writeFileString(
1082 `${userDataDirectory(context)}/Local State`,
1083 `{"profile":{"info_cache":{"Default":{"name":"You"},"../../../../secrets":{"name":"Escape"},"a/b":{"name":"Nested"},"..":{"name":"Parent"}}}}`,
1084 );
1085
1086 const profiles = yield* listSourceProfiles(helium, context);
1087
1088 assert.deepEqual(
1089 profiles.map((profile) => profile.directory),
1090 ["Default"],
1091 );
1092 }),
1093 ),
1094 );
1095});
1096
1097describe("Safari profiles", () => {
1098 const safari = BROWSER_IMPORT_SOURCES.find((source) => source.id === "safari")!;
1099 const workUuid = "C561D071-67AD-4537-866F-54F65FB8E8DD";
1100 const otherUuid = "2875EB19-B938-4E38-BE92-5AE97C256BDD";
1101
1102 const fixture = Effect.fnUntraced(function* () {
1103 const context = yield* withSourceHome();
1104 const fileSystem = yield* FileSystem.FileSystem;
1105 const root = safari.userDataDirectory(context)!;
1106 const library = context.path.dirname(root);
1107 yield* fileSystem.makeDirectory(root, { recursive: true });
1108 yield* fileSystem.writeFileString(context.path.join(root, "Cookies.binarycookies"), "default");
1109 const store = (uuid: string) =>
1110 context.path.join(library, "WebKit", "WebsiteDataStore", uuid.toLowerCase(), "Cookies");
1111 for (const uuid of [workUuid, otherUuid]) {
1112 yield* fileSystem.makeDirectory(store(uuid), { recursive: true });
1113 yield* fileSystem.writeFileString(
1114 context.path.join(store(uuid), "Cookies.binarycookies"),
1115 uuid,
1116 );
1117 }
1118 yield* fileSystem.makeDirectory(context.path.join(library, "Safari"), { recursive: true });
1119 const metadata = context.path.join(library, "Safari", "SafariTabs.db");
1120 return { context, root, store, metadata };
1121 });
1122
1123 it.effect("discovers named profiles and resolves only the selected profile's cookies", () =>
1124 run(
1125 Effect.gen(function* () {
1126 const { context, root, store, metadata } = yield* fixture();
1127 yield* Effect.sync(() => {
1128 const database = new NodeSqlite.DatabaseSync(metadata);
1129 try {
1130 database.exec(`CREATE TABLE bookmarks (
1131 title TEXT, external_uuid TEXT, parent INTEGER DEFAULT 0,
1132 type INTEGER DEFAULT 1, subtype INTEGER DEFAULT 2,
1133 deleted INTEGER DEFAULT 0, order_index INTEGER DEFAULT 0
1134 )`);
1135 const insert = database.prepare(
1136 "INSERT INTO bookmarks (title, external_uuid, deleted) VALUES (?, ?, ?)",
1137 );
1138 insert.run("", "DefaultProfile", 0);
1139 insert.run("Ping", workUuid, 0);
1140 insert.run("Deleted", otherUuid, 1);
1141 insert.run("Unsafe", "../../outside", 0);
1142 database.exec(
1143 "INSERT INTO bookmarks (title, external_uuid, subtype) VALUES ('Tab group', 'group', 1)",
1144 );
1145 } finally {
1146 database.close();
1147 }
1148 });
1149 const profiles = yield* listSourceProfiles(safari, context);
1150 assert.deepEqual(profiles, [
1151 { directory: ".", name: "Personal" },
1152 { directory: store(workUuid), name: "Ping" },
1153 ]);
1154 assert.strictEqual(
1155 yield* resolveCookieDatabase(safari, context, "."),
1156 context.path.join(root, "Cookies.binarycookies"),
1157 );
1158 const selected = yield* resolveCookieDatabase(safari, context, profiles[1]!.directory);
1159 assert.strictEqual(selected, context.path.join(store(workUuid), "Cookies.binarycookies"));
1160 const fileSystem = yield* FileSystem.FileSystem;
1161 assert.strictEqual(yield* fileSystem.readFileString(selected!), workUuid);
1162 yield* fileSystem.remove(selected!);
1163 assert.isUndefined(yield* resolveCookieDatabase(safari, context, profiles[1]!.directory));
1164 assert.deepEqual(yield* listSourceProfiles(safari, context), profiles);
1165 }),
1166 ),
1167 );
1168
1169 for (const metadataState of ["missing", "corrupt"] as const) {
1170 it.effect(`recovers separate cookie stores when metadata is ${metadataState}`, () =>
1171 run(
1172 Effect.gen(function* () {
1173 const { context, store, metadata } = yield* fixture();
1174 const fileSystem = yield* FileSystem.FileSystem;
1175 if (metadataState === "corrupt") yield* fileSystem.writeFileString(metadata, "invalid");
1176 yield* fileSystem.remove(context.path.join(store(otherUuid), "Cookies.binarycookies"));
1177 assert.deepEqual(yield* listSourceProfiles(safari, context), [
1178 { directory: ".", name: "Safari" },
1179 { directory: store(workUuid), name: workUuid.toLowerCase() },
1180 ]);
1181 assert.isTrue(yield* isSourceInstalled(safari, context));
1182 }),
1183 ),
1184 );
1185 }
1186
1187 it.effect("keeps Safari without profiles available", () =>
1188 run(
1189 Effect.gen(function* () {
1190 const context = yield* withSourceHome();
1191 assert.deepEqual(yield* listSourceProfiles(safari, context), [
1192 { directory: ".", name: "Safari" },
1193 ]);
1194 assert.isFalse(yield* isSourceInstalled(safari, context));
1195 }),
1196 ),
1197 );
1198});