@@ -53,6 +53,7 @@ describe("Linux Chromium secret applications", () => {
5353 opera : "opera" ,
5454 helium : "chromium" ,
5555 firefox : undefined ,
56+ zen : undefined ,
5657 } ,
5758 ) ;
5859 } ) ;
@@ -672,6 +673,144 @@ describe("cookieDatabaseCandidatePaths", () => {
672673} ) ;
673674
674675const firefox = BROWSER_IMPORT_SOURCES . find ( ( source ) => source . id === "firefox" ) ! ;
676+ const zen = BROWSER_IMPORT_SOURCES . find ( ( source ) => source . id === "zen" ) ! ;
677+
678+ describe ( "Zen" , ( ) => {
679+ it . effect ( "resolves Zen's native user-data roots on every supported platform" , ( ) =>
680+ run (
681+ Effect . gen ( function * ( ) {
682+ const darwinContext = yield * sourcePathContext . pipe (
683+ Effect . provideService ( HostProcessEnvironment , { HOME : "/Users/zen-user" } ) ,
684+ Effect . provideService ( HostProcessPlatform , "darwin" ) ,
685+ ) ;
686+ const windowsContext = yield * sourcePathContext . pipe (
687+ Effect . provideService ( HostProcessEnvironment , {
688+ HOME : "C:\\Users\\zen-user" ,
689+ APPDATA : "C:\\Users\\zen-user\\AppData\\Roaming" ,
690+ } ) ,
691+ Effect . provideService ( HostProcessPlatform , "win32" ) ,
692+ ) ;
693+ const linuxContext = yield * sourcePathContext . pipe (
694+ Effect . provideService ( HostProcessEnvironment , { HOME : "/home/zen-user" } ) ,
695+ Effect . provideService ( HostProcessPlatform , "linux" ) ,
696+ ) ;
697+
698+ assert . equal ( zen . name , "Zen" ) ;
699+ assert . equal ( zen . engine , "firefox" ) ;
700+ assert . deepEqual ( [ ...zen . platforms ] , [ "darwin" , "win32" , "linux" ] ) ;
701+ assert . equal (
702+ zen . userDataDirectory ( darwinContext ) ,
703+ darwinContext . path . join ( "/Users/zen-user" , "Library" , "Application Support" , "zen" ) ,
704+ ) ;
705+ assert . equal (
706+ zen . userDataDirectory ( windowsContext ) ,
707+ windowsContext . path . join ( "C:\\Users\\zen-user\\AppData\\Roaming" , "zen" ) ,
708+ ) ;
709+ assert . equal (
710+ zen . userDataDirectory ( linuxContext ) ,
711+ linuxContext . path . join ( "/home/zen-user" , ".config" , "zen" ) ,
712+ ) ;
713+ } ) ,
714+ ) ,
715+ ) ;
716+
717+ it . effect ( "discovers Zen profiles through its Firefox-compatible metadata" , ( ) =>
718+ run (
719+ Effect . gen ( function * ( ) {
720+ const fileSystem = yield * FileSystem . FileSystem ;
721+ const home = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "t3code-zen-" } ) ;
722+ const context = yield * sourcePathContext . pipe (
723+ Effect . provideService ( HostProcessEnvironment , { HOME : home } ) ,
724+ Effect . provideService ( HostProcessPlatform , "darwin" ) ,
725+ ) ;
726+ const root = zen . userDataDirectory ( context ) ! ;
727+ yield * fileSystem . makeDirectory ( root , { recursive : true } ) ;
728+ const profile = context . path . join ( root , "Profiles" , "zen.default" ) ;
729+ yield * fileSystem . makeDirectory ( profile , { recursive : true } ) ;
730+ yield * writeFirefoxCookieDatabase ( context . path . join ( profile , "cookies.sqlite" ) , 2 , 1 ) ;
731+ yield * fileSystem . makeDirectory ( context . path . join ( root , "Profiles" , "empty.default" ) , {
732+ recursive : true ,
733+ } ) ;
734+ yield * fileSystem . writeFileString (
735+ context . path . join ( root , "profiles.ini" ) ,
736+ [
737+ "[Profile0]" ,
738+ "Name=Zen" ,
739+ "IsRelative=1" ,
740+ "Path=Profiles/zen.default" ,
741+ "ZenAvatarPath=chrome://browser/content/zen-avatars/avatar-55.svg" ,
742+ "Default=1" ,
743+ "" ,
744+ "[Profile1]" ,
745+ "Name=Empty" ,
746+ "IsRelative=1" ,
747+ "Path=Profiles/empty.default" ,
748+ "" ,
749+ ] . join ( "\n" ) ,
750+ ) ;
751+
752+ assert . deepEqual ( yield * listSourceProfiles ( zen , context ) , [
753+ {
754+ directory : context . path . join ( "Profiles" , "zen.default" ) ,
755+ name : "Zen" ,
756+ cookieCount : 2 ,
757+ } ,
758+ ] ) ;
759+ assert . isTrue ( yield * isSourceInstalled ( zen , context ) ) ;
760+ assert . isFalse ( yield * isSourceRunning ( zen , context ) ) ;
761+ assert . equal (
762+ yield * resolveCookieDatabase ( zen , context , context . path . join ( "Profiles" , "zen.default" ) ) ,
763+ context . path . join ( profile , "cookies.sqlite" ) ,
764+ ) ;
765+ } ) ,
766+ ) ,
767+ ) ;
768+
769+ it . effect ( "does not mistake Firefox Snap installs for Zen profiles" , ( ) =>
770+ run (
771+ Effect . gen ( function * ( ) {
772+ const fileSystem = yield * FileSystem . FileSystem ;
773+ const home = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "t3code-zen-snap-" } ) ;
774+ const context = yield * sourcePathContext . pipe (
775+ Effect . provideService ( HostProcessEnvironment , { HOME : home } ) ,
776+ Effect . provideService ( HostProcessPlatform , "linux" ) ,
777+ ) ;
778+ const zenRoot = context . path . join ( home , ".config" , "zen" ) ;
779+ const snapRoot = context . path . join (
780+ home ,
781+ "snap" ,
782+ "firefox" ,
783+ "common" ,
784+ ".mozilla" ,
785+ "firefox" ,
786+ ) ;
787+ const zenProfile = context . path . join ( zenRoot , "zen.default" ) ;
788+ const snapProfile = context . path . join ( snapRoot , "snap.default" ) ;
789+ for ( const root of [ zenRoot , snapRoot ] ) {
790+ const profile = root === zenRoot ? zenProfile : snapProfile ;
791+ yield * fileSystem . makeDirectory ( profile , { recursive : true } ) ;
792+ yield * writeFirefoxCookieDatabase ( context . path . join ( profile , "cookies.sqlite" ) , 1 , 0 ) ;
793+ yield * fileSystem . writeFileString (
794+ context . path . join ( root , "profiles.ini" ) ,
795+ [
796+ "[Profile0]" ,
797+ "Name=Personal" ,
798+ "IsRelative=1" ,
799+ `Path=${ profile === zenProfile ? "zen.default" : "snap.default" } ` ,
800+ ] . join ( "\n" ) ,
801+ ) ;
802+ }
803+
804+ const profiles = yield * listSourceProfiles ( zen , context ) ;
805+ assert . deepEqual (
806+ profiles . map ( ( profile ) => profile . directory ) ,
807+ [ "zen.default" ] ,
808+ ) ;
809+ assert . isTrue ( yield * isSourceInstalled ( zen , context ) ) ;
810+ } ) ,
811+ ) ,
812+ ) ;
813+ } ) ;
675814
676815describe ( "Firefox Snap profiles" , ( ) => {
677816 it . effect . skipIf ( ! symlinksSupported ) (
0 commit comments