@@ -472,6 +472,45 @@ describe("DesktopWindow", () => {
472472 ) ;
473473 } ) ;
474474
475+ it ( "rejects renderer navigations whose origin only serializes as null" , ( ) => {
476+ for ( const applicationUrl of [ "t3code://app/" , "t3code-dev://app/" ] ) {
477+ assert . isTrue (
478+ DesktopWindow . isSameOriginRendererNavigation ( {
479+ applicationUrl,
480+ navigationUrl : `${ applicationUrl } threads?id=1#latest` ,
481+ } ) ,
482+ applicationUrl ,
483+ ) ;
484+ }
485+ for ( const navigationUrl of [
486+ "t3code://other/" ,
487+ "t3code://app.example/" ,
488+ "t3code://app:8080/" ,
489+ "t3code://user@other/" ,
490+ "t3code:app" ,
491+ "t3code-dev://app/" ,
492+ "file:///etc/passwd" ,
493+ "data:text/html,<p>hi</p>" ,
494+ "javascript:alert(1)" ,
495+ "about:blank" ,
496+ "blob:t3code://app/0b5e2c4a" ,
497+ ] ) {
498+ assert . isFalse (
499+ DesktopWindow . isSameOriginRendererNavigation ( {
500+ applicationUrl : "t3code://app/" ,
501+ navigationUrl,
502+ } ) ,
503+ navigationUrl ,
504+ ) ;
505+ }
506+ assert . isFalse (
507+ DesktopWindow . isSameOriginRendererNavigation ( {
508+ applicationUrl : "data:text/html,app" ,
509+ navigationUrl : "data:text/html,other" ,
510+ } ) ,
511+ ) ;
512+ } ) ;
513+
475514 it . effect (
476515 "opens and reopens the window without backend readiness when local execution is disabled" ,
477516 ( ) =>
@@ -973,6 +1012,17 @@ describe("DesktopWindow", () => {
9731012 if ( ! willNavigate ) {
9741013 return yield * Effect . die ( "will-navigate listener was not registered" ) ;
9751014 }
1015+ for ( const [ url , expectedPrevented ] of [
1016+ [ "t3code-dev://app/threads?id=1#latest" , false ] ,
1017+ [ "t3code-dev://other/" , true ] ,
1018+ [ "t3code://app/" , true ] ,
1019+ ] as const ) {
1020+ const preventDefault = vi . fn ( ) ;
1021+ willNavigate ( { preventDefault } , url ) ;
1022+ assert . equal ( preventDefault . mock . calls . length , expectedPrevented ? 1 : 0 , url ) ;
1023+ }
1024+ assert . deepEqual ( openedExternalUrls , [ ] ) ;
1025+
9761026 let prevented = false ;
9771027 willNavigate (
9781028 {
0 commit comments