gitoria
All repositories: gitoria
4.6 KB
// tests/mobile-measure.js — THE PHONE MEASUREMENT of one page (gitoria#23), evaluated inside the page by tests/browser.mjs// (block "phone first") and by a real-data run. Set `window.__W` (the phone width, 390) before; returns one object:// docScrollWidth the page's width (must be ≤ __W: no sideways scroll — innerWidth is NOT used, a mobile viewport grows with the page)// taps / tapsSmall interactive elements (a[href], button, summary, fields) and those under 44×44 px. Exempt (WCAG 2.5.8 "inline"):// a link that flows inside a sentence (display inline, its parent has more text than the link)// inputsSmall visible fields with a font under 16 px (iOS zooms into them on focus)// textSmall visible elements whose own text is under 14 px// headerH the application header's height// boxesOver code / diff / table boxes (pre, #lines, table-scroll, table) that reach past the screen edge// tabsRow the repo tab row: its height, rows and whether it overflows itself(() => {const W = window.__W || 390;const sel = (e) => { let s = e.tagName.toLowerCase(); if (e.id) s += '#' + e.id; else if (typeof e.className === 'string' && e.className.trim()) s += '.' + e.className.trim().split(/\s+/).join('.'); return s; };const shown = (e) => { const r = e.getBoundingClientRect(); if (r.width <= 0 || r.height <= 0) return false; const cs = getComputedStyle(e); return cs.visibility !== 'hidden' && cs.display !== 'none' && cs.opacity !== '0'; };const out = { url: location.href, W, docScrollWidth: document.documentElement.scrollWidth, docHeight: document.documentElement.scrollHeight };out.hscroll = out.docScrollWidth > W;const inline = (e) => { if (e.tagName !== 'A' || getComputedStyle(e).display !== 'inline' || !e.parentElement) return false; return e.parentElement.textContent.trim().length > e.textContent.trim().length; };const tapEls = [...document.querySelectorAll('a[href], button, summary, input:not([type=hidden]), select, textarea, [role=button]')].filter(shown);const small = [];for (const e of tapEls) { if (inline(e)) continue; const r = e.getBoundingClientRect(); if (r.width < 43.5 || r.height < 43.5) small.push(`${sel(e)} "${(e.textContent || e.value || '').trim().slice(0, 20)}" ${Math.round(r.width)}x${Math.round(r.height)}`); }// ident's selector (shadow DOM): its visible buttons count toofor (const h of document.querySelectorAll('ident-selector')) if (h.shadowRoot && shown(h)) for (const e of h.shadowRoot.querySelectorAll('button, a[href], input')) { if (!shown(e)) continue; const r = e.getBoundingClientRect(); if (r.width < 43.5 || r.height < 43.5) small.push(`shadow:${sel(e)} ${Math.round(r.width)}x${Math.round(r.height)}`); }out.taps = tapEls.length; out.tapsSmall = small.length; out.tapsSmallList = small.slice(0, 12);const fields = [...document.querySelectorAll('input:not([type=hidden]), textarea, select')].filter(shown);out.inputs = fields.length; out.inputsSmallList = fields.filter(e => parseFloat(getComputedStyle(e).fontSize) < 15.95).map(e => `${sel(e)} ${getComputedStyle(e).fontSize}`);out.inputsSmall = out.inputsSmallList.length;const tiny = {};for (const e of document.querySelectorAll('body *')) {if (['SCRIPT', 'STYLE'].includes(e.tagName)) continue;if (![...e.childNodes].some(n => n.nodeType === 3 && n.textContent.trim())) continue;if (!shown(e)) continue;const fs = parseFloat(getComputedStyle(e).fontSize);if (fs < 13.95) { const k = `${sel(e)} ${fs.toFixed(1)}px`; tiny[k] = (tiny[k] || 0) + 1; }}out.textSmall = Object.values(tiny).reduce((a, b) => a + b, 0); out.textSmallList = Object.entries(tiny).slice(0, 8).map(([k, v]) => `${k} x${v}`);const hd = document.querySelector('application-header'); out.headerH = hd ? Math.round(hd.getBoundingClientRect().height) : null;out.boxesOver = [...document.querySelectorAll('pre, #lines, table-scroll, table')].filter(shown).filter(e => e.getBoundingClientRect().right > W + 1).map(e => `${sel(e)} right ${Math.round(e.getBoundingClientRect().right)}`);const nav = document.querySelector('repo-nav');if (nav) { const kids = [...nav.children].filter(shown); out.tabsRow = { h: Math.round(nav.getBoundingClientRect().height), rows: new Set(kids.map(k => Math.round(k.getBoundingClientRect().top))).size, overflows: nav.scrollWidth > nav.clientWidth + 1, right: Math.round(Math.max(0, ...kids.map(k => k.getBoundingClientRect().right))) }; }out.ok = !out.hscroll && out.tapsSmall === 0 && out.inputsSmall === 0 && out.textSmall === 0 && (out.headerH === null || out.headerH <= 53) && out.boxesOver.length === 0;return out;})()
Branches
Latest commits
- fe209ffeMerge branch 'w56-owner-members' into mainGitoria
- fa0754c8|||PR repository owner transfer and members API (#55)mre
- 8862e537Merge branch 'w55-rename-org' into mainGitoria
- 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
- 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
- 499f25f2Review fixes for the Settings organization move (#53)mre
- ed3b922b|||PR move a repository into an organization in Settings (#53)mre
- 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
- 9f7ce8d8Preserve rename compatibility and live page titlesmre
- c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
- ce08920dMerge branch 'w52c-header-phone' into mainGitoria
- 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
- e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
- c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
- 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria
- 80307ae2|||PR pulls page cache: live PR numbers, complete scans onlymre
- 69141f65|||PR pulls page: cache the git part per repo by branch tipsmre
- 155861f6Merge branch 'w52-person-approval' into mainGitoria
- b5435de8|||PR person approvals: second Kunibert round (#52)mre
- 3a8b2fb8|||PR person approvals: Kunibert review fixes (#52)mre