Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sovereign-intelligence/blob/main/docs/site/evidence/CONVERSATION-PATH-L656/browser_matrix.py # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `sovereign-intelligence / docs / site / evidence / CONVERSATION-PATH-L656 / browser_matrix.py` 90 lines ยท 7021 bytes Raw Blame History 1 # Execute via browser_exec: helpers are injected by the browser harness. 2 import base64 3 import json 4 from pathlib import Path 5 import shutil 6 7 # Bind the real injected helpers explicitly for static analysis as well as execution. 8 cdp = globals()["cdp"] 9 js = globals()["js"] 10 goto_url = globals()["goto_url"] 11 wait_for_load = globals()["wait_for_load"] 12 capture_screenshot = globals()["capture_screenshot"] 13 14 OUT = Path('/Users/drakestapleton/.hermes/cache/scratch/loop13-personal71/evidence/CONVERSATION-PATH-L656/browser/final') 15 OUT.mkdir(parents=True, exist_ok=False) 16 BASE = 'http://127.0.0.1:18731/' 17 cdp('Network.enable') 18 cdp('Network.setBlockedURLs', urls=['https://formsubmit.co/*']) 19 20 def enter(selector): 21 root = cdp('DOM.getDocument')['root']['nodeId'] 22 node = cdp('DOM.querySelector', nodeId=root, selector=selector)['nodeId'] 23 if not node: 24 raise RuntimeError('missing keyboard target: ' + selector) 25 cdp('DOM.focus', nodeId=node) 26 cdp('Input.dispatchKeyEvent', type='keyDown', key='Enter', code='Enter', windowsVirtualKeyCode=13, text='\r', unmodifiedText='\r') 27 cdp('Input.dispatchKeyEvent', type='keyUp', key='Enter', code='Enter', windowsVirtualKeyCode=13) 28 29 def page_probe(expected): 30 # Inspector-injected on-new-document code may run with page JS disabled. 31 # Exercise an actual page script element instead; verify both modes. 32 js('delete window.__l656PageScriptProbe;var s=document.createElement("script");s.textContent="window.__l656PageScriptProbe=123";document.head.appendChild(s);s.remove();') 33 actual = js('window.__l656PageScriptProbe===123') 34 if actual != expected: 35 raise RuntimeError('page script execution mode not proven: ' + str(actual)) 36 return actual 37 38 rows = [] 39 for label, width, height, mobile, enabled in [ 40 ('desktop',1440,900,False,True), ('phone',390,844,True,True), 41 ('desktop',1440,900,False,False), ('phone',390,844,True,False), 42 ]: 43 name = label + ('-js' if enabled else '-nojs') 44 cdp('Emulation.setScriptExecutionDisabled', value=not enabled) 45 cdp('Emulation.setDeviceMetricsOverride', width=width, height=height, deviceScaleFactor=1, mobile=mobile) 46 if not mobile: 47 zoom = cdp('Page.getLayoutMetrics')['visualViewport'].get('zoom',1) 48 cdp('Emulation.setDeviceMetricsOverride', width=round(width*zoom), height=round(height*zoom), deviceScaleFactor=1, mobile=False) 49 goto_url(BASE); wait_for_load() 50 actual_script = page_probe(enabled) 51 home = js('({url:location.href,width:innerWidth,height:innerHeight,scrollWidth:document.documentElement.scrollWidth,qa:window.__qa??null,ctas:Array.from(document.querySelectorAll(".uni-cta a")).map(a=>({name:a.textContent,href:a.getAttribute("href"),rect:a.getBoundingClientRect().toJSON()})),outsideResources:performance.getEntriesByType("resource").filter(r=>new URL(r.name).origin!==location.origin).map(r=>r.name)})') 52 if (home['width'],home['height']) != (width,height) or home['scrollWidth']>width or home['outsideResources']: 53 raise RuntimeError('homepage viewport/resource failure: '+str(home)) 54 shutil.copyfile(capture_screenshot(), OUT/(name+'-home.png')) 55 enter('.uni-cta a[href="/interest"]'); wait_for_load() 56 page_probe(enabled) 57 interest = js('({url:location.href,width:innerWidth,height:innerHeight,scrollWidth:document.documentElement.scrollWidth,qa:window.__qa??null,h1:document.querySelector("h1").textContent,h2Font:getComputedStyle(document.querySelector(".prose h2")).fontSize,forms:document.forms.length,action:document.forms[0].action,method:document.forms[0].method,valid:document.forms[0].checkValidity(),novalidate:document.forms[0].noValidate,descriptionIds:document.getElementById("message").getAttribute("aria-describedby"),labels:Array.from(document.querySelectorAll("form input:not([type=hidden]),form textarea")).map(e=>({name:e.name,label:e.labels?.[0]?.textContent,required:e.required})),mailto:document.querySelector("a[href^=mailto]").getAttribute("href"),outsideResources:performance.getEntriesByType("resource").filter(r=>new URL(r.name).origin!==location.origin).map(r=>r.name)})') 58 if '/interest' not in interest['url'] or (interest['width'],interest['height'])!=(width,height) or interest['scrollWidth']>width or interest['forms']!=1 or interest['valid'] or interest['novalidate'] or interest['outsideResources']: 59 raise RuntimeError('interest-page failure: '+str(interest)) 60 for view in [home,interest]: 61 if view['qa'] and (view['qa']['errors'] or view['qa']['messages']): 62 raise RuntimeError('console failure: '+str(view['qa'])) 63 clip = cdp('Page.getLayoutMetrics')['contentSize'] 64 (OUT/(name+'-interest-full.png')).write_bytes(base64.b64decode(cdp('Page.captureScreenshot', format='png', captureBeyondViewport=True, clip={**clip,'scale':1})['data'])) 65 enter('button[type=submit]') 66 validation = js('({url:location.href,focused:document.activeElement.id,missing:document.getElementById("name").validity.valueMissing,message:document.getElementById("name").validationMessage})') 67 if validation['focused']!='name' or not validation['missing'] or not validation['message'] or '/interest' not in validation['url']: 68 raise RuntimeError('native required-field validation failed: '+str(validation)) 69 tabs = [] 70 for _ in range(3): 71 for typ in ['keyDown','keyUp']: 72 cdp('Input.dispatchKeyEvent', type=typ, key='Tab', code='Tab', windowsVirtualKeyCode=9) 73 tabs.append(js('({id:document.activeElement.id,tag:document.activeElement.tagName,type:document.activeElement.type})')) 74 if [x['id'] for x in tabs[:2]]!=['email','message'] or tabs[2]['tag']!='BUTTON': 75 raise RuntimeError('form keyboard order failed: '+str(tabs)) 76 legacy = [] 77 for target in ['#w-home','#w-aien']: 78 goto_url(BASE); wait_for_load() 79 enter('.uni-cta a[href="'+target+'"]') 80 state = js('({hash:location.hash,visible:getComputedStyle(document.querySelector(location.hash)).display!=="none"&&getComputedStyle(document.querySelector(location.hash)).visibility!=="hidden"})') 81 if state['hash']!=target or not state['visible']: 82 raise RuntimeError('retained keyboard action failed: '+str(state)) 83 legacy.append(state) 84 rows.append({'viewport':label,'javascript':enabled,'page_script_probe_executed':actual_script,'home':home,'interest':interest,'keyboard_enter_navigated':True,'native_empty_submit_refused':validation,'third_party_submission_blocked_during_test':True,'form_tab_order':tabs,'retained_actions_keyboard':legacy}) 85 (OUT/'results.json').write_text(json.dumps(rows,indent=2)+'\n') 86 print(name,'PASS: two pages, contextual Enter, native validation, form tab order, both retained actions') 87 if len({(r['viewport'],r['javascript']) for r in rows})!=4: 88 raise RuntimeError('incomplete matrix') 89 (OUT/'complete.json').write_text(json.dumps({'states':len(rows),'page_views':len(rows)*2,'complete':True,'no_real_submission':True},indent=2)+'\n') 90 print(str(OUT/'phone-nojs-home.png'))