Release Vulpes OS 2.7 Preview 25 for Desktop, Android and Pixel 3a
This commit is contained in:
parent
6a44daeaaa
commit
3a1fba4efe
1 changed files with 1301 additions and 196 deletions
|
|
@ -4,17 +4,18 @@ import vm from 'node:vm';
|
|||
import {readFileSync} from 'node:fs';
|
||||
const source=readFileSync(new URL('../gaia/apps/marketplace/marketplace.js',import.meta.url),'utf8');
|
||||
function element(){return Object.assign(new EventTarget(),{style:{},hidden:false,textContent:''});}
|
||||
async function setup() {
|
||||
async function setup(online=true) {
|
||||
const network=new EventTarget(),navigator={language:"en",onLine:online};
|
||||
const nodes=Object.fromEntries(['catalogue','message','confirm','open','browse','install','cancel','status','title','question','permissions'].map(id=>[id,element()]));
|
||||
let poll,download=null,finish;
|
||||
const context={document:{getElementById:id=>nodes[id]},navigator:{language:'en'},console,
|
||||
addEventListener(){},setInterval:fn=>poll=fn,VulpesCompat:{call:async method=>{
|
||||
const context={document:{getElementById:id=>nodes[id]},navigator,console,
|
||||
addEventListener:network.addEventListener.bind(network),setInterval:fn=>poll=fn,VulpesCompat:{call:async method=>{
|
||||
if(method==='locale.current')return 'en';
|
||||
if(method==='marketplace.poll'){const url=download;download=null;return url;}
|
||||
if(method==='marketplace.prepare')return new Promise(resolve=>finish=resolve);
|
||||
}}};
|
||||
await vm.runInNewContext(source,context);
|
||||
return {nodes,poll,setDownload:()=>download='https://vulpes-os.org/marketplace/index.php?download=1',finish:()=>finish({name:'Test',bytes:1024,token:'test'})};
|
||||
return {nodes,poll,setLanguage(value){navigator.language=value;network.dispatchEvent(new Event("languagechange"));},setOnline(value){navigator.onLine=value;network.dispatchEvent(new Event(value?"online":"offline"));},setDownload:()=>download='https://vulpes-os.org/marketplace/index.php?download=1',finish:()=>finish({name:'Test',bytes:1024,token:'test'})};
|
||||
}
|
||||
test('closing the Android web view exposes a way back to the catalogue, not a blank frame',async()=>{
|
||||
const {nodes:n}=await setup();
|
||||
|
|
@ -32,3 +33,45 @@ test('a close notification cannot erase an installation confirmation',async()=>{
|
|||
assert.match(f.nodes.status.textContent,/Checking/);
|
||||
f.finish();await pending;assert.equal(f.nodes.confirm.hidden,false);
|
||||
});
|
||||
|
||||
test('offline catalogue hides its action and reconnects when the network returns',async()=>{
|
||||
const f=await setup(false), n=f.nodes;
|
||||
assert.equal(n.browse.hidden,true);
|
||||
assert.equal(n.catalogue.src,undefined);
|
||||
f.setOnline(true);
|
||||
assert.equal(n.browse.hidden,false);
|
||||
assert.equal(n.catalogue.style.visibility,'visible');
|
||||
f.setOnline(false);
|
||||
assert.equal(n.browse.hidden,true);
|
||||
assert.equal(n.message.hidden,false);
|
||||
});
|
||||
|
||||
test('reopening a closed catalogue navigates the frame again',async()=>{
|
||||
const {nodes:n}=await setup();
|
||||
n.catalogue.dispatchEvent(new Event('mozbrowserclose'));
|
||||
n.catalogue.src='about:blank';
|
||||
n.browse.onclick();
|
||||
assert.match(n.catalogue.src,/mode=app&lang=en/);
|
||||
});
|
||||
|
||||
test('losing connectivity while confirming and cancelling dismisses the dialog',async()=>{
|
||||
const f=await setup();f.setDownload();const pending=f.poll();
|
||||
await new Promise(resolve=>setImmediate(resolve));f.finish();await pending;
|
||||
f.setOnline(false);
|
||||
f.nodes.cancel.onclick();
|
||||
assert.equal(f.nodes.confirm.hidden,true);
|
||||
assert.equal(f.nodes.message.hidden,false);
|
||||
});
|
||||
|
||||
test('the English download confirmation uses MiB',async()=>{
|
||||
const f=await setup();f.setDownload();const pending=f.poll();
|
||||
await new Promise(resolve=>setImmediate(resolve));f.finish();await pending;
|
||||
assert.match(f.nodes.question.textContent,/MiB/);
|
||||
});
|
||||
|
||||
test('changing language before installation completes does not leave the catalogue in the old language',async()=>{
|
||||
const f=await setup();f.setDownload();const pending=f.poll();
|
||||
await new Promise(resolve=>setImmediate(resolve));f.setLanguage('fr');f.finish();await pending;
|
||||
f.nodes.cancel.onclick();
|
||||
assert.match(f.nodes.catalogue.src,/lang=fr/);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue