WIP V improve UX [snapshot task 2]
This commit is contained in:
1 parent
5f8c6a1916
commit
a73b3075b6
16 files changed
+238
-232
No files matched your search
+63
-46
@@ -159,11 +159,19 @@ async function connect(sender: string, receiver: string, size: number, changedId
|
||||
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);
|
||||
await click(receiver, 'Both fingerprints match — confirm');
|
||||
if (changedIdentity) {
|
||||
// The receiver still trusts the unchanged sender and verifies automatically;
|
||||
// the sender must compare manually and is not offered a silent replacement.
|
||||
assert.ok(await evaluate(sender, () => document.body.textContent?.includes('Device identity differs from the paired device')));
|
||||
assert.equal(await evaluate(sender, () => [...document.querySelectorAll('.fingerprint label')].find(el => el.textContent?.includes('Replace the paired device'))?.querySelector('input')?.checked), false);
|
||||
await wait(receiver, () => document.body.textContent?.includes('Verification submitted'));
|
||||
await click(sender, 'Both fingerprints match — confirm');
|
||||
} else {
|
||||
await click(sender, 'Both fingerprints match — confirm');
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
assert.equal(await evaluate(receiver, () => !!document.querySelector('.incoming')), false);
|
||||
await click(receiver, 'Both fingerprints match — confirm');
|
||||
}
|
||||
await wait(receiver, () => !!document.querySelector('.incoming'));
|
||||
if (turn) {
|
||||
for (const session of [sender, receiver]) {
|
||||
@@ -457,39 +465,44 @@ try {
|
||||
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'));
|
||||
const receiverOrigin = origin.replace('127.0.0.1', 'localhost');
|
||||
const identityReceiver = await page(receiverOrigin);
|
||||
await click(identityReceiver, 'Receive');
|
||||
const pairedKey = (session: string) => evaluate(session, () => document.querySelector('.device-settings code')?.textContent || '');
|
||||
// Clears the paired device directly in storage, so this tab is not notified.
|
||||
const forgetQuietly = (session: string) => evaluate(session, async () => {
|
||||
const db = await new Promise<IDBDatabase>((resolve, reject) => { const request = indexedDB.open('hellcon-connections', 1); request.onsuccess = () => resolve(request.result); request.onerror = () => reject(request.error); });
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const tx = db.transaction('connections', 'readwrite'), store = tx.objectStore('connections'), request = store.getAll();
|
||||
request.onsuccess = () => { for (const record of request.result) store.put({ ...record, peerKey: '' }); };
|
||||
tx.oncomplete = () => resolve(); tx.onabort = () => reject(tx.error);
|
||||
}); db.close();
|
||||
});
|
||||
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 evaluate(session, () => { const details = [...document.querySelectorAll('details')].find(el => el.querySelector('summary')?.textContent === 'Remembered device'); 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 wait(session, () => document.querySelector<HTMLInputElement>('#remember-device')?.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 wait(session, () => document.body.textContent?.includes('Remembered for Con 1'));
|
||||
await wait(session, () => !!document.querySelector('.device-settings code'));
|
||||
}
|
||||
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')]]) {
|
||||
// Reload both pages to exercise persisted CryptoKeys and paired connections.
|
||||
for (const [session, url] of [[identitySender, origin], [identityReceiver, receiverOrigin]]) {
|
||||
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);
|
||||
assert.equal(await evaluate(session, () => document.querySelector<HTMLSelectElement>('#expected-device')!.value), key, 'The slot preselects its saved trusted peer after reload');
|
||||
await input(session, '#expected-device', key);
|
||||
await wait(session, () => !!document.querySelector('.device-settings code'));
|
||||
assert.equal(await evaluate(session, () => !!document.querySelector('#remember-device')), false, 'A paired connection shows its device instead of the opt-in');
|
||||
await input(session, '#stun-provider', 'none');
|
||||
}
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(4096, 'remembered.bin'));
|
||||
@@ -501,24 +514,21 @@ try {
|
||||
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')));
|
||||
for (const session of [identitySender, identityReceiver]) assert.ok(await evaluate(session, () => document.body.textContent?.includes('Paired 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.');
|
||||
console.log('PASS: identities and paired connections persist across reload; fresh mutual proofs authenticate the paired device 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 forgetQuietly(forgottenSide);
|
||||
assert.ok(await pairedKey(forgottenSide), 'Original tab still shows the stale paired device before connection setup');
|
||||
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(128, 'forgotten-contact.bin'));
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(128, 'forgotten-device.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');
|
||||
@@ -526,22 +536,19 @@ try {
|
||||
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 pairedKey(forgottenSide), '', 'Connection setup re-reads the forgotten pairing');
|
||||
assert.equal(await evaluate(forgottenSide, () => [...document.querySelectorAll('.fingerprint label')].find(el => el.textContent?.includes('Remember this device for Con 1'))?.querySelector('input')?.checked), true);
|
||||
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 wait(forgottenSide, () => !!document.querySelector('.device-settings code'));
|
||||
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.');
|
||||
console.log('PASS: forgetting a device in another tab removes stale trust before either role reconnects; manual confirmation gates metadata and pairs the connection again.');
|
||||
|
||||
await evaluate(identitySender, () => { indexedDB.open = () => { throw new DOMException('Storage denied during refresh', 'SecurityError'); }; });
|
||||
await evaluate(identitySender, () => window.__hellcon.chooseFile(1, 'storage-failure.bin'));
|
||||
@@ -550,23 +557,32 @@ try {
|
||||
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.');
|
||||
console.log('PASS: unreadable storage during connection setup cannot reuse a cached identity or paired device.');
|
||||
|
||||
const senderPaired = await pairedKey(identitySender);
|
||||
await evaluate(identityReceiver, () => {
|
||||
const label = [...document.querySelectorAll('label')].find(el => el.textContent?.includes('Delete this browser’s identity'));
|
||||
const label = [...document.querySelectorAll('label')].find(el => el.textContent?.includes('Delete this browser’s device identity'));
|
||||
label?.querySelector<HTMLInputElement>('input')?.click();
|
||||
});
|
||||
await click(identityReceiver, 'Delete identity and contacts');
|
||||
await click(identityReceiver, 'Delete device identity');
|
||||
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 wait(identityReceiver, () => !!document.querySelector('.device-settings code'));
|
||||
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.');
|
||||
assert.ok(await evaluate(identitySender, () => document.body.textContent?.includes('This device was not remembered.')));
|
||||
assert.equal(await pairedKey(identitySender), senderPaired, 'Changed identity must not replace the paired device automatically');
|
||||
console.log('PASS: replaced peer identity requires manual comparison and preserves the paired device.');
|
||||
await click(identitySender, 'Disconnect');
|
||||
await wait(identityReceiver, () => !document.querySelector('.incoming'));
|
||||
await click(identitySender, 'Reset'); await click(identityReceiver, 'Reset');
|
||||
const stale = await page();
|
||||
await wait(stale, () => !!document.querySelector('#use-device-identity'));
|
||||
await wait(stale, () => !!document.querySelector('.device-settings code'));
|
||||
await click(stale, 'Forget device');
|
||||
await wait(stale, () => document.querySelector<HTMLInputElement>('#remember-device')?.checked);
|
||||
await wait(identitySender, () => document.querySelector<HTMLInputElement>('#remember-device')?.checked);
|
||||
console.log('PASS: Forget device keeps the per-connection opt-in and reaches other tabs.');
|
||||
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) => {
|
||||
@@ -575,18 +591,19 @@ try {
|
||||
tx.oncomplete = () => resolve(); tx.onabort = () => reject(tx.error);
|
||||
}); db.close();
|
||||
});
|
||||
await click(stale, 'Forget');
|
||||
await evaluate(stale, () => [...document.querySelectorAll('label')].find(el => el.textContent?.includes('Delete this browser’s device identity'))?.querySelector<HTMLInputElement>('input')?.click());
|
||||
await click(stale, 'Delete device identity');
|
||||
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 new Promise<void>(resolve => { const tx = db.transaction('settings', 'readwrite'); tx.objectStore('settings').put({ identity: { publicKey: '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 wait(stale, () => document.body.textContent?.includes('Invalid device identity'));
|
||||
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.');
|
||||
console.log('PASS: stale identity 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);
|
||||
|
||||
Reference in new issue
Block a user