code wiki / _hdl_build / nx_connect_browser_verify.nx

nx_connect_browser_verify.nx source

↩ module page · 72 lines · 4340 B

1// nx_connect_browser_verify.nx -- verify the LIVE public CONNECT app THROUGH THE NISHI BROWSER ENGINE 2// (operator 2026-07-10: "native nishi os and nishi browser our hardware from each rung up"). This goes 3// one rung deeper than nx_connect_live_verify (which asserts on raw bytes): it drives nx_browser's REAL 4// load_page pipeline -- our TLS 1.3 fetch (redirect-following) -> our HTML->DOM extract -> our CSS layout 5// engine -> a laid-out Page -- and asserts the app actually RENDERED into layout boxes on our hardware. 6// boxes>0 means our browser parsed + laid out the live page; a blank/failed fetch would be 0. 7// Composes nx_browser (no duplication); the SHOT mode of nx_browser.elf produces the matching PNG. 8// license_tier: ORIGINAL expect_exit: 0 9import "nx_browser.nx" 10 11func cbv_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 12func cbv_n(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } 13func cbv_check(pass: i64, label: *u8, fails: *i64) -> i64 { 14 cbv_w(" " as *u8); cbv_w(label); cbv_w(": " as *u8) 15 if pass==1 { cbv_w("PASS\n" as *u8) } else { cbv_w("FAIL\n" as *u8); fails[0]=fails[0]+1 } 16 return 0 17} 18 19func main() -> i64 { 20 let fails: *i64 = sys_mmap(16) as *i64 21 fails[0]=0 22 cbv_w("=== nx_connect_browser_verify -- render nishifamily.com/connect THROUGH the Nishi browser engine ===\n" as *u8) 23 24 // trust store (nxc2-relative real Mozilla bundle), same as nx_browser main 25 var tr: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt\x00" as *u8, 300, 4194304) 26 if tr<=0 { tr = nx_trust_store_load_from_certdata("/tmp/mozilla_certdata.txt\x00" as *u8, 300, 4194304) } 27 if tr<=0 { cbv_w("CA bundle load failed (run from nxc2)\n" as *u8); return 1 } 28 let store: *TrustStore = tr as *TrustStore 29 cbv_w(" CA roots=" as *u8); cbv_n(trust_store_count(store)); cbv_w("\n" as *u8) 30 31 // ephemeral handshake material (fixed = deterministic; own_site_live_test precedent) 32 let cr: *u8 = sys_mmap(32) 33 let priv: *u8 = sys_mmap(32) 34 var z: i64=0 35 while z<32 { cr[z]=(0xC0+z) as u8; priv[z]=(0xA0+z) as u8; z=z+1 } 36 37 let url: *u8 = "https://nishifamily.com/connect\x00" as *u8 38 let ulen: i64 = 31 39 let page: *Page = sys_mmap(NX_PAGE_BYTES) as *Page 40 41 // THE FULL BROWSER PIPELINE: our TLS fetch -> DOM extract -> layout 42 let rc: i64 = load_page(url, ulen, store, cr, priv, page, 1000) 43 cbv_w(" load_page rc=" as *u8); cbv_n(rc) 44 cbv_w(" page.ok=" as *u8); cbv_n(page.ok) 45 cbv_w(" boxes=" as *u8); cbv_n(page.tree.count) 46 cbv_w(" page_h=" as *u8); cbv_n(page.page_h); cbv_w("\n" as *u8) 47 48 // T1: the fetch+parse+layout succeeded end to end (our TLS, our engine) 49 var t1: i64=0 50 if rc==0 { if page.ok==1 { t1=1 } } 51 cbv_check(t1, "T1 Nishi browser fetched + parsed + laid out /connect over our TLS (rc=0, page.ok=1)" as *u8, fails) 52 53 // T2: real content RENDERED -- a non-trivial layout tree (a blank/failed page would be ~0 boxes). 54 // /connect is a rich app (partners, chat, events, poll) -> tens-to-hundreds of boxes. 55 var t2: i64=0 56 if page.tree.count > 50 { t2=1 } 57 // The label must NOT bake a measurement: it read "measured 161" long after the real count had become 58 // 89, so the gate was printing a stale number as if it were this run's result. The live count is 59 // already emitted above -- the assertion states its THRESHOLD, never a remembered value. 60 cbv_check(t2, "T2 the app rendered into a real layout tree (threshold >50 boxes; live count printed above)" as *u8, fails) 61 62 // T3: the page laid out to a real height (content flowed, not a zero-height blank) 63 var t3: i64=0 64 if page.page_h > 300 { t3=1 } 65 cbv_check(t3, "T3 content flowed to a real page height (>300px)" as *u8, fails) 66 67 cbv_w(" fails=" as *u8); cbv_n(fails[0]); cbv_w("\n" as *u8) 68 if fails[0]==0 { cbv_w("VERDICT: GREEN (our own browser engine renders the live public /connect app -- fetch+DOM+layout, our hardware, no WebFetch)\n" as *u8); sys_exit(0) } 69 cbv_w("VERDICT: RED\n" as *u8) 70 sys_exit(1) 71 return 1 72}