gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita22d2daaa22d2daaident#31: the sign-in frame is no taller than the tallest step needs (plain CSS height per width), gate check for itmrea22d2daa/tests/signin.mjs

23.3 KB

  1. // tests/signin.mjs — THE GATE OF ident#31: signing in to ident INSIDE the identity selector's panel. Real headless Chrome (tests/cdp.mjs).
  2. // A signed-out visitor opens the selector on an app's page: the panel holds ident's /embed/signin in an iframe (email → code → identity,
  3. // "This signs you in to ident."); choosing an identity takes the whole page to the app's return URL with ident_code and the app logs
  4. // the user in. A NEW address is sent on to ident in the same tab (/signin/<rid>/welcome), names/picks its identity there and is sent back.
  5. // Framing is allowed for the app's registered origins only. Own servers (NEVER the dev server, NEVER real mail):
  6. // ident :8700 (IDENT_MAIL_SINK), test app A :8701 (registered), an unregistered origin :8702 that frames the sign-in page
  7. // Chrome debug ports 8710-8719. Storage .scratch/signin-gate (wiped at start). Shots .scratch/signin-*.png (390 and 1280 px).
  8. // Run: node tests/signin.mjs (SIGNIN_GATE_APP=<other checkout> runs the same checks against that code, e.g. main: they must fail)
  9. import { spawn } from 'node:child_process';
  10. import { createServer } from 'node:http';
  11. import { readFileSync, writeFileSync, rmSync, mkdirSync, existsSync } from 'node:fs';
  12. import { dirname, join } from 'node:path';
  13. import { fileURLToPath } from 'node:url';
  14. import { launchBrowser, sleep } from './cdp.mjs';
  15. if (!process.env.HL_CHROME && existsSync('/opt/google/chrome/chrome')) process.env.HL_CHROME = '/opt/google/chrome/chrome';
  16. const APP = process.env.SIGNIN_GATE_APP || join(dirname(fileURLToPath(import.meta.url)), '..');
  17. const G = join(APP, '.scratch/signin-gate');
  18. const SHOTS = process.env.SIGNIN_SHOTS || join(APP, '.scratch');
  19. mkdirSync(SHOTS, { recursive: true });
  20. const P0 = Number(process.env.SIGNIN_GATE_PORT || 8700);
  21. const ID = 'http://127.0.0.1:' + P0, TA = 'http://127.0.0.1:' + (P0 + 1), EVIL = 'http://127.0.0.1:' + (P0 + 2);
  22. const CHROME_PORTS = (process.env.SIGNIN_GATE_CHROME || '8710-8719').split('-').map(Number);
  23. const J = JSON.stringify;
  24. let passed = 0, failed = 0;
  25. const check = (name, ok, detail = '') => { if (ok) { passed++; console.log(' ok ' + name); } else { failed++; console.log(' FAIL ' + name + (detail ? ' — ' + detail : '')); } };
  26. const procs = [];
  27. function start(cwd, env, log) {
  28. const p = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd, env: { ...process.env, SMTP_HOST: '', SMTP_USER: '', SMTP_PASSWORD: '', ...env }, stdio: ['ignore', 'pipe', 'pipe'] });
  29. let out = ''; p.stdout.on('data', d => { out += d; }); p.stderr.on('data', d => { out += d; });
  30. p.on('exit', () => writeFileSync(join(G, log), out));
  31. p.getOut = () => out; p.logName = log;
  32. procs.push(p); return p;
  33. }
  34. async function up(url) {
  35. for (const end = Date.now() + Number(process.env.IDENT_COLD_MS || 120000); Date.now() < end;) { try { await fetch(url + '/', { redirect: 'manual' }); return; } catch {} await sleep(250); }
  36. throw new Error('server did not come up: ' + url);
  37. }
  38. rmSync(G, { recursive: true, force: true });
  39. mkdirSync(join(G, 'main'), { recursive: true });
  40. start(APP, { IDENT_PORT: String(P0), IDENT_STORAGE: join(G, 'main', 'ident'), IDENT_SESSIONS: join(G, 'main', 'sess') + '/', IDENT_MAIL_SINK: join(G, 'main', 'mail.txt'), IDENT_IP_LIMIT: '1000', IDENT_IP_DAY_LIMIT: '1000' }, 'ident.log');
  41. start(join(APP, 'testapp'), { TESTAPP_PORT: String(P0 + 1), TESTAPP_URL: TA, IDENT_URL: ID, TESTAPP_STORE: join(G, 'testapp-a.json') }, 'testapp.log');
  42. let evilKey = '';
  43. const evil = createServer((req, res) => {
  44. res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
  45. res.end(`<!doctype html><html><head><meta charset="utf-8"><title>not registered</title></head><body style="background:#222"><iframe id="f" width="360" height="400" src="${ID}/embed/signin?key=${evilKey}&return=${encodeURIComponent(TA + '/callback')}"></iframe></body></html>`);
  46. });
  47. await new Promise(r => evil.listen(P0 + 2, '127.0.0.1', r));
  48. await Promise.all([up(ID), up(TA)]);
  49. const lastCode = (email) => {
  50. const lines = readFileSync(join(G, 'main', 'mail.txt'), 'utf8').trim().split('\n').filter(l => l.startsWith(email + ' '));
  51. return lines.length ? lines[lines.length - 1].split(' ')[1] : null;
  52. };
  53. const sh = (hostSel, expr) => `(() => { const h = document.querySelector(${J(hostSel)}); const r = h && h.shadowRoot; if (!r) return null; return (${expr}); })()`;
  54. async function ready(p) { await p.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { label: 'hydrated' }); }
  55. async function viewport(p, w) { await p.send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 500 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 500 }); }
  56. // ---- driving the IFRAME: its JS worlds come from Runtime.executionContextCreated, its pointer input is the top page's -------------
  57. const worlds = new Map(); // sessionId → Map(frameId → contextId of the page's main world)
  58. function trackWorlds(p) {
  59. const m = new Map(); worlds.set(p, m);
  60. p.conn.onEvent((msg) => {
  61. if (msg.sessionId !== p.sessionId) return;
  62. const c = msg.params && msg.params.context;
  63. if (msg.method === 'Runtime.executionContextCreated' && c && c.auxData && c.auxData.isDefault) m.set(c.auxData.frameId, c.id);
  64. if (msg.method === 'Runtime.executionContextDestroyed') for (const [f, id] of m) if (id === msg.params.executionContextId) m.delete(f);
  65. if (msg.method === 'Runtime.executionContextsCleared') m.clear();
  66. });
  67. return p.send('Runtime.enable');
  68. }
  69. async function childFrame(p) {
  70. const t = await p.send('Page.getFrameTree');
  71. const c = (t.frameTree.childFrames || [])[0];
  72. return c ? c.frame : null;
  73. }
  74. async function fEval(p, expr) {
  75. const f = await childFrame(p);
  76. if (!f) throw new Error('no frame');
  77. const id = worlds.get(p).get(f.id);
  78. if (!id) throw new Error('no context for the frame');
  79. const r = await p.send('Runtime.evaluate', { contextId: id, expression: expr, returnByValue: true, awaitPromise: true });
  80. if (r.exceptionDetails) throw new Error('frame evaluate threw: ' + ((r.exceptionDetails.exception && r.exceptionDetails.exception.description) || r.exceptionDetails.text));
  81. return r.result.value;
  82. }
  83. async function fWait(p, expr, { timeout = 15000, label = '' } = {}) {
  84. const end = Date.now() + timeout; let last;
  85. while (Date.now() < end) { try { last = await fEval(p, expr); if (last) return last; } catch (e) { last = e.message; } await sleep(80); }
  86. let t = ''; try { t = await fEval(p, "document.body.innerText + ' || code=' + ((document.querySelector('#code') || {}).value)"); } catch {}
  87. throw new Error('frame waitFor timed out: ' + (label || expr.slice(0, 100)) + ' (' + last + ') frame text: ' + t);
  88. }
  89. const fReady = async (p) => {
  90. try { return await fWait(p, `!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1`, { label: 'frame hydrated' }); }
  91. catch (e) { throw new Error(e.message + ' :: ' + await fEval(p, `location.href + ' | ' + typeof window.__hl + ' | ' + (window.__hl && window.__hl.socket && window.__hl.socket.readyState) + ' | ' + [...document.scripts].map(s => s.type + ':' + (s.src || s.text.length)).join(',') + ' | seed ' + !!document.getElementById('hl-seed') + ' | ' + document.body.innerHTML.slice(-200)`)); }
  92. };
  93. async function frameOffset(p) { // the iframe's top-left in the top viewport
  94. return p.evaluate(sh('#selector', `(() => { const b = r.querySelector('iframe#signin').getBoundingClientRect(); return { x: b.left, y: b.top, w: b.width, h: b.height }; })()`));
  95. }
  96. async function fBox(p, sel) {
  97. const b = await fEval(p, `(() => { const el = document.querySelector(${J(sel)}); if (!el) return null; el.scrollIntoView({ block: 'center' }); const r = el.getBoundingClientRect(); return r.width ? { x: r.left + r.width / 2, y: r.top + r.height / 2, w: r.width, h: r.height } : null; })()`);
  98. if (!b) throw new Error('no box for ' + sel);
  99. return b;
  100. }
  101. async function fClick(p, sel) {
  102. await fWait(p, `!!document.querySelector(${J(sel)})`, { label: sel });
  103. const b = await fBox(p, sel), o = await frameOffset(p);
  104. const base = { x: Math.round(o.x + b.x), y: Math.round(o.y + b.y), button: 'left', clickCount: 1 };
  105. await p.send('Input.dispatchMouseEvent', { type: 'mouseMoved', ...base, buttons: 0 });
  106. await p.send('Input.dispatchMouseEvent', { type: 'mousePressed', ...base, buttons: 1 });
  107. await p.send('Input.dispatchMouseEvent', { type: 'mouseReleased', ...base, buttons: 0 });
  108. }
  109. async function fType(p, sel, text) {
  110. await fClick(p, sel);
  111. for (const ch of text) {
  112. await p.send('Input.dispatchKeyEvent', { type: 'keyDown', text: ch, unmodifiedText: ch, key: ch });
  113. await p.send('Input.dispatchKeyEvent', { type: 'keyUp', key: ch });
  114. }
  115. }
  116. async function shClick(p, inner) {
  117. const box = await p.waitFor(sh('#selector', `(() => { const el = r.querySelector(${J(inner)}); if (!el) return null; el.scrollIntoView({ block: 'center' }); const b = el.getBoundingClientRect(); return b.width ? { x: b.left + b.width / 2, y: b.top + b.height / 2 } : null; })()`), { label: 'shadow ' + inner });
  118. const base = { x: Math.round(box.x), y: Math.round(box.y), button: 'left', clickCount: 1 };
  119. await p.send('Input.dispatchMouseEvent', { type: 'mouseMoved', ...base, buttons: 0 });
  120. await p.send('Input.dispatchMouseEvent', { type: 'mousePressed', ...base, buttons: 1 });
  121. await p.send('Input.dispatchMouseEvent', { type: 'mouseReleased', ...base, buttons: 0 });
  122. }
  123. async function shot(p, name) {
  124. for (const w of [390, 1280]) {
  125. await viewport(p, w); await sleep(300);
  126. const over = await p.evaluate('document.documentElement.scrollWidth > window.innerWidth');
  127. check(`${name} @${w}px: the page does not overflow sideways`, !over);
  128. const { data } = await p.send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: true });
  129. writeFileSync(join(SHOTS, `signin-${name}-${w}.png`), Buffer.from(data, 'base64'));
  130. }
  131. await viewport(p, 1280);
  132. }
  133. // every control of the frame: at least 44 px tall (taps) and inside the frame's width
  134. async function controlsOk(p, label) {
  135. const rows = await fEval(p, `[...document.querySelectorAll('input, button, a.button')].filter(e => e.getBoundingClientRect().width).map(e => { const r = e.getBoundingClientRect(); return { id: e.id || e.className || e.tagName, h: Math.round(r.height), w: Math.round(r.width), right: Math.round(r.right), vw: innerWidth }; })`);
  136. const bad = rows.filter(r => r.h < 44 || r.right > r.vw);
  137. check(`${label}: every control is at least 44 px tall and inside the frame`, rows.length > 0 && bad.length === 0, J(bad.length ? bad : rows));
  138. }
  139. // the frame is no taller than the tallest step needs (plain CSS, one height per width): at each width every step's content
  140. // height is recorded together with the frame's height; fitCheck() compares them after the last step
  141. const FIT = { 390: [], 1280: [] }, FRAME_H = { 390: 0, 1280: 0 };
  142. async function fitRecord(p, label) {
  143. const w0 = await p.evaluate('innerWidth');
  144. for (const w of [390, 1280]) {
  145. await viewport(p, w); await sleep(400);
  146. const content = await fEval(p, `Math.ceil(Math.max(...[...document.querySelectorAll('main *')].filter(e => e.getBoundingClientRect().height && !e.children.length && e.id !== 'message').map(e => e.getBoundingClientRect().bottom)) + scrollY)`);
  147. const frame = await p.evaluate(sh('#selector', `r.querySelector('iframe').offsetHeight`));
  148. FIT[w].push({ label, content }); FRAME_H[w] = frame;
  149. }
  150. await viewport(p, w0 > 500 ? 1280 : 390);
  151. }
  152. function fitCheck() {
  153. for (const w of [390, 1280]) {
  154. const tallest = Math.max(...FIT[w].map(r => r.content));
  155. check(`@${w}px the frame (${FRAME_H[w]} px) is no taller than the tallest step (${tallest} px) plus 24 px, and shows every step whole`, FRAME_H[w] >= tallest && FRAME_H[w] <= tallest + 24, J(FIT[w]));
  156. console.log(' frame fit @' + w + ': ' + J(FIT[w]) + ' frame ' + FRAME_H[w]);
  157. }
  158. }
  159. let browser1, browser2, browser3, browser4;
  160. const pages = [];
  161. try {
  162. for (const k of [1, 2, 3, 4]) {
  163. const b = await launchBrowser({ debugPortRange: CHROME_PORTS });
  164. if (k === 1) browser1 = b; if (k === 2) browser2 = b; if (k === 3) browser3 = b; if (k === 4) browser4 = b;
  165. }
  166. const mk = async (b) => { const pg = await b.newPage(); pages.push(pg); await trackWorlds(pg); await viewport(pg, 1280); return pg; };
  167. const p = await mk(browser1);
  168. // ==== setup: alice's account (signed in on ident), the app, the test app =============
  169. console.log('# setup');
  170. const ALICE = '[email protected]', BOB = '[email protected]';
  171. await p.goto(ID + '/'); await p.waitForSelector('#email'); await ready(p);
  172. await p.type('#email', ALICE); await p.click('#sendcode');
  173. await p.waitFor('/\\/code$/.test(location.pathname) && !!document.querySelector("#code")'); await ready(p);
  174. await p.type('#code', lastCode(ALICE)); await p.click('#verify');
  175. await p.waitForSelector('#skip'); await p.click('#skip');
  176. await p.waitFor('!document.querySelector("#identityform")');
  177. await p.click('#newidentity'); await p.waitForSelector('#identityform');
  178. await p.type('#fidentityname', 'Work'); await p.click('#saveidentity');
  179. await p.waitFor('document.querySelectorAll("#identities li").length === 2');
  180. await p.goto(ID + '/apps'); await p.waitForSelector('#newapp'); await ready(p);
  181. await p.click('#newapp'); await p.waitForSelector('#appform');
  182. await p.type('#fappname', 'Signin app'); await p.type('#forigins', TA);
  183. await p.click('#saveapp'); await p.waitForSelector('#secret');
  184. const secret = (await p.text('#secret')).trim();
  185. const key = await p.evaluate('[...document.querySelectorAll("#apps .apikey")].map(e => e.textContent.trim()).pop()');
  186. await p.click('#secretdone');
  187. check('app registered', /^pk_[0-9a-f]{32}$/.test(key), key);
  188. evilKey = key;
  189. await p.goto(TA + '/');
  190. await p.type('#key', key, { clear: true }); await p.type('#secret', secret, { clear: true });
  191. await p.evaluate('window.__old = 1'); await p.click('#savesetup');
  192. await p.waitFor('!window.__old && document.readyState === "complete" && !!document.querySelector("#setupkey")');
  193. // ==== the headers of the frame page ====================================================
  194. console.log('# who may frame the page');
  195. const ret = encodeURIComponent(TA + '/callback');
  196. const fr = await fetch(`${ID}/embed/signin?key=${key}&return=${ret}`);
  197. const csp = fr.headers.get('content-security-policy') || '';
  198. check('/embed/signin answers 200 and may be framed by the app\'s origin only', fr.status === 200 && /frame-ancestors http:\/\/127\.0\.0\.1:8701(;|$)/.test(csp) && !fr.headers.get('x-frame-options'), `${fr.status} ${csp} xfo=${fr.headers.get('x-frame-options')}`);
  199. const badRet = await fetch(`${ID}/embed/signin?key=${key}&return=${encodeURIComponent(EVIL + '/x')}`);
  200. check('a return URL outside the app\'s origins: 400 error page, never framed', badRet.status === 400 && /frame-ancestors 'none'/.test(badRet.headers.get('content-security-policy') || ''), String(badRet.status));
  201. const badKey = await fetch(`${ID}/embed/signin?key=pk_${'0'.repeat(32)}&return=${ret}`);
  202. check('an unknown key: 400', badKey.status === 400);
  203. const post = await fetch(`${ID}/embed/signin?key=${key}&return=${ret}`, { method: 'POST' });
  204. check('POST: 405', post.status === 405);
  205. // ==== A. a known address, signed out: email → code → identity → signed in on the app ======
  206. console.log('# A: known address, all in the selector panel');
  207. const q = await mk(browser2);
  208. await q.goto(TA + '/');
  209. await q.waitFor('!!customElements.get("ident-selector") && !!document.querySelector("#selector").shadowRoot');
  210. await shClick(q, '#choose');
  211. await q.waitFor(sh('#selector', `!!r.querySelector('iframe#signin') || !!r.querySelector('#message')`), { label: 'the signed-out panel' });
  212. await sleep(1500);
  213. await shot(q, 'step0-panel');
  214. check('signed out: the panel holds ident\'s sign-in frame and no new-tab link', await q.evaluate(sh('#selector', `!r.querySelector('a[target=_blank]') && r.querySelector('iframe#signin').src.startsWith(${J(ID + '/embed/signin?key=' + key)})`)));
  215. await fReady(q); await fWait(q, '!!document.querySelector("#email")');
  216. check('the frame says it signs the user in to ident', /This signs you in to ident\./.test(await fEval(q, 'document.body.innerText')));
  217. await shot(q, 'step1-email');
  218. await controlsOk(q, 'email step');
  219. await fitRecord(q, 'email');
  220. await fType(q, '#email', ALICE);
  221. await fClick(q, '#sendcode');
  222. await fWait(q, '!!document.querySelector("#code")', { label: 'code field' });
  223. check('code step: the same page, the address shown', /alice@example\.org/.test(await fEval(q, 'document.body.innerText')));
  224. await shot(q, 'step2-code');
  225. await controlsOk(q, 'code step');
  226. await fitRecord(q, 'code');
  227. await fType(q, '#code', lastCode(ALICE));
  228. await fClick(q, '#verify');
  229. await fWait(q, 'document.querySelectorAll("#chooselist li").length === 2 || /wrong|expired|error|refused/.test(document.body.innerText)', { label: 'identity list in the frame' });
  230. check('the right code lists both identities', (await fEval(q, 'document.querySelectorAll("#chooselist li").length')) === 2, await fEval(q, 'document.body.innerText'));
  231. const labels = await fEval(q, '[...document.querySelectorAll("#chooselist .choose")].map(a => a.target + "|" + a.textContent.trim()).join(",")');
  232. check('identity step: two identities, each a plain target=_top link', labels === '_top|Continue,_top|Continue', labels);
  233. await shot(q, 'step3-identity');
  234. await controlsOk(q, 'identity step');
  235. await fitRecord(q, 'identity');
  236. await q.evaluate('window.__still = 1');
  237. await fClick(q, '#chooselist li:nth-child(2) .choose');
  238. await q.waitFor(`location.href.startsWith(${J(TA + '/callback')}) && !!document.querySelector("#identity")`, { label: 'back on the app, signed in' });
  239. check('the whole app page went to its return URL and the app logged the user in', /^[2-9a-hj-km-np-z]{5}$/.test((await q.text('#identity')).trim()) && (await q.text('#userstate')) === 'new user');
  240. const idWork = (await q.text('#identity')).trim();
  241. check('the cookie of ident was set by the frame (a second visit lists the identities in the selector, no frame)', await (async () => {
  242. await q.goto(TA + '/');
  243. await q.waitFor('!!customElements.get("ident-selector") && !!document.querySelector("#selector").shadowRoot');
  244. await q.evaluate('document.querySelector("#selector").loggedIn = false; document.querySelector("#logout") && document.querySelector("#logout").click()');
  245. await q.goto(TA + '/');
  246. await q.waitFor('!!customElements.get("ident-selector") && !!document.querySelector("#selector").shadowRoot');
  247. await shClick(q, '#choose');
  248. return q.waitFor(sh('#selector', `r.querySelectorAll('[part~="identity"]').length === 2 && !r.querySelector('iframe')`), { label: 'list' });
  249. })());
  250. // a wrong code stays in the frame
  251. console.log('# wrong code, other address');
  252. const w = await mk(browser3);
  253. await w.goto(TA + '/'); await w.waitFor('!!customElements.get("ident-selector") && !!document.querySelector("#selector").shadowRoot');
  254. await shClick(w, '#choose'); await w.waitFor(sh('#selector', `!!r.querySelector('iframe#signin')`));
  255. await fReady(w); await fWait(w, '!!document.querySelector("#email")');
  256. await fType(w, '#email', ALICE); await fClick(w, '#sendcode'); await fWait(w, '!!document.querySelector("#code")');
  257. await fType(w, '#code', '000000'); await fClick(w, '#verify');
  258. await fWait(w, '/wrong code/.test(document.querySelector("#message").textContent)', { label: 'wrong code message' });
  259. check('a wrong code: the message in the frame, still signed out', true);
  260. await fClick(w, '#back');
  261. await fWait(w, '!!document.querySelector("#email")', { label: 'back to the email step' });
  262. check('"Other address" goes back to the email field in the frame', true);
  263. // ==== B. an unknown address: sent to ident in the same tab, back on the app ================
  264. console.log('# B: unknown address → ident → back signed in');
  265. const b = await mk(browser4);
  266. await b.goto(TA + '/'); await b.waitFor('!!customElements.get("ident-selector") && !!document.querySelector("#selector").shadowRoot');
  267. await shClick(b, '#choose'); await b.waitFor(sh('#selector', `!!r.querySelector('iframe#signin')`));
  268. await fReady(b); await fWait(b, '!!document.querySelector("#email")');
  269. await fType(b, '#email', BOB); await fClick(b, '#sendcode'); await fWait(b, '!!document.querySelector("#code")');
  270. await fType(b, '#code', lastCode(BOB)); await fClick(b, '#verify');
  271. await fWait(b, '!!document.querySelector("#gonew")', { label: 'new-address step' });
  272. check('a new address: the frame says it needs an identity on ident and links the top window there', (await fEval(b, 'document.querySelector("#gonew").target + "|" + document.querySelector("#gonew").getAttribute("href")')).startsWith('_top|/signin/'));
  273. await shot(b, 'step3-new');
  274. await controlsOk(b, 'new-address step');
  275. await fitRecord(b, 'new');
  276. await fClick(b, '#gonew');
  277. await b.waitFor(`location.origin === ${J(ID)} && /\\/signin\\/[0-9a-f]{32}\\/welcome$/.test(location.pathname) && !!document.querySelector("#identityform")`, { label: 'ident welcome form in the top window' });
  278. await ready(b);
  279. check('the same tab is on ident, the default identity\'s name form is open', await b.evaluate('!!document.querySelector("#welcome") && !!document.querySelector("#skip")'));
  280. await b.type('#fidentityname', 'Bob');
  281. await b.click('#saveidentity');
  282. await b.waitForSelector('#chooselist');
  283. check('then the identity choice for the app', (await b.text('#appname')).trim() === 'Signin app' && (await b.evaluate('document.querySelectorAll("#chooselist li").length')) === 1);
  284. await b.click('#chooselist li .choose');
  285. await b.waitFor(`location.href.startsWith(${J(TA + '/callback')}) && !!document.querySelector("#identity")`, { label: 'back on the app' });
  286. check('sent back to the app, signed in as a new user', (await b.text('#userstate')) === 'new user' && /^[2-9a-hj-km-np-z]{5}$/.test((await b.text('#identity')).trim()));
  287. // ==== C. a page of an unregistered origin cannot frame it ===================================
  288. console.log('# C: unregistered origin');
  289. const e = await mk(browser3);
  290. await e.goto(EVIL + '/');
  291. await sleep(1500);
  292. const ef = await childFrame(e);
  293. const loaded = ef ? await (async () => { try { const id = worlds.get(e).get(ef.id); if (!id) return false; const r = await e.send('Runtime.evaluate', { contextId: id, expression: '!!document.querySelector("#email")', returnByValue: true }); return r.result.value === true; } catch { return false; } })() : false;
  294. check('the framed sign-in page does not load on an unregistered origin (no email field, the browser blocks it)', !loaded, ef ? ef.url : 'no frame');
  295. await sleep(100);
  296. const log = e.messages.map(m => m.text).join('\n');
  297. check('the browser reported the frame-ancestors refusal', /frame-ancestors|Refused to frame/.test(log) || ef == null || /chrome-error/.test(ef.url || ''), log.slice(0, 200));
  298. // ==== D. console ==========================================================================
  299. const probs = pages.flatMap(pg => pg.problems().map(m => m.text)).filter(t => !/Refused to frame|frame-ancestors|ERR_BLOCKED|Failed to load resource/.test(t));
  300. check('no console errors', probs.length === 0, probs.slice(0, 3).join(' | '));
  301. } catch (err) {
  302. failed++; console.log(' FAIL gate crashed — ' + (err && err.stack || err));
  303. for (const pg of pages) console.log(' console: ' + pg.messages.map(m => m.level + ' ' + m.text).join(' || ').slice(0, 1500));
  304. } finally {
  305. for (const b of [browser1, browser2, browser3, browser4]) { try { await b.close(); } catch {} }
  306. for (const p of procs) { try { writeFileSync(join(G, p.logName), p.getOut()); p.kill(); } catch {} }
  307. evil.close();
  308. }
  309. fitCheck();
  310. console.log(`\n${passed} passed, ${failed} failed`);
  311. process.exit(failed ? 1 : 0);

Branches

Latest commits

  • a22d2daaident#31: the sign-in frame is no taller than the tallest step needs (plain CSS height per width), gate check for itmre
  • a77d1b22ident#31: the welcome form keeps editId a plain value (browser gate), README, wider rows in the framemre
  • 5c481bfdident#31: sign in to ident inside the selector's panel (email, code, identity in an iframe; a new address goes to ident in the same tab and comes back)mre
  • 061abfe2ident: the apps gate waits until the test app's login button stops moving before it clicks (the page grows after load and the click missed about every second run)mre
  • 45f7e4daident: the user menu's Sign out waits for the server before it reloads (the apps gate failed because the session could still be signed in)mre
  • f07658c7ident: home page shows the account once (account bar removed, the user menu carries email, Sign out, Sign out everywhere); wildcard origins https://*.domain for apps on many subdomains; gates follow (WIP: gates not re-run after the last edits)mre
  • f2c43bbbtheme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 6d4f996esessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 029eb5e5deploy: security gate (tests/security.mjs)mre
  • d3c065a8security audit (SI): uploadMax 0, Secure __Host- cookie behind https, headers on function routes/files, page CSP+referrer meta, app/identity caps, tests/security.mjs, reportmre
  • 5561a0cbreport I4-mobilemre
  • 4ca2ed20404 page in the shell (viewport, status 404, way home); phone: account actions live in the user menu so the open menu covers nothing; mobile gate; signoutall waits for a cold startmre
  • 9baad745tests: browser gate waits for the reloaded document (offline reload race under CPU throttle); HL_CPU_THROTTLE knobmre
  • b96796bdtests: wait for hydration before real clicks after a navigation (H2)mre
  • 9722964fre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • c9b196c9tests/iplimit: wait for the welcome form itself after B's first login (identities list renders before it); mission 017 reportmre
  • 72e0f587ident#26: identity page with "Used in" (app, since, last use, Notif. chip, empty state); lastLogin recorded at exchange; gates + lisbeth E2E; mission 016 reportmre
  • 94576fbcident#26 WIP: identity page /identity/:iid with "Used in" (app, since, last use, Notif. chip), lastLogin recorded at exchange, "Used in…" link on the identities list; apps gate 4b, e2e-usedin.mjsmre
  • 349cb502tests/invites: wait for hydration on the code page before entering the code (native GET submit raced the welcome form); mission 015 reportmre
  • d1bf4720tests: no hard-coded ports — every gate's ports and fixture origins come from <GATE>_PORT / _CHROME env (defaults unchanged; Bob/fixture origins follow, selector cookie name too)mre