INNER CODE UNIT · JavaScript
detectCapabilities
polius/FileSync · web/js/test-diagnostics.js:41
function detectCapabilities() {
const secure = window.isSecureContext === true;
const webrtc = typeof RTCPeerConnection !== 'undefined';
const swApi = 'serviceWorker' in navigator;
const fsApi = typeof window.showSaveFilePicker === 'function';
const streams = typeof ReadableStream !== 'undefined';
setCell('cap-secure', secure, secure ? 'Secure' : 'Insecure');
setCell('cap-webrtc', webrtc, webrtc ? 'Supported' : 'Unsupported');
setCell('cap-sw-api', swApi, swApi ? 'Supported' : 'Unsupported');
// FS Access is a desktop-Chromium API and needs a secure context — show the partial
// (supported-but-insecure) case as a warning rather than a flat failure.
if (!fsApi) setCell('cap-fs', null, 'Not supported (Chromium desktop)', 'bad');
else if (!secure) setCell('cap-fs', null, 'Supported, needs HTTPS', 'warn');
else setCell('cap-fs', null, 'Available', 'ok');
setCell('cap-streams', streams, streams ? 'Supported' : 'Unsupported');