@@ -72,6 +72,46 @@ async function main() {
7272 const appUrl = `http://127.0.0.1:${ port } /${ packaged ? "chat/" : "" } ` ;
7373 await waitForHttp ( appUrl ) ;
7474 browser = await launchBrowser ( chromium ) ;
75+ for ( const storageFailure of [ "getter" , "methods" ] ) {
76+ const isolated = await browser . newPage ( { viewport : { width : 1512 , height : 982 } } ) ;
77+ const errors = [ ] ;
78+ isolated . on ( "pageerror" , ( error ) => errors . push ( error . message ) ) ;
79+ await isolated . addInitScript ( ( failure ) => {
80+ const deny = ( ) => { throw new DOMException ( "Storage unavailable" , "SecurityError" ) ; } ;
81+ if ( failure === "getter" ) {
82+ Object . defineProperty ( window , "localStorage" , { get : deny } ) ;
83+ } else {
84+ Storage . prototype . getItem = deny ;
85+ Storage . prototype . setItem = deny ;
86+ }
87+ } , storageFailure ) ;
88+ await isolated . route ( `http://127.0.0.1:${ port } /ssh-hosts` , ( route ) => route . fulfill ( {
89+ json : { ok : true , schema_version : "ssh_host_catalog_v0" , hosts : [ ] } ,
90+ } ) ) ;
91+ await isolated . route ( `http://127.0.0.1:${ port } /status.json*` , ( route ) => route . fulfill ( {
92+ json : statusPayload ( "local-goal" , "Local Goal Only" ) ,
93+ } ) ) ;
94+ await isolated . route ( "http://127.0.0.1:8976/status.json*" , ( route ) => route . fulfill ( {
95+ json : statusPayload ( "remote-b-goal" , "Remote B Goal Only" ) ,
96+ } ) ) ;
97+ await isolated . goto ( appUrl , { waitUntil : "networkidle" } ) ;
98+ await isolated . getByText ( "Local Goal Only" , { exact : true } ) . first ( ) . waitFor ( { timeout : 10_000 } ) ;
99+ const select = isolated . getByRole ( "combobox" , { name : "选择控制面来源" } ) ;
100+ if ( await selectedSourceLabel ( select ) !== "本机" ) throw new Error ( `${ storageFailure } : missing local source fallback` ) ;
101+ await isolated . getByRole ( "button" , { name : "添加 SSH 隧道来源" } ) . click ( ) ;
102+ await isolated . getByRole ( "tab" , { name : "手动 URL" } ) . click ( ) ;
103+ await isolated . getByLabel ( "名称" ) . fill ( "Session Remote" ) ;
104+ await isolated . getByLabel ( "本地转发 URL" ) . fill ( "http://127.0.0.1:8976/status.json" ) ;
105+ await isolated . getByRole ( "button" , { name : "添加只读来源" } ) . click ( ) ;
106+ await isolated . getByText ( "Remote B Goal Only" , { exact : true } ) . first ( ) . waitFor ( { timeout : 10_000 } ) ;
107+ await isolated . locator ( ".personal-read-only-source" , { hasText : "Session Remote" } ) . waitFor ( ) ;
108+ await selectSource ( isolated , select , "本机" ) ;
109+ await isolated . getByText ( "Local Goal Only" , { exact : true } ) . first ( ) . waitFor ( { timeout : 10_000 } ) ;
110+ await isolated . reload ( { waitUntil : "networkidle" } ) ;
111+ await isolated . getByText ( "Local Goal Only" , { exact : true } ) . first ( ) . waitFor ( { timeout : 10_000 } ) ;
112+ if ( errors . length ) throw new Error ( `${ storageFailure } : uncaught page errors: ${ errors . join ( "; " ) } ` ) ;
113+ await isolated . close ( ) ;
114+ }
75115 const page = await browser . newPage ( { viewport : { width : 1512 , height : 982 } } ) ;
76116 const state = {
77117 ensureGates : new Map ( ) ,
0 commit comments