Add scoped native history and window agent controls
This commit is contained in:
1 parent
adf0940e5f
commit
61fcd8336f
27 files changed
+503
-25
No files matched your search
@@ -12,6 +12,16 @@ async function fixture(t, overrides = {}) {
|
||||
const request = (action,args={},headers={})=>requestAgent(api,{action,args},{headers});
|
||||
return {api, request,calls,events};
|
||||
}
|
||||
|
||||
test('new history and window actions use protected transport, strict arguments and projected outputs',async t=>{
|
||||
const snapshotId='00000000-0000-4000-8000-000000000001',entryId='00000000-0000-4000-8000-000000000002';let effects=0;
|
||||
const {request,events}=await fixture(t,{actions:{'history:list':async()=>({snapshotId,entries:[{entryId,title:'Public',url:'https://example.test/',active:false,index:0,pageState:'PRIVATE_NATIVE_STATE'}]}),'history:go':async()=>{effects++;return {completed:true,url:'PRIVATE_TARGET'};},'window:state':async()=>({width:1200,height:800,visible:true,focused:true,minimized:false,maximized:false,fullScreen:false,title:'PRIVATE_WINDOW_TITLE'}),'window:control':async()=>{effects++;return {completed:true,state:{title:'PRIVATE_STATE'}};}}});
|
||||
const list=await request('history:list',{sessionId:'session'});assert.equal(list.status,200);const value=await list.json();assert.equal(JSON.stringify(value).includes('PRIVATE'),false);assert.equal(value.result.entries[0].index,undefined);
|
||||
assert.equal((await request('history:go',{sessionId:'session',snapshotId,entryId})).status,200);
|
||||
assert.equal((await request('window:state')).status,200);assert.equal((await request('window:control',{command:'maximize'})).status,200);
|
||||
for(const [action,args]of [['history:list',{}],['history:go',{sessionId:'session',snapshotId,entryId,index:1}],['history:go',{sessionId:'session',snapshotId:'invalid',entryId}],['window:control',{command:'close'}],['window:state',{title:'PRIVATE'}]])assert.equal((await request(action,args)).status,400);
|
||||
assert.equal(effects,2);assert.ok(events.some(e=>e.action==='history:go'&&e.scope==='history:go'&&e.outcome==='completed'));assert.ok(events.some(e=>e.action==='window:control'&&e.scope==='window:control'&&e.outcome==='completed'));assert.equal(JSON.stringify(events).includes('PRIVATE'),false);
|
||||
});
|
||||
test('postquantum channel refuses plaintext, tampering and replays before adapter execution',async t=>{
|
||||
const {api,calls}=await fixture(t);
|
||||
const headers=(route,body='{}')=>({'Content-Type':'application/json',Authorization:authorization(api.token,route,body)});
|
||||
|
||||
Reference in new issue
Block a user