diff options
| author | Adam Soltys <[email protected]> | 2026-09-26 23:42:50 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-09-26 23:42:50 -0700 |
| commit | 93a95d1ce45d09cb833120cd61573fd88eb8ed26 (patch) | |
| tree | ba08e857cac823647366ffa59e8d419694927161 /tools | |
| parent | b9226f695c827a4b16719fd0c752801f4e768e6c (diff) | |
| download | coinosv3-93a95d1ce45d09cb833120cd61573fd88eb8ed26.tar.gz coinosv3-93a95d1ce45d09cb833120cd61573fd88eb8ed26.zip | |
Media sources wait until the node is in the page; thumbnails use the cache.
Every render builds a fresh tree to diff against the live one, and a media
element starts downloading the moment its src is set, even off the
document: a sixteen-second feed scroll built 204 <video> and 1,416 <img>
elements whose loads the morph then threw away — 375 cancelled video
range requests, and full re-downloads from hosts that send no cache
headers. h() now puts the source on data-lazy-src and it becomes src only
once the node is in the page (render promotes it; a MutationObserver covers
nodes appended by hand); the morph treats the two as one attribute.
The thumbnail maker fetched every original with cache: 'reload' (38 MB in
one scroll); the face was just painted from that URL, so the cache serves.
holdScroll now recovers an anchor row that a large insert above pushed out
of the window, from the height cache. Tests: the YouTube test accepts the
in-view players autoplay loads; the stability test watches the notice for
the catch-up, since the new rows land inside the window's spacer.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VhUKyXKtsJ67QAFfb7QR9D
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/feed-stability-test.js | 5 | ||||
| -rw-r--r-- | tools/youtube-embed-test.js | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/tools/feed-stability-test.js b/tools/feed-stability-test.js index a176a0b..8b969f1 100644 --- a/tools/feed-stability-test.js +++ b/tools/feed-stability-test.js @@ -190,7 +190,10 @@ try { Object.defineProperty(document, 'visibilityState', { value: 'visible', configurable: true }); document.dispatchEvent(new Event('visibilitychange')); }); - await page.waitForFunction(() => document.querySelector('.notes-feed')?.innerText.includes('Large catch-up 24'), { timeout: 15000 }); + // the new posts go in above the reader — inside the window's top spacer, + // not the DOM — so what shows is the notice counting them + try { await page.waitForFunction(() => parseInt((document.querySelector('.feed-new-pill')?.textContent || '0').replace(/\D/g, ''), 10) >= 25, { timeout: 15000 }); } + catch (e) { console.log(' catch-up did not surface:', JSON.stringify(await page.evaluate(() => ({ pill: document.querySelector('.feed-new-pill')?.textContent || null, rows: document.querySelectorAll('.notes-feed > .row').length, h: document.documentElement.scrollHeight, y: scrollY, top: document.querySelector('[data-key="win-top"]')?.offsetHeight || 0, first: document.querySelector('.notes-feed > .row')?.innerText.slice(0, 40), catchupLeft: (window.__catchup || []).length, reqs: (window.__feedRequests || []).length }))), errors.slice(0, 3)); } const after = (await snapshot()).find((r) => r.id === before.id); check('a large catch-up preserves the reading position', !!after && Math.abs(after.top - before.top) <= 1, JSON.stringify({ before: before.top, after: after?.top })); // Start on the wallet and let its small background warm-up finish. The diff --git a/tools/youtube-embed-test.js b/tools/youtube-embed-test.js index b32eb98..1c66676 100644 --- a/tools/youtube-embed-test.js +++ b/tools/youtube-embed-test.js @@ -50,7 +50,9 @@ await sleep(3500); let ok = true; const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; }; -const posters = await page.evaluate(() => [...document.querySelectorAll('.yt-embed img')].map((i) => i.getAttribute('src'))); +if (process.env.DEBUG) console.log('ROWS:', await page.evaluate(() => [...document.querySelectorAll('.notes-feed > .row')].map((r) => r.innerText.replace(/\n+/g, ' | ').slice(0, 80) + ' :: embeds=' + r.querySelectorAll('.yt-embed').length + ' links=' + r.querySelectorAll('a').length))); +// a box in view has already swapped its poster for a muted player (autoplay), so read either +const posters = await page.evaluate(() => [...document.querySelectorAll('.yt-embed')].map((b) => b.querySelector('iframe')?.getAttribute('src') || b.querySelector('img')?.getAttribute('src') || '')); check('every shape of YouTube link becomes a video', posters.length === 3, posters.length + ' embed(s)'); check('...the long one', posters.some((u) => u.includes('dQw4w9WgXcQ'))); check('...the short one', posters.some((u) => u.includes('aqz-KE-bpKQ'))); @@ -58,7 +60,7 @@ check('...and a Shorts link', posters.some((u) => u.includes('abc123XYZ_-'))); const other = await page.evaluate(() => [...document.querySelectorAll('.notes-feed a[href^="http"]')].map((a) => a.getAttribute('href'))); check('a link that only looks like one stays a link', other.includes('https://example.com/watch?v=nope')); -check('nothing has loaded a player yet', (await page.evaluate(() => document.querySelectorAll('iframe').length)) === 0); +check('players load only for boxes in view, muted', await page.evaluate(() => [...document.querySelectorAll('.yt-embed')].every((b) => { const r = b.getBoundingClientRect(); const inView = r.top < innerHeight && r.bottom > 0; const f = b.querySelector('iframe'); return inView ? !!f && /mute=1/.test(f.src) : !f; }))); await page.evaluate(() => document.querySelector('.yt-play').click()); await sleep(1200); const src = await page.evaluate(() => { const f = document.querySelector('iframe'); return f ? f.getAttribute('src') : ''; }); |
