WIP IV improve UX [snapshot task 2]
This commit is contained in:
1 parent
28c90d1d71
commit
58c3e2af86
16 files changed
+779
-36
No files matched your search
+146
-1
@@ -125,7 +125,7 @@ const enableTurn = (session: string) => evaluate(session, () => {
|
||||
const checkbox = window.__hellcon.element<HTMLInputElement>('.checkbox input');
|
||||
if (!checkbox.checked) checkbox.click();
|
||||
});
|
||||
async function connect(sender: string, receiver: string, size: number) {
|
||||
async function connect(sender: string, receiver: string, size: number, changedIdentity = false) {
|
||||
await evaluate(sender, (size: number) => window.__hellcon.chooseFile(size, 'browser-test.bin'), size);
|
||||
await input(sender, '#stun-provider', provider);
|
||||
await input(receiver, '#stun-provider', provider);
|
||||
@@ -150,6 +150,7 @@ async function connect(sender: string, receiver: string, size: number) {
|
||||
const rf = await evaluate(receiver, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent));
|
||||
assert.equal(sf[0], rf[1]); assert.equal(sf[1], rf[0]); assert.equal(sf[0]?.split(' ').length, 32);
|
||||
assert.equal(await evaluate(receiver, () => !!document.querySelector('.incoming')), false);
|
||||
if (changedIdentity) assert.ok(await evaluate(sender, () => document.body.textContent?.includes('Device identity differs from the expected contact')));
|
||||
await click(sender, 'Both fingerprints match — confirm');
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
assert.equal(await evaluate(receiver, () => !!document.querySelector('.incoming')), false);
|
||||
@@ -324,6 +325,150 @@ try {
|
||||
await click(receiver, 'Receive in memory (up to 64 MiB)');
|
||||
await wait(sender, () => window.__hellcon.element('[role=status]').textContent?.includes('confirmed the complete file'));
|
||||
console.log('PASS: fresh code exchange after a failed transfer succeeds without reloading either page.');
|
||||
if (!turn) {
|
||||
const identitySender = await page();
|
||||
const identityReceiver = await page(origin.replace('127.0.0.1', 'localhost'));
|
||||
await click(identityReceiver, 'Receive');
|
||||
for (const session of [identitySender, identityReceiver]) {
|
||||
await evaluate(session, () => { const details = [...document.querySelectorAll('details')].find(el => el.querySelector('summary')?.textContent === 'Remembered devices'); if (details) details.open = true; });
|
||||
await wait(session, () => [...document.querySelectorAll('button')].some(button => button.textContent === 'Create device identity' && !button.disabled));
|
||||
await click(session, 'Create device identity');
|
||||
await wait(session, () => document.querySelector<HTMLInputElement>('#use-device-identity')?.checked);
|
||||
}
|
||||
await connect(identitySender, identityReceiver, 2048);
|
||||
for (const session of [identitySender, identityReceiver]) {
|
||||
await wait(session, () => !!document.querySelector('#contact-name'));
|
||||
await input(session, '#contact-name', 'Paired device');
|
||||
await click(session, 'Remember device');
|
||||
await wait(session, () => !document.querySelector('#contact-name'));
|
||||
}
|
||||
await checkAccessibility(identitySender, 'remembered identity');
|
||||
await click(identityReceiver, 'Receive in memory (up to 64 MiB)');
|
||||
await wait(identitySender, () => document.body.textContent?.includes('The receiver confirmed the complete file.'));
|
||||
await click(identitySender, 'Disconnect');
|
||||
await wait(identityReceiver, () => [...document.querySelectorAll('button')].some(button => button.textContent === 'Reset'));
|
||||
// Reload both pages to exercise persisted CryptoKeys and contacts.
|
||||
for (const [session, url] of [[identitySender, origin], [identityReceiver, origin.replace('127.0.0.1', 'localhost')]]) {
|
||||
await call('Page.navigate', { url }, session);
|
||||
await wait(session, () => !!document.querySelector('#stun-provider'));
|
||||
}
|
||||
await click(identityReceiver, 'Receive');
|
||||
for (const session of [identitySender, identityReceiver]) {
|
||||
await wait(session, () => !!document.querySelector('#use-device-identity'));
|
||||
assert.equal(await evaluate(session, () => document.querySelector<HTMLInputElement>('#use-device-identity')!.checked), false, 'Reload defaults to a temporary connection');
|
||||
await evaluate(session, () => document.querySelector<HTMLInputElement>('#use-device-identity')!.click());
|
||||
const key = await evaluate(session, () => document.querySelector<HTMLSelectElement>('#expected-device')!.options[1]!.value);
|
||||
await input(session, '#expected-device', key);
|
||||
await input(session, '#stun-provider', 'none');
|
||||
}
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(4096, 'remembered.bin'));
|
||||
await click(identitySender, 'Create code'); await wait(identitySender, () => !!document.querySelector('#output-code'));
|
||||
const offer = await evaluate(identitySender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
|
||||
assert.equal(JSON.parse(atob(offer)).version, 4);
|
||||
await input(identityReceiver, '#offer-input', offer); await click(identityReceiver, 'Accept & create answer');
|
||||
await wait(identityReceiver, () => !!document.querySelector('#output-code'));
|
||||
const answer = await evaluate(identityReceiver, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
|
||||
await input(identitySender, '#answer-input', answer); await click(identitySender, 'Connect');
|
||||
await wait(identityReceiver, () => !!document.querySelector('.incoming'));
|
||||
for (const session of [identitySender, identityReceiver]) assert.ok(await evaluate(session, () => document.body.textContent?.includes('Remembered device authenticated')));
|
||||
await click(identityReceiver, 'Receive in memory (up to 64 MiB)');
|
||||
await wait(identitySender, () => document.body.textContent?.includes('The receiver confirmed the complete file.'));
|
||||
const rememberedBytes = await evaluate(identityReceiver, async () => { const bytes = new Uint8Array(await (await fetch(window.__hellcon.element<HTMLAnchorElement>('a.download').href)).arrayBuffer()); return { length: bytes.length, valid: bytes.every(byte => byte === 123) }; });
|
||||
assert.deepEqual(rememberedBytes, { length: 4096, valid: true });
|
||||
console.log('PASS: identities and contacts persist across reload; fresh mutual proofs authenticate remembered devices and transfer exact bytes without manual reconfirmation.');
|
||||
|
||||
await click(identitySender, 'Disconnect');
|
||||
await wait(identityReceiver, () => !document.querySelector('.incoming'));
|
||||
await click(identitySender, 'Reset'); await click(identityReceiver, 'Reset');
|
||||
for (const forgottenSide of [identitySender, identityReceiver]) {
|
||||
const editor = await page(forgottenSide === identitySender ? origin : origin.replace('127.0.0.1', 'localhost'));
|
||||
await wait(editor, () => !!document.querySelector('#expected-device'));
|
||||
await click(editor, 'Forget');
|
||||
await wait(editor, () => document.querySelector<HTMLSelectElement>('#expected-device')?.options.length === 1);
|
||||
assert.ok(await evaluate(forgottenSide, () => document.querySelector<HTMLSelectElement>('#expected-device')!.value), 'Original tab still has the stale expected contact before connection setup');
|
||||
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(128, 'forgotten-contact.bin'));
|
||||
await click(identitySender, 'Create code'); await wait(identitySender, () => !!document.querySelector('#output-code'));
|
||||
const freshOffer = await evaluate(identitySender, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
|
||||
await input(identityReceiver, '#offer-input', freshOffer); await click(identityReceiver, 'Accept & create answer');
|
||||
await wait(identityReceiver, () => !!document.querySelector('#output-code'));
|
||||
const freshAnswer = await evaluate(identityReceiver, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
|
||||
await input(identitySender, '#answer-input', freshAnswer); await click(identitySender, 'Connect');
|
||||
await wait(forgottenSide, () => document.body.textContent?.includes('New device. Compare both fingerprints manually'));
|
||||
assert.equal(await evaluate(forgottenSide, () => document.querySelector<HTMLSelectElement>('#expected-device')!.value), '');
|
||||
assert.equal(await evaluate(forgottenSide, () => document.querySelector<HTMLSelectElement>('#expected-device')!.options.length), 1);
|
||||
assert.equal(await evaluate(identityReceiver, () => !!document.querySelector('.incoming')), false, 'Forgotten trust must not release file metadata');
|
||||
await click(forgottenSide, 'Both fingerprints match — confirm');
|
||||
await wait(identityReceiver, () => !!document.querySelector('.incoming'));
|
||||
await click(identityReceiver, 'Receive in memory (up to 64 MiB)');
|
||||
await wait(identitySender, () => document.body.textContent?.includes('The receiver confirmed the complete file.'));
|
||||
await input(forgottenSide, '#contact-name', 'Paired device'); await click(forgottenSide, 'Remember device');
|
||||
await wait(forgottenSide, () => !document.querySelector('#contact-name'));
|
||||
await click(identitySender, 'Disconnect');
|
||||
await wait(identityReceiver, () => !document.querySelector('.incoming'));
|
||||
await click(identitySender, 'Reset'); await click(identityReceiver, 'Reset');
|
||||
const key = await evaluate(forgottenSide, () => document.querySelector<HTMLSelectElement>('#expected-device')!.options[1]!.value);
|
||||
await input(forgottenSide, '#expected-device', key);
|
||||
}
|
||||
console.log('PASS: forgetting a device in another tab removes stale trust before either role reconnects; manual confirmation gates metadata and permits pairing again.');
|
||||
|
||||
await evaluate(identitySender, () => { indexedDB.open = () => { throw new DOMException('Storage denied during refresh', 'SecurityError'); }; });
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(1, 'storage-failure.bin'));
|
||||
await click(identitySender, 'Create code');
|
||||
await wait(identitySender, () => document.body.textContent?.includes('Storage denied during refresh'));
|
||||
assert.equal(await evaluate(identitySender, () => !!document.querySelector('#output-code')), false, 'Failed storage refresh must not use cached trust');
|
||||
await evaluate(identitySender, () => { Reflect.deleteProperty(indexedDB, 'open'); });
|
||||
await click(identitySender, 'Reset');
|
||||
console.log('PASS: unreadable storage during connection setup cannot reuse a cached identity or contact.');
|
||||
|
||||
await evaluate(identityReceiver, () => {
|
||||
const label = [...document.querySelectorAll('label')].find(el => el.textContent?.includes('Replace or delete'));
|
||||
label?.querySelector<HTMLInputElement>('input')?.click();
|
||||
});
|
||||
await click(identityReceiver, 'Delete identity and contacts');
|
||||
await wait(identityReceiver, () => [...document.querySelectorAll('button')].some(button => button.textContent === 'Create device identity'));
|
||||
await click(identityReceiver, 'Create device identity');
|
||||
await wait(identityReceiver, () => document.querySelector<HTMLInputElement>('#use-device-identity')?.checked);
|
||||
await connect(identitySender, identityReceiver, 512, true);
|
||||
await click(identityReceiver, 'Receive in memory (up to 64 MiB)');
|
||||
await wait(identitySender, () => document.body.textContent?.includes('The receiver confirmed the complete file.'));
|
||||
assert.equal(await evaluate(identitySender, () => document.querySelector<HTMLSelectElement>('#expected-device')!.options.length), 2, 'Changed identity must not replace or append saved contacts automatically');
|
||||
console.log('PASS: replaced peer identity requires manual comparison and preserves the original saved contact.');
|
||||
const stale = await page();
|
||||
await wait(stale, () => !!document.querySelector('#use-device-identity'));
|
||||
await evaluate(stale, async () => {
|
||||
const db = await new Promise<IDBDatabase>((resolve, reject) => { const request = indexedDB.open('hellcon-devices', 1); request.onsuccess = () => resolve(request.result); request.onerror = () => reject(request.error); });
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const tx = db.transaction('settings', 'readwrite'), store = tx.objectStore('settings'), request = store.get('state');
|
||||
request.onsuccess = () => store.put({ ...request.result, revision: crypto.randomUUID() }, 'state');
|
||||
tx.oncomplete = () => resolve(); tx.onabort = () => reject(tx.error);
|
||||
}); db.close();
|
||||
});
|
||||
await click(stale, 'Forget');
|
||||
await wait(stale, () => document.body.textContent?.includes('Device settings changed in another tab'));
|
||||
await evaluate(stale, async () => {
|
||||
const db = await new Promise<IDBDatabase>(resolve => { const request = indexedDB.open('hellcon-devices', 1); request.onsuccess = () => resolve(request.result); });
|
||||
await new Promise<void>(resolve => { const tx = db.transaction('settings', 'readwrite'); tx.objectStore('settings').put({ identity: null, contacts: 'broken', revision: 'broken' }, 'state'); tx.oncomplete = () => resolve(); }); db.close();
|
||||
});
|
||||
await call('Page.navigate', { url: origin }, stale);
|
||||
await wait(stale, () => document.body.textContent?.includes('Invalid contact list'));
|
||||
await evaluate(stale, () => [...document.querySelectorAll('label')].find(label => label.textContent?.includes('Delete unreadable device storage'))?.querySelector<HTMLInputElement>('input')?.click());
|
||||
await click(stale, 'Clear device storage');
|
||||
await wait(stale, () => [...document.querySelectorAll('button')].some(button => button.textContent === 'Create device identity' && !button.disabled));
|
||||
console.log('PASS: stale contact edits cannot overwrite newer settings; unreadable storage can be cleared with explicit consent.');
|
||||
const denied = await page();
|
||||
await call('Page.addScriptToEvaluateOnNewDocument', { source: "indexedDB.open = () => { throw new DOMException('Storage denied', 'SecurityError'); };" }, denied);
|
||||
await call('Page.navigate', { url: origin }, denied);
|
||||
await wait(denied, () => document.body.textContent?.includes('Storage denied'));
|
||||
await evaluate(denied, () => window.__hellcon.chooseFile(1, 'temporary.bin'));
|
||||
await input(denied, '#stun-provider', 'none'); await click(denied, 'Create code');
|
||||
await wait(denied, () => !!document.querySelector('#output-code'));
|
||||
const temporary = await evaluate(denied, () => window.__hellcon.element<HTMLTextAreaElement>('#output-code').value);
|
||||
assert.equal(JSON.parse(atob(temporary)).version, 3);
|
||||
await click(denied, 'Cancel connection');
|
||||
console.log('PASS: denied identity storage still allows temporary v3 connection setup.');
|
||||
|
||||
}
|
||||
if (turn) console.log(`PASS: forced TURN over ${transport.toUpperCase()}, relay candidates at both ends, exact file bytes and receipt.`);
|
||||
assert.deepEqual(browserErrors, []);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user