nx_lds_page_grade.nx source
↩ module page · 48 lines · 3042 B
1// nx_lds_page_grade.nx -- benchmark the LDS test UI by COMPOSING the sovereign UX/CX grader.
2// Reads web_assets/lds_connect.html and runs the real nx_uxcx_grade byte-scan checks against it
3// (no reinvention -- imports uxg_* directly). Reports the 7 page structural/a11y/sovereignty checks
4// (the ones that apply to a static page) + the 4 interactive SPA-state checks (which a static
5// marketing page has no views for) + the raw uxg_grade_full permil, honestly. license_tier: ORIGINAL expect_exit: 0
6import "nx_syscalls_x86_64.nx"
7import "nx_uxcx_grade.nx"
8
9func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=0 { n=n+1 } sys_write(1,s,n); return 0 }
10func gn(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-(m/10)*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 }
11func grow(name: *u8, ok: i64) -> i64 { gw(" " as *u8); gw(name); gw(": " as *u8); if ok==1 { gw("PASS\n" as *u8) } else { gw("FAIL\n" as *u8) } return 0 }
12
13func main() -> i64 {
14 let len_p: *i64 = sys_mmap(8) as *i64
15 let html: *u8 = sys_read_file_x86_64("web_assets/lds_connect.html" as *u8, len_p)
16 if html == (0 as *u8) { gw("cannot read web_assets/lds_connect.html\n" as *u8); return 5 }
17 let hn: i64 = len_p[0]
18
19 gw("=== nx_lds_page_grade -- grading web_assets/lds_connect.html via nx_uxcx_grade ===\n" as *u8)
20 gw("-- PAGE: structural / accessibility / sovereignty (applies to a static page) --\n" as *u8)
21 let e1: i64 = uxg_escaping_ok(html,hn)
22 let e2: i64 = uxg_viewport_ok(html,hn)
23 let e3: i64 = uxg_skiplink_ok(html,hn)
24 let e4: i64 = uxg_lang_ok(html,hn)
25 let e5: i64 = uxg_title_ok(html,hn)
26 let e6: i64 = uxg_nav_ok(html,hn)
27 let e7: i64 = uxg_sovereign_ok(html,hn)
28 grow("escaping (no double-encode)" as *u8, e1)
29 grow("viewport (width=device-width)" as *u8, e2)
30 grow("skip-link (bypass blocks)" as *u8, e3)
31 grow("lang attribute" as *u8, e4)
32 grow("title" as *u8, e5)
33 grow("nav landmark" as *u8, e6)
34 grow("sovereign (no external src=)" as *u8, e7)
35 var pp: i64 = e1+e2+e3+e4+e5+e6+e7
36 gw(" PAGE dimension = " as *u8); gn((pp*1000)/7); gw(" / 1000 (" as *u8); gn(pp); gw("/7)\n" as *u8)
37
38 gw("-- interactive SPA-state checks (a static landing page has no async views) --\n" as *u8)
39 grow("back-nav (no buggy history.back)" as *u8, uxg_back_ok(html,hn))
40 grow("loading state" as *u8, uxg_loading_ok(html,hn))
41 grow("error state" as *u8, uxg_error_ok(html,hn))
42 grow("empty state" as *u8, uxg_empty_ok(html,hn))
43
44 gw(" FULL 11-check permil (uxg_grade_full) = " as *u8); gn(uxg_grade_full(html,hn,html,hn)); gw(" / 1000\n" as *u8)
45 gw(" NOTE: the 3 SPA-state checks (loading/error/empty) assume an interactive JS app; a static\n" as *u8)
46 gw(" marketing page has no such views, so they read N/A here -- the PAGE dimension is the honest score.\n" as *u8)
47 return 0
48}