"""Run against desktop-driver.mjs with a maximized Default-profile Browser panel.
The local HTTPS service is running on 18443. Its cookies/approvals were cleared
through Preview menu > Clear cookies before each recording. No TLS flags are used.
Native button coordinates apply to the un-decorated Linux Xvfb warning.
"""
import urllib.request,json,time,sys
port=int(sys.argv[1])
def call(ep,data={}):
 r=urllib.request.urlopen(urllib.request.Request(f'http://127.0.0.1:{port}/{ep}',json.dumps(data).encode()))
 v=json.loads(r.read());print(ep,v,flush=True);return v
call('record',{'label':'concise-proof'})
call('click',{'name':'Refresh'})
time.sleep(3)
# Cancel the native warning where offered; on base this point has only the error page.
call('native',{'args':['mousemove','480','248','click','1']})
time.sleep(2)
call('capture',{'label':'proof-cancel'})
call('click',{'name':'Refresh'})
time.sleep(3)
# Trust and Remember where offered; on base no native approval exists.
call('native',{'args':['mousemove','160','248','click','1']})
time.sleep(3)
call('capture',{'label':'proof-result'})
call('stop-record')
