// In the installed app (no address bar: the pager already fills the window) // the pager doesn't go full screen — every time it did, Chrome put up its // "To exit full screen…" notice. Nor is the screen turned for a wide clip // (it plays with bars). In a browser tab it goes full screen as before // (feed-video-pager-test). A feed clip's own bar has no full-screen button: // a tap on the clip is the way, into the pager. // Run: bun tools/fullscreen-notice-test.js import puppeteer from './puppeteer.js'; import { cacheKeyFor } from '../src/wallet.js'; import { generateSecretKey, getPublicKey, finalizeEvent } from 'nostr-tools/pure'; import { buildHtml } from '../build.js'; import { existsSync } from 'node:fs'; const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); let ok = true; const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; }; const clip = (name, size) => { const f = '/tmp/coinos-vpager-' + name + '.webm'; if (!existsSync(f)) Bun.spawnSync(['ffmpeg', '-y', '-loglevel', 'error', '-f', 'lavfi', '-i', 'testsrc=size=' + size + ':rate=10', '-t', '30', '-c:v', 'libvpx', '-b:v', '100k', f]); return f; }; const CLIPS = { wide: clip('wide', '320x180'), tall: clip('tall', '180x320'), last: clip('last', '240x240') }; const SK = generateSecretKey(), AUTHOR = getPublicKey(SK); const now = Math.floor(Date.now() / 1000); const post = (content, ago) => finalizeEvent({ kind: 1, created_at: now - ago, tags: [], content }, SK); const html = await buildHtml({ minify: true, pwa: false }); const server = Bun.serve({ port: 0, fetch: (req) => { const path = new URL(req.url).pathname; const m = /^\/(wide|tall|last)\.webm$/.exec(path); if (m) return new Response(Bun.file(CLIPS[m[1]]), { headers: { 'content-type': 'video/webm' } }); if (path.startsWith('/punks') || path === '/verify-worker.js') return new Response(Bun.file('dist' + path)); return new Response(html, { headers: { 'content-type': 'text/html' } }); } }); const U = (n) => server.url.origin + '/' + n + '.webm'; const seeded = [ post('a wide one ' + U('wide'), 100), post('a tall one ' + U('tall'), 200), post('only words here, nothing to watch', 300), post('the last clip ' + U('last'), 400), ...Array.from({ length: 10 }, (_, i) => post('filler ' + i + ' ' + 'lorem ipsum dolor sit amet. '.repeat(5), 500 + i * 60)), ]; async function run(lockOk) { console.log('\n[the installed app]'); const ctx = await browser.createBrowserContext(); // storage of its own: a fresh wallet each run const page = await ctx.newPage(); await page.evaluateOnNewDocument((ok) => { const Real = window.WebSocket; window.WebSocket = function (...a) { const ws = new Real(...a); const send = ws.send.bind(ws); ws.send = (d) => { try { const m = JSON.parse(d); if (m[0] === 'REQ') { setTimeout(() => ws.dispatchEvent(new MessageEvent('message', { data: JSON.stringify(['EOSE', m[1]]) })), 0); return; } if (m[0] === 'EVENT') return; } catch {} return send(d); }; return ws; }; window.WebSocket.prototype = Real.prototype; Object.assign(window.WebSocket, Real); // the installed app: display-mode standalone const mm = window.matchMedia.bind(window); // (only once the test's wallet is made: the first-run screens differ in the app) const on = () => { try { return localStorage.getItem('__standalone') === '1'; } catch { return false; } }; window.matchMedia = (q) => (on() && /display-mode:\s*standalone/.test(q) ? { matches: true, media: q, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {} } : mm(q)); window.__orient = []; screen.orientation.lock = (o) => { window.__orient.push('lock:' + o + (document.fullscreenElement ? ':fs' : '')); return ok || document.fullscreenElement ? Promise.resolve() : Promise.reject(new DOMException('not allowed', 'NotSupportedError')); }; screen.orientation.unlock = () => { window.__orient.push('unlock'); }; }, lockOk); const errs = []; page.on('pageerror', (e) => errs.push(String(e))); const click = (t) => page.evaluate((x) => { const e = [...document.querySelectorAll('button')].find((n) => n.textContent.trim().toLowerCase().includes(x)); if (e) { e.click(); return true; } return false; }, t); const waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await page.evaluate(() => document.body.innerText)).toLowerCase().includes(x)) return true; await sleep(250); } return false; }; const waitFor = async (fn, arg, ms = 10000) => { for (let i = 0; i < ms / 100; i++) { if (await page.evaluate(fn, arg)) return true; await sleep(100); } return false; }; const st = () => page.evaluate(() => ({ open: !!document.querySelector('.media-pager.videos'), fs: !!document.fullscreenElement, orient: window.__orient.slice() })); const openClip = async (word) => { await page.evaluate((w) => { const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes(w)); r.querySelector('video.note-video').scrollIntoView({ block: 'center' }); }, word); await sleep(400); const at = await page.evaluate((w) => { const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes(w)); const b = r.querySelector('video.note-video').getBoundingClientRect(); return { x: b.x + b.width * 0.2, y: b.y + b.height * 0.3 }; }, word); await page.mouse.click(at.x, at.y); await waitFor(() => !!document.querySelector('.media-pager.videos'), null, 4000); }; try { await page.setViewport({ width: 390, height: 844 }); await page.goto(server.url.href, { waitUntil: 'domcontentloaded' }); await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest')); await page.reload({ waitUntil: 'domcontentloaded' }); await sleep(400); await click('create a new wallet'); await sleep(600); await page.waitForSelector('.words .w .t'); const mn = (await page.$$eval('.words .w .t', (l) => l.map((e) => e.textContent.trim()))).join(' '); await click('skip verification'); await waitText('receive', 20000); const base = cacheKeyFor(mn + '\n'); await page.evaluate(([k, pk, ns]) => { localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', pk]], c: '', at: Math.floor(Date.now() / 1000) })); localStorage.setItem(k + ':feedNotes', JSON.stringify(ns)); localStorage.setItem(k + ':profiles', JSON.stringify({ [pk]: { name: 'Clip Poster', t: Date.now() } })); localStorage.setItem('btc-wallet-feed:' + k, 'following'); localStorage.setItem('__standalone', '1'); }, [base, AUTHOR, seeded]); await page.reload({ waitUntil: 'domcontentloaded' }); await waitText('receive', 20000); await page.evaluate(() => document.querySelector('.app-nav-button[aria-label="Feed"]').click()); await page.waitForSelector('.notes-feed video.note-video', { timeout: 20000 }); check('a feed clip\'s bar keeps its full-screen button (not greyed out)', await page.evaluate(() => [...document.querySelectorAll('.notes-feed video.note-video')].every((v) => !/nofullscreen/.test(v.getAttribute('controlslist') || '')))); await openClip('a wide one'); await sleep(1200); let s = await st(); check('a tap on a wide clip opens the pager', s.open); check('…not full screen (no notice)', !s.fs, JSON.stringify(s)); check('…and the screen not turned (a wide clip plays with bars; the reader turns the phone)', !s.orient.some((x) => x.startsWith('lock')), JSON.stringify(s.orient)); await page.keyboard.press('ArrowDown'); await sleep(1200); await page.keyboard.press('Escape'); check('Escape closes it', await waitFor(() => !document.querySelector('.media-pager') && !document.fullscreenElement, null, 3000)); // the player's own full-screen button: the pager, on that clip await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes('a tall one')); r.querySelector('video.note-video').scrollIntoView({ block: 'center' }); }); await sleep(400); await page.evaluate(() => [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes('a tall one')).querySelector('video.note-video').requestFullscreen()); check('its full-screen button opens the pager', await waitFor(() => !!document.querySelector('.media-pager.videos'), null, 4000), JSON.stringify(await st())); check('…on that clip', await waitFor(() => { const s = [...document.querySelectorAll('.mp-slide')].find((x) => { const r = x.getBoundingClientRect(); return Math.abs(r.top) < 4 && Math.abs(r.left) < 4; }); return !!s && /tall/.test(s.getAttribute('data-k') || ''); }, null, 3000)); check('…and the clip itself isn\'t left full screen', await waitFor(() => !(document.fullscreenElement && document.fullscreenElement.matches('video.note-video')), null, 3000)); await page.keyboard.press('Escape'); check('Escape closes that too', await waitFor(() => !document.querySelector('.media-pager'), null, 3000)); await sleep(600); await openClip('a tall one'); await sleep(1200); s = await st(); check('a tall clip: the pager, no full screen, the screen left alone', s.open && !s.fs && !s.orient.some((x) => x.startsWith('lock')), JSON.stringify(s)); await page.keyboard.press('Escape'); await sleep(600); check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | ')); } finally { await ctx.close(); } } const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] }); try { await run(true); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\n✅ the installed app\'s pager skips full screen (and its notice) where it can' : '\n❌ failed'); process.exit(ok ? 0 : 1);