- probe-reduce-after.mjs:线上 reduce 偏好下 hydration 错误计数(修复后 0) - probe-reduce-scroll.mjs:逐屏滚动后 hidden 14→3、末段 opacity=1 - about-reduce-after-scroll.png:修复后 reduce 渲染实物 其余探针(nojs / matrix / clientnav / live / webkit)已在 fix(motion) 那笔一并入库。
19 lines
1.1 KiB
JavaScript
19 lines
1.1 KiB
JavaScript
import { webkit, chromium } from 'playwright';
|
|
for (const [name, engine] of [['webkit', webkit], ['chromium', chromium]]) {
|
|
const b = await engine.launch();
|
|
const ctx = await b.newContext({ viewport:{width:1280,height:900}, reducedMotion:'reduce' });
|
|
const p = await ctx.newPage();
|
|
const errs = [];
|
|
p.on('pageerror', e => errs.push(String(e).slice(0,200)));
|
|
p.on('console', m => { if (m.type()==='error' && /hydrat|418|did not match/i.test(m.text())) errs.push('console: '+m.text().slice(0,160)); });
|
|
await p.goto('https://www.novalon.cn/about', { waitUntil:'networkidle', timeout:60000 }).catch(()=>{});
|
|
await p.waitForTimeout(2000);
|
|
const info = await p.evaluate(() => ({
|
|
reduce: matchMedia('(prefers-reduced-motion: reduce)').matches,
|
|
hidden: [...document.querySelectorAll('main *')].filter(e=>parseFloat(getComputedStyle(e).opacity)===0).length,
|
|
h1opacity: Number(getComputedStyle(document.querySelector('h1')).opacity),
|
|
}));
|
|
console.log(name, JSON.stringify(info), 'hydrationErrors', errs.length, JSON.stringify(errs.slice(0,2)));
|
|
await b.close();
|
|
}
|