Files
site-portfolio/shchk.mjs
T

25 lines
1.4 KiB
JavaScript

import puppeteer from 'puppeteer';
const b = await puppeteer.launch({ args:['--no-sandbox','--disable-setuid-sandbox','--use-gl=angle','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
const p = await b.newPage();
const errs=[]; p.on('console',m=>{if(m.type()==='error')errs.push(m.text())}); p.on('pageerror',e=>errs.push('PE '+e.message));
await p.goto('http://10.200.201.3:4175/_lab/neu-card.html',{waitUntil:'load',timeout:60000});
await new Promise(r=>setTimeout(r,1500));
const info = await p.evaluate(()=>{
const hosts=[...document.querySelectorAll('#sec-shader .card-shader-host')];
return hosts.map(h=>{
const cv=h.querySelector('canvas');
return { sel:h.dataset.shader, hasCanvas:!!cv, w:cv?.width, h:cv?.height, mounted:h.dataset.mounted };
});
});
// снимем пиксель чтобы убедиться что шейдер реально рисует (не пустой canvas)
const pix = await p.evaluate(()=>{
const cv=document.querySelector('#sec-shader .card-shader-host canvas');
if(!cv) return 'no-canvas';
const gl=cv.getContext('webgl2')||cv.getContext('webgl');
if(!gl) return 'no-gl';
const px=new Uint8Array(4); gl.readPixels(Math.floor(cv.width/2),Math.floor(cv.height/2),1,1,gl.RGBA,gl.UNSIGNED_BYTE,px);
return Array.from(px).join(',');
});
console.log(JSON.stringify({info, centerPixel:pix, errs}, null, 1));
await b.close();