Report a problem: a diagnostic summary with no personal data, shown as it would be shared, with Copy and the issue page
The app menu's "Report a problem…" opens a small dialog with the summary (reportModel.ts, English on purpose: the people who read reports do): the app and framework versions, the system and webview (coarse, from the user agent), the language and how it was chosen, the mode, the theme and icon pack ids, the file names of the plugins that are on, what paused itself (the panel's `reportDetails`), and safe mode. The model has no field for an account, a handle, an address, a tab or a path, and a value that is not made of id characters is left out rather than trimmed into shape, so nothing of that kind can ride along (tested with hostile input). The dialog sends nothing: Copy puts the text on the clipboard, and "Open the issue page" opens `ShellSite.menu.report.issueUrl` bare in the system browser (the summary is never put in a URL). Without an issue page the button is off and the dialog says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1b0a489b36
commit
7c683598a4
12 changed files with 396 additions and 9 deletions
|
|
@ -24,6 +24,7 @@ import {
|
||||||
DEFAULT_MENU, ZOOM_MAX, ZOOM_MIN, findSpec, joinGroups, languageChoice, languageRows, menuText, moveStop, planMenu, shortcutText, specRows, submenuKeys, submenuLeft, typeahead, updateRow,
|
DEFAULT_MENU, ZOOM_MAX, ZOOM_MIN, findSpec, joinGroups, languageChoice, languageRows, menuText, moveStop, planMenu, shortcutText, specRows, submenuKeys, submenuLeft, typeahead, updateRow,
|
||||||
type BuiltinMenuItem, type MenuEnv, type MenuItemRow, type MenuRow,
|
type BuiltinMenuItem, type MenuEnv, type MenuItemRow, type MenuRow,
|
||||||
} from './menuModel.ts';
|
} from './menuModel.ts';
|
||||||
|
import { ReportDialog } from './ReportDialog.tsx';
|
||||||
import { safe, setSafeMode } from './safeStore.ts';
|
import { safe, setSafeMode } from './safeStore.ts';
|
||||||
import { hasFeature, site } from './site.ts';
|
import { hasFeature, site } from './site.ts';
|
||||||
import { isWeb, setOverlay, shell, type TabParams } from './state.ts';
|
import { isWeb, setOverlay, shell, type TabParams } from './state.ts';
|
||||||
|
|
@ -81,6 +82,7 @@ export function AppMenu() {
|
||||||
const [version, setVersion] = useState('');
|
const [version, setVersion] = useState('');
|
||||||
const [update, setUpdate] = useState<UpdateStatus>({ state: 'idle' });
|
const [update, setUpdate] = useState<UpdateStatus>({ state: 'idle' });
|
||||||
const [askedUpdate, setAskedUpdate] = useState(false);
|
const [askedUpdate, setAskedUpdate] = useState(false);
|
||||||
|
const [reporting, setReporting] = useState(false);
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
const [, tick] = useReducer((n: number) => n + 1, 0);
|
const [, tick] = useReducer((n: number) => n + 1, 0);
|
||||||
const button = useRef<HTMLButtonElement>(null);
|
const button = useRef<HTMLButtonElement>(null);
|
||||||
|
|
@ -306,6 +308,7 @@ export function AppMenu() {
|
||||||
case 'safe-mode': return safe.active
|
case 'safe-mode': return safe.active
|
||||||
? item(id, menuText('safeLeave'), 'shield', { run: () => setSafeMode(false) })
|
? item(id, menuText('safeLeave'), 'shield', { run: () => setSafeMode(false) })
|
||||||
: item(id, menuText('safeRestart'), 'shield', { submenu: true });
|
: item(id, menuText('safeRestart'), 'shield', { submenu: true });
|
||||||
|
case 'report': return item(id, menuText('report'), 'flag', { run: () => setReporting(true) });
|
||||||
case 'about': return item(id, menuText('about', { product: config.product }), 'info', { run: () => shell.openPanelSection('home') });
|
case 'about': return item(id, menuText('about', { product: config.product }), 'info', { run: () => shell.openPanelSection('home') });
|
||||||
case 'settings': return item(id, section(t('wb.panel.section.settings')), 'settings', { run: () => shell.openPanelSection('settings') });
|
case 'settings': return item(id, section(t('wb.panel.section.settings')), 'settings', { run: () => shell.openPanelSection('settings') });
|
||||||
}
|
}
|
||||||
|
|
@ -523,6 +526,7 @@ export function AppMenu() {
|
||||||
{renderMenus()}
|
{renderMenus()}
|
||||||
</div>
|
</div>
|
||||||
</div>, document.body)}
|
</div>, document.body)}
|
||||||
|
{reporting && <ReportDialog onClose={() => setReporting(false)}/>}
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
102
packages/shell/src/frame/ReportDialog.tsx
Normal file
102
packages/shell/src/frame/ReportDialog.tsx
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
// "Report a problem": a small dialog that shows the diagnostic summary (reportModel.ts) exactly as
|
||||||
|
// it would be shared, with Copy and a button that opens the project's new-issue page in the system
|
||||||
|
// browser. The app sends nothing itself: no request, and the summary is never put in a URL (the
|
||||||
|
// issue page opens bare; the owner pastes what they copied). Without a configured issue page the
|
||||||
|
// button is off and says why.
|
||||||
|
|
||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
import { invoke } from './bridge.ts';
|
||||||
|
import { useT } from './hooks.ts';
|
||||||
|
import { textLocale } from './i18n.ts';
|
||||||
|
import { Icon } from './icons.tsx';
|
||||||
|
import { menuText } from './menuModel.ts';
|
||||||
|
import { buildReport, systemFromUserAgent, webviewFromUserAgent, type ReportInfo } from './reportModel.ts';
|
||||||
|
import { safe } from './safeStore.ts';
|
||||||
|
import { site } from './site.ts';
|
||||||
|
import { setOverlay } from './state.ts';
|
||||||
|
|
||||||
|
type Hints = { platformVersion?: string; architecture?: string; bitness?: string };
|
||||||
|
|
||||||
|
/** What the engine says about the system when asked (Chromium webviews; others have the user agent only). */
|
||||||
|
async function systemHints(): Promise<Hints> {
|
||||||
|
try {
|
||||||
|
const data = (navigator as Navigator & { userAgentData?: { getHighEntropyValues(hints: string[]): Promise<Hints> } }).userAgentData;
|
||||||
|
return data ? await data.getHighEntropyValues(['platformVersion', 'architecture', 'bitness']) : {};
|
||||||
|
} catch { return {}; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gathers the facts a report may say: from the app's config and the shell's own state, nothing about the person. */
|
||||||
|
async function collect(): Promise<ReportInfo> {
|
||||||
|
const config = site();
|
||||||
|
const menu = config.menu ?? {};
|
||||||
|
const themes = config.themes;
|
||||||
|
const [appVersion, hints, mode, plugins, details] = await Promise.all([
|
||||||
|
menu.version ? menu.version().catch(() => '') : Promise.resolve(''),
|
||||||
|
systemHints(),
|
||||||
|
menu.modes ? menu.modes.current().catch(() => null) : Promise.resolve(undefined),
|
||||||
|
invoke<Array<{ file?: unknown; enabled?: unknown }>>('plugins_list').then(list => list.filter(plugin => plugin.enabled === true).map(plugin => String(plugin.file ?? '')), () => null),
|
||||||
|
menu.report?.details ? Promise.resolve(menu.report.details()).catch(() => []) : Promise.resolve([]),
|
||||||
|
]);
|
||||||
|
if (themes) await themes.loadThemes().catch(() => {});
|
||||||
|
const choice = themes?.current().choice;
|
||||||
|
const theme = themes ? themes.adapter.resolve(choice) as { id?: unknown; icons?: { pack?: unknown } } : null;
|
||||||
|
return {
|
||||||
|
product: config.product,
|
||||||
|
appVersion,
|
||||||
|
system: systemFromUserAgent(navigator.userAgent, hints),
|
||||||
|
webview: webviewFromUserAgent(navigator.userAgent),
|
||||||
|
language: menu.languages?.state().locale ?? textLocale(),
|
||||||
|
languageChoice: menu.languages?.state().preference ?? 'fixed',
|
||||||
|
mode,
|
||||||
|
theme: themes ? themes.adapter.preset(choice) : undefined,
|
||||||
|
iconPack: theme ? (typeof theme.icons?.pack === 'string' ? theme.icons.pack : '') : undefined,
|
||||||
|
plugins,
|
||||||
|
details,
|
||||||
|
safeMode: safe.active,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ReportDialog({ onClose }: { onClose(): void }) {
|
||||||
|
const t = useT();
|
||||||
|
const [text, setText] = useState<string | null>(null);
|
||||||
|
const [copied, setCopied] = useState(false);
|
||||||
|
const dialog = useRef<HTMLDivElement>(null);
|
||||||
|
const issueUrl = site().menu?.report?.issueUrl;
|
||||||
|
const canOpen = typeof issueUrl === 'string' && /^https:\/\//.test(issueUrl);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setOverlay(1);
|
||||||
|
invoke('shell_focus').catch(() => {});
|
||||||
|
let live = true;
|
||||||
|
collect().then(info => { if (live) setText(buildReport(info)); }, () => { if (live) setText(''); });
|
||||||
|
dialog.current?.focus();
|
||||||
|
return () => { live = false; setOverlay(-1); };
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const copy = async () => {
|
||||||
|
if (!text) return;
|
||||||
|
try { await navigator.clipboard.writeText(text); setCopied(true); setTimeout(() => setCopied(false), 2200); }
|
||||||
|
catch { dialog.current?.querySelector<HTMLTextAreaElement>('textarea')?.select(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
return createPortal(<div className="bt-palette-backdrop bt-report-backdrop" onMouseDown={onClose}>
|
||||||
|
<div ref={dialog} className="bt-palette bt-report bt-pop" role="dialog" aria-modal="true" aria-labelledby="bt-report-title" aria-describedby="bt-report-lede" tabIndex={-1}
|
||||||
|
onMouseDown={event => event.stopPropagation()} onKeyDown={event => { if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); onClose(); } }}>
|
||||||
|
<header className="bt-report-head">
|
||||||
|
<h2 id="bt-report-title">{menuText('reportTitle')}</h2>
|
||||||
|
<button className="bt-icon" aria-label={t('wb.common.close')} onClick={onClose}><Icon name="close"/></button>
|
||||||
|
</header>
|
||||||
|
<p id="bt-report-lede" className="bt-report-lede">{menuText('reportLede')}</p>
|
||||||
|
<textarea className="bt-report-text" readOnly spellCheck={false} dir="ltr" lang="en" rows={12} aria-label={menuText('reportTitle')}
|
||||||
|
value={text ?? t('wb.common.loading')} onFocus={event => event.currentTarget.select()}/>
|
||||||
|
{!canOpen && <p className="bt-report-note">{menuText('reportNoPage')}</p>}
|
||||||
|
<footer className="bt-report-foot">
|
||||||
|
<span className="bt-report-copied" role="status" aria-live="polite">{copied ? t('wb.common.copied') : ''}</span>
|
||||||
|
<button className="bt-deck-secondary" disabled={!canOpen} title={canOpen ? issueUrl : menuText('reportNoPage')}
|
||||||
|
onClick={() => { if (canOpen) invoke('open_external_url', { url: issueUrl }).catch(() => {}); }}><Icon name="external"/>{menuText('reportOpen')}</button>
|
||||||
|
<button className="bt-deck-primary" disabled={!text} onClick={() => void copy()}><Icon name="copy"/>{t('wb.common.copy')}</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>, document.body);
|
||||||
|
}
|
||||||
|
|
@ -99,3 +99,20 @@
|
||||||
.bt-safe-chip:hover .bt-safe-leave { color: var(--bt-text); }
|
.bt-safe-chip:hover .bt-safe-leave { color: var(--bt-text); }
|
||||||
.bt-safe-chip:disabled { opacity: .6; cursor: default; }
|
.bt-safe-chip:disabled { opacity: .6; cursor: default; }
|
||||||
.bt-app-sub .bt-app-note { max-width: 300px; }
|
.bt-app-sub .bt-app-note { max-width: 300px; }
|
||||||
|
|
||||||
|
/* "Report a problem" (ReportDialog.tsx): the summary, exactly as it would be shared. */
|
||||||
|
.bt-report { width: min(560px, 100%); max-height: min(86vh, 620px); display: flex; flex-direction: column; overflow: hidden; }
|
||||||
|
.bt-report:focus { outline: 0; }
|
||||||
|
.bt-report-head { display: flex; align-items: center; gap: 8px; padding-block: 16px 4px; padding-inline: 20px 12px; }
|
||||||
|
.bt-report-head h2 { margin: 0; flex: 1; font: 700 17px/1.2 var(--bt-ui); letter-spacing: -.015em; color: var(--bt-text); }
|
||||||
|
.bt-report-lede, .bt-report-note { margin: 0; padding: 0 20px; color: var(--bt-muted); font: 400 12.5px/1.5 var(--bt-ui); }
|
||||||
|
.bt-report-note { padding-top: 10px; color: var(--bt-text-2); }
|
||||||
|
.bt-report-text {
|
||||||
|
flex: 1 1 auto; min-height: 150px; margin: 12px 20px 0; padding: 12px 14px; box-sizing: border-box; resize: none; overflow: auto;
|
||||||
|
border: 1px solid var(--bt-line); border-radius: var(--bt-r3); background: var(--bt-field); color: var(--bt-text);
|
||||||
|
font: 400 12px/1.65 var(--bt-mono); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; text-align: left; /* rtl-ok: the report is English */
|
||||||
|
}
|
||||||
|
.bt-report-text:focus-visible { outline: 0; border-color: transparent; box-shadow: var(--bt-ring); }
|
||||||
|
.bt-report-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; }
|
||||||
|
.bt-report-copied { margin-inline-end: auto; color: var(--bt-muted); font: 500 12px/1 var(--bt-ui); }
|
||||||
|
.bt-report-foot .bt-glyph { width: 15px; height: 15px; }
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ export const ICONS = {
|
||||||
folder: 'M4 7h6l2 2h8v10H4z',
|
folder: 'M4 7h6l2 2h8v10H4z',
|
||||||
info: 'M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18zM12 11v5M12 8h.01',
|
info: 'M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18zM12 11v5M12 8h.01',
|
||||||
shield: 'M12 3l7 3v5.5c0 4.2-2.9 7.9-7 9.5-4.1-1.6-7-5.3-7-9.5V6z',
|
shield: 'M12 3l7 3v5.5c0 4.2-2.9 7.9-7 9.5-4.1-1.6-7-5.3-7-9.5V6z',
|
||||||
|
flag: 'M6 21V4M6 5h11l-2 4 2 4H6',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type IconName = keyof typeof ICONS;
|
export type IconName = keyof typeof ICONS;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ export type { PaletteItem, PaletteAction, PaletteContext } from './paletteModel.
|
||||||
export { Icon, Avatar, ICONS, type IconName } from './icons.tsx';
|
export { Icon, Avatar, ICONS, type IconName } from './icons.tsx';
|
||||||
export {
|
export {
|
||||||
DEFAULT_MENU, MENU_BUILTINS, MENU_MESSAGES, menuWith, menuWithout,
|
DEFAULT_MENU, MENU_BUILTINS, MENU_MESSAGES, menuWith, menuWithout,
|
||||||
type BuiltinMenuItem, type MenuEntry, type MenuGroups, type MenuItemSpec, type MenuLanguages, type MenuModes, type ShellMenu,
|
type BuiltinMenuItem, type MenuEntry, type MenuGroups, type MenuItemSpec, type MenuLanguages, type MenuModes, type ReportDetails, type ShellMenu,
|
||||||
} from './menuModel.ts';
|
} from './menuModel.ts';
|
||||||
export { openAppMenu, type AppMenuRequest } from './AppMenu.tsx';
|
export { openAppMenu, type AppMenuRequest } from './AppMenu.tsx';
|
||||||
export { createLanguage, resolveLocale, type Language, type LanguageOptions, type LanguagePreference } from './language.ts';
|
export { createLanguage, resolveLocale, type Language, type LanguageOptions, type LanguagePreference } from './language.ts';
|
||||||
|
|
|
||||||
|
|
@ -44,5 +44,10 @@
|
||||||
"wb.menu.safeConfirm": "Restart tabs in safe mode",
|
"wb.menu.safeConfirm": "Restart tabs in safe mode",
|
||||||
"wb.menu.safeLeave": "Leave safe mode",
|
"wb.menu.safeLeave": "Leave safe mode",
|
||||||
"wb.menu.safeLeaveShort": "Leave",
|
"wb.menu.safeLeaveShort": "Leave",
|
||||||
"wb.menu.safeChip": "Safe mode is on: plugins, themes, custom CSS and page features are off for this run. Click to leave; the tabs load again with your setup."
|
"wb.menu.safeChip": "Safe mode is on: plugins, themes, custom CSS and page features are off for this run. Click to leave; the tabs load again with your setup.",
|
||||||
|
"wb.menu.report": "Report a problem…",
|
||||||
|
"wb.menu.reportTitle": "Report a problem",
|
||||||
|
"wb.menu.reportLede": "This is everything the report contains: versions and what is switched on. No account, no address, nothing from the pages you have open. Copy it, then paste it into your report.",
|
||||||
|
"wb.menu.reportOpen": "Open the issue page",
|
||||||
|
"wb.menu.reportNoPage": "This app has no public issue page yet. Copy the text and send it to the developer."
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ export const MENU_BUILTINS = [
|
||||||
'zoom',
|
'zoom',
|
||||||
'plugins', 'store', 'workspaces',
|
'plugins', 'store', 'workspaces',
|
||||||
'find', 'shortcuts', 'palette',
|
'find', 'shortcuts', 'palette',
|
||||||
'developer', 'updates', 'safe-mode', 'about', 'settings',
|
'developer', 'updates', 'safe-mode', 'report', 'about', 'settings',
|
||||||
] as const;
|
] as const;
|
||||||
export type BuiltinMenuItem = typeof MENU_BUILTINS[number];
|
export type BuiltinMenuItem = typeof MENU_BUILTINS[number];
|
||||||
|
|
||||||
|
|
@ -89,6 +89,9 @@ export type MenuModes = {
|
||||||
apply(to: string, keep: boolean): Promise<void>;
|
apply(to: string, keep: boolean): Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Lines an app adds to the "Report a problem" summary (reportModel.ts): ids only, never anything about the person. */
|
||||||
|
export type ReportDetails = ReadonlyArray<{ label: string; values: readonly string[] }>;
|
||||||
|
|
||||||
/** `ShellSite.menu`: the app menu's rows and what the built-in ones need from the app. */
|
/** `ShellSite.menu`: the app menu's rows and what the built-in ones need from the app. */
|
||||||
export type ShellMenu = {
|
export type ShellMenu = {
|
||||||
/** The rows, in order. A string is a built-in row, an object one of the app's. Default: `DEFAULT_MENU`. */
|
/** The rows, in order. A string is a built-in row, an object one of the app's. Default: `DEFAULT_MENU`. */
|
||||||
|
|
@ -99,6 +102,13 @@ export type ShellMenu = {
|
||||||
modes?: MenuModes;
|
modes?: MenuModes;
|
||||||
/** The app's version, shown on the Updates row. */
|
/** The app's version, shown on the Updates row. */
|
||||||
version?(): Promise<string>;
|
version?(): Promise<string>;
|
||||||
|
/**
|
||||||
|
* "Report a problem": the project's new-issue page (https; opened bare in the system browser, the
|
||||||
|
* summary is never put in the URL) and lines the app adds to the summary (a fixed English label
|
||||||
|
* and ids: what paused itself, which areas are on). Without `issueUrl` the dialog still shows and
|
||||||
|
* copies the summary; its button is off and says there is no public page yet.
|
||||||
|
*/
|
||||||
|
report?: { issueUrl?: string; details?(): ReportDetails | Promise<ReportDetails> };
|
||||||
/** Opens the app's shortcuts sheet ("Keyboard shortcuts…"); without one the row opens the command palette. */
|
/** Opens the app's shortcuts sheet ("Keyboard shortcuts…"); without one the row opens the command palette. */
|
||||||
shortcuts?(): void;
|
shortcuts?(): void;
|
||||||
};
|
};
|
||||||
|
|
@ -110,7 +120,7 @@ export const DEFAULT_MENU: MenuGroups = [
|
||||||
['zoom'],
|
['zoom'],
|
||||||
['plugins', 'store', 'workspaces'],
|
['plugins', 'store', 'workspaces'],
|
||||||
['find', 'shortcuts', 'palette'],
|
['find', 'shortcuts', 'palette'],
|
||||||
['developer', 'updates', 'safe-mode', 'about', 'settings'],
|
['developer', 'updates', 'safe-mode', 'report', 'about', 'settings'],
|
||||||
];
|
];
|
||||||
|
|
||||||
const entryId = (entry: MenuEntry) => (typeof entry === 'string' ? entry : entry.id);
|
const entryId = (entry: MenuEntry) => (typeof entry === 'string' ? entry : entry.id);
|
||||||
|
|
|
||||||
126
packages/shell/src/frame/reportModel.ts
Normal file
126
packages/shell/src/frame/reportModel.ts
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
// "Report a problem": the diagnostic summary, as a pure model (unit-tested under node). It is a
|
||||||
|
// short plain text in English (the people who read reports do) built from a fixed set of facts
|
||||||
|
// about the app, never about the person: versions, the system, the language, the mode, the ids of
|
||||||
|
// what is switched on, what paused itself, safe mode. It has no field for an account, a handle, an
|
||||||
|
// address, a tab, a file path or anything of the site's, and every value must be made of the
|
||||||
|
// characters an id or a version is made of, or it is left out (never trimmed into shape), so
|
||||||
|
// nothing of that kind can ride along in a value either. The text is shown to the owner exactly as it would be shared and is
|
||||||
|
// never sent anywhere by the app (no request, and nothing is put in a URL).
|
||||||
|
|
||||||
|
/** The framework's version (kept in step with packages/waybetter/package.json by a test). */
|
||||||
|
export const FRAMEWORK_VERSION = '0.6.0';
|
||||||
|
|
||||||
|
/** Everything a report may say. */
|
||||||
|
export type ReportInfo = {
|
||||||
|
/** The app's name and version ("wayBetter for X", "1.3.2"). */
|
||||||
|
product: string;
|
||||||
|
appVersion: string;
|
||||||
|
/** "Windows 11 (x64)", "macOS", "Linux (x86_64)". */
|
||||||
|
system: string;
|
||||||
|
/** "WebView2 141.0.3537.71", "WebKit 605.1.15". */
|
||||||
|
webview: string;
|
||||||
|
/** The catalog in use and how it was chosen (`site`, `system` or a language tag). */
|
||||||
|
language: string;
|
||||||
|
languageChoice: string;
|
||||||
|
/** The mode in use (its id), when the app has modes. */
|
||||||
|
mode?: string | null;
|
||||||
|
/** The theme's id and the icon pack it uses, when the app has themes. */
|
||||||
|
theme?: string;
|
||||||
|
iconPack?: string;
|
||||||
|
/** File names of the plugins that are switched on (null: could not be read). */
|
||||||
|
plugins: readonly string[] | null;
|
||||||
|
/** Lines the app adds: a fixed English label and ids (what paused itself, which areas are on). */
|
||||||
|
details?: ReadonlyArray<{ label: string; values: readonly string[] }>;
|
||||||
|
safeMode: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const MAX_ITEMS = 60;
|
||||||
|
|
||||||
|
const ID = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/;
|
||||||
|
|
||||||
|
/** An id or a version as it is, or nothing: anything that is not made of id characters is left out, never trimmed into shape. */
|
||||||
|
export function reportValue(value: unknown): string {
|
||||||
|
const text = typeof value === 'number' ? String(value) : typeof value === 'string' ? value : '';
|
||||||
|
return ID.test(text) ? text : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A plugin's file name: the name itself (never where the file is), or nothing. */
|
||||||
|
export function reportFileName(value: unknown): string {
|
||||||
|
return typeof value === 'string' ? reportValue(value.split(/[\\/]/).pop()) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A language tag (`tr`, `zh-Hant`) or one of the automatic choices; anything else is left out. */
|
||||||
|
function languageValue(value: unknown): string {
|
||||||
|
return typeof value === 'string' && (/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8}){0,3}$/.test(value) || ['site', 'system', 'fixed'].includes(value)) ? value : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What `systemFromUserAgent` and `webviewFromUserAgent` write, and nothing else. */
|
||||||
|
const SYSTEM = /^(Windows|macOS|Linux)( \d+(\.\d+)?| 10 or 11)?( \([A-Za-z0-9_]{1,12}\))?$/;
|
||||||
|
const WEBVIEW = /^(WebView2|Chromium|WebKit) [0-9.]{1,24}$/;
|
||||||
|
/** The app's name and its labels are its own constants: letters, digits and spaces. */
|
||||||
|
const NAME = /^[A-Za-z][A-Za-z0-9 ]{0,39}$/;
|
||||||
|
|
||||||
|
function list(values: readonly unknown[] | null | undefined, clean: (value: unknown) => string): string {
|
||||||
|
if (!values) return 'unknown';
|
||||||
|
const kept = values.map(clean).filter(Boolean);
|
||||||
|
const left = values.length - kept.length;
|
||||||
|
const shown = kept.slice(0, MAX_ITEMS);
|
||||||
|
const more = kept.length - shown.length + left;
|
||||||
|
if (!shown.length) return more ? `${more} not shown` : 'none';
|
||||||
|
return `${shown.join(', ')}${more ? `, and ${more} more` : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The report's text: one fact per line. */
|
||||||
|
export function buildReport(info: ReportInfo): string {
|
||||||
|
const lines = [
|
||||||
|
`${NAME.test(info.product) ? info.product : 'App'} ${reportValue(info.appVersion) || 'unknown version'}`,
|
||||||
|
`Framework: wayBetter ${FRAMEWORK_VERSION}`,
|
||||||
|
`System: ${SYSTEM.test(info.system) ? info.system : 'unknown'}`,
|
||||||
|
`Webview: ${WEBVIEW.test(info.webview) ? info.webview : 'unknown'}`,
|
||||||
|
`Language: ${languageValue(info.language) || 'unknown'} (chosen: ${languageValue(info.languageChoice) || 'unknown'})`,
|
||||||
|
];
|
||||||
|
if (info.mode !== undefined) lines.push(`Mode: ${info.mode === null ? 'none chosen' : reportValue(info.mode) || 'unknown'}`);
|
||||||
|
if (info.theme !== undefined) lines.push(`Theme: ${reportValue(info.theme) || 'unknown'}`);
|
||||||
|
if (info.iconPack !== undefined) lines.push(`Icon pack: ${info.iconPack === '' ? "the site's own" : reportValue(info.iconPack) || 'unknown'}`);
|
||||||
|
lines.push(`Plugins on: ${list(info.plugins, reportFileName)}`);
|
||||||
|
for (const detail of (info.details ?? []).slice(0, 12)) {
|
||||||
|
if (NAME.test(detail.label)) lines.push(`${detail.label}: ${list(detail.values, reportValue)}`);
|
||||||
|
}
|
||||||
|
lines.push(`Safe mode: ${info.safeMode ? 'yes' : 'no'}`);
|
||||||
|
return lines.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The webview engine and its version from a user agent string. */
|
||||||
|
export function webviewFromUserAgent(userAgent: string): string {
|
||||||
|
const edge = /\bEdg\/([\d.]+)/.exec(userAgent);
|
||||||
|
if (edge) return `WebView2 ${edge[1]}`;
|
||||||
|
const chrome = /\bChrom(?:e|ium)\/([\d.]+)/.exec(userAgent);
|
||||||
|
if (chrome) return `Chromium ${chrome[1]}`;
|
||||||
|
const webkit = /\bAppleWebKit\/([\d.]+)/.exec(userAgent);
|
||||||
|
if (webkit) return `WebKit ${webkit[1]}`;
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operating system from a user agent string, refined by what the engine says when asked
|
||||||
|
* (`platformVersion`: on Windows a major of 13 or more is Windows 11; `architecture`). Coarse on
|
||||||
|
* purpose: a family and a version, nothing that names a machine.
|
||||||
|
*/
|
||||||
|
export function systemFromUserAgent(userAgent: string, hints: { platformVersion?: string; architecture?: string; bitness?: string } = {}): string {
|
||||||
|
const arch = hints.architecture ? `${hints.architecture}${hints.bitness === '64' && hints.architecture === 'x86' ? '_64' : ''}` : '';
|
||||||
|
if (/Windows NT/.test(userAgent)) {
|
||||||
|
const major = Number.parseInt(hints.platformVersion ?? '', 10);
|
||||||
|
const version = Number.isFinite(major) && major > 0 ? (major >= 13 ? '11' : '10') : /Windows NT 10\.0/.test(userAgent) ? '10 or 11' : '';
|
||||||
|
const bits = arch || (/Win64|x64|WOW64/.test(userAgent) ? 'x64' : /ARM64/i.test(userAgent) ? 'arm64' : '');
|
||||||
|
return `Windows${version ? ` ${version}` : ''}${bits ? ` (${bits})` : ''}`;
|
||||||
|
}
|
||||||
|
if (/Macintosh|Mac OS X/.test(userAgent)) {
|
||||||
|
const version = (hints.platformVersion ?? '').split('.').slice(0, 2).join('.');
|
||||||
|
return `macOS${/^\d+(\.\d+)?$/.test(version) && version !== '0' ? ` ${version}` : ''}${arch ? ` (${arch})` : ''}`;
|
||||||
|
}
|
||||||
|
if (/Linux|X11/.test(userAgent)) {
|
||||||
|
const machine = /Linux (x86_64|aarch64|armv\w+|i686)/.exec(userAgent)?.[1] ?? arch;
|
||||||
|
return `Linux${machine ? ` (${machine})` : ''}`;
|
||||||
|
}
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
|
@ -78,6 +78,15 @@ function usePaused(table: FeatureTable): Set<string> {
|
||||||
return paused;
|
return paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lines for the app menu's "Report a problem" summary (the frame's `ShellSite.menu.report.details`):
|
||||||
|
* the feature flags the focused site tab says paused themselves. Flag ids only.
|
||||||
|
*/
|
||||||
|
export function reportDetails(): Array<{ label: string; values: string[] }> {
|
||||||
|
const table = featureTable();
|
||||||
|
return table ? [{ label: 'Paused features', values: [...pausedFeatures(table, focusedCommands()?.items)].sort() }] : [];
|
||||||
|
}
|
||||||
|
|
||||||
/** The area cards and the Fixes list. Renders nothing for an app without a feature table. */
|
/** The area cards and the Fixes list. Renders nothing for an app without a feature table. */
|
||||||
export function AreaPlugins({ notify }: { notify: Notify }) {
|
export function AreaPlugins({ notify }: { notify: Notify }) {
|
||||||
const table = featureTable();
|
const table = featureTable();
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export {
|
||||||
} from './controls.tsx';
|
} from './controls.tsx';
|
||||||
export { FeatureGroups, useFeatures } from './FeatureToggles.tsx';
|
export { FeatureGroups, useFeatures } from './FeatureToggles.tsx';
|
||||||
// Area plugins and modes (PanelSite.features): the cards, the Fixes list, the first-run screen.
|
// Area plugins and modes (PanelSite.features): the cards, the Fixes list, the first-run screen.
|
||||||
export { AreaPlugins, featureTable, flagsChanged, useFlags } from './PluginFeatures.tsx';
|
export { AreaPlugins, featureTable, flagsChanged, reportDetails, useFlags } from './PluginFeatures.tsx';
|
||||||
export { ModeSettings, Onboarding, menuModes, openOnboardingWhenDue, useModeState, type ModeState } from './Modes.tsx';
|
export { ModeSettings, Onboarding, menuModes, openOnboardingWhenDue, useModeState, type ModeState } from './Modes.tsx';
|
||||||
export { areaCards, featureFiles, fixRows, modePlan, type AreaCard, type FeatureRow, type ModePlan, type PluginFileState } from './featureModel.ts';
|
export { areaCards, featureFiles, fixRows, modePlan, type AreaCard, type FeatureRow, type ModePlan, type PluginFileState } from './featureModel.ts';
|
||||||
export { compareLines } from './compare.ts';
|
export { compareLines } from './compare.ts';
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ test('a row the app cannot serve is left out, and a group left empty takes its r
|
||||||
['new-tab', 'split-right', 'split-down'],
|
['new-tab', 'split-right', 'split-down'],
|
||||||
['plugins'],
|
['plugins'],
|
||||||
['shortcuts', 'palette'],
|
['shortcuts', 'palette'],
|
||||||
['about', 'settings'],
|
['report', 'about', 'settings'],
|
||||||
]);
|
]);
|
||||||
// Each gate is its own.
|
// Each gate is its own.
|
||||||
const gates: Array<[keyof MenuEnv, string]> = [
|
const gates: Array<[keyof MenuEnv, string]> = [
|
||||||
|
|
@ -44,7 +44,7 @@ test('a row the app cannot serve is left out, and a group left empty takes its r
|
||||||
assert.equal(ids(planMenu(DEFAULT_MENU, { ...ALL, [feature]: false })).flat().includes(row), false, `without ${feature} there is no ${row}`);
|
assert.equal(ids(planMenu(DEFAULT_MENU, { ...ALL, [feature]: false })).flat().includes(row), false, `without ${feature} there is no ${row}`);
|
||||||
assert.equal(builtinAvailable(row as typeof MENU_BUILTINS[number], NONE), false);
|
assert.equal(builtinAvailable(row as typeof MENU_BUILTINS[number], NONE), false);
|
||||||
}
|
}
|
||||||
for (const row of ['new-tab', 'split-right', 'split-down', 'plugins', 'shortcuts', 'palette', 'about', 'settings'] as const) assert.ok(builtinAvailable(row, NONE), row);
|
for (const row of ['new-tab', 'split-right', 'split-down', 'plugins', 'shortcuts', 'palette', 'report', 'about', 'settings'] as const) assert.ok(builtinAvailable(row, NONE), row);
|
||||||
// The rows that remain are separated once, never twice.
|
// The rows that remain are separated once, never twice.
|
||||||
const rows = joinGroups(planMenu(DEFAULT_MENU, NONE).map(group => group.map((entry): MenuRow => ({ kind: 'item', id: String(entry), label: String(entry) }))));
|
const rows = joinGroups(planMenu(DEFAULT_MENU, NONE).map(group => group.map((entry): MenuRow => ({ kind: 'item', id: String(entry), label: String(entry) }))));
|
||||||
assert.equal(rows.filter(row => row.kind === 'separator').length, 3);
|
assert.equal(rows.filter(row => row.kind === 'separator').length, 3);
|
||||||
|
|
@ -63,7 +63,7 @@ test('an app orders, removes and adds rows; its own rows follow their `when`', (
|
||||||
assert.equal(ids(planMenu(groups, ALL)).flat().includes('drafts'), false);
|
assert.equal(ids(planMenu(groups, ALL)).flat().includes('drafts'), false);
|
||||||
drafts = true;
|
drafts = true;
|
||||||
assert.deepEqual(ids(planMenu(menuWithout(groups, 'store', 'zoom', 'drafts'), ALL)), [
|
assert.deepEqual(ids(planMenu(menuWithout(groups, 'store', 'zoom', 'drafts'), ALL)), [
|
||||||
['new-tab', 'split-right', 'split-down', 'new-column'], ['language', 'theme', 'mode'], ['plugins', 'workspaces'], ['find', 'shortcuts', 'palette'], ['developer', 'updates', 'safe-mode', 'about', 'settings'],
|
['new-tab', 'split-right', 'split-down', 'new-column'], ['language', 'theme', 'mode'], ['plugins', 'workspaces'], ['find', 'shortcuts', 'palette'], ['developer', 'updates', 'safe-mode', 'report', 'about', 'settings'],
|
||||||
]);
|
]);
|
||||||
// Explicit order; a row listed twice shows once; an unknown name and an own row named like a built-in are ignored.
|
// Explicit order; a row listed twice shows once; an unknown name and an own row named like a built-in are ignored.
|
||||||
const custom: MenuGroups = [['settings', 'new-tab', 'settings', 'nope' as never], [{ id: 'zoom', label: () => 'Fake zoom' }, own]];
|
const custom: MenuGroups = [['settings', 'new-tab', 'settings', 'nope' as never], [{ id: 'zoom', label: () => 'Fake zoom' }, own]];
|
||||||
|
|
@ -229,7 +229,7 @@ test("the menu's words: English from menuMessages.en.json until a catalog has th
|
||||||
assert.equal(menuText('zoom'), 'Zoom', 'a key the catalog lacks still reads in English');
|
assert.equal(menuText('zoom'), 'Zoom', 'a key the catalog lacks still reads in English');
|
||||||
// The component and the palette name their words through menuText, never as raw keys.
|
// The component and the palette name their words through menuText, never as raw keys.
|
||||||
const used = new Set<string>();
|
const used = new Set<string>();
|
||||||
for (const file of ['AppMenu.tsx', 'TitlebarExtras.tsx', 'AccountSwitcher.tsx', 'paletteModel.ts', 'FindBar.tsx', 'menuModel.ts']) {
|
for (const file of ['AppMenu.tsx', 'TitlebarExtras.tsx', 'AccountSwitcher.tsx', 'paletteModel.ts', 'FindBar.tsx', 'menuModel.ts', 'ReportDialog.tsx']) {
|
||||||
for (const match of readFileSync(join(here, '../src/frame', file), 'utf8').matchAll(/menuText\('([A-Za-z]+)'/g)) used.add(`wb.menu.${match[1]}`);
|
for (const match of readFileSync(join(here, '../src/frame', file), 'utf8').matchAll(/menuText\('([A-Za-z]+)'/g)) used.add(`wb.menu.${match[1]}`);
|
||||||
}
|
}
|
||||||
for (const key of used) assert.ok(key in MENU_MESSAGES, `${key} has English`);
|
for (const key of used) assert.ok(key in MENU_MESSAGES, `${key} has English`);
|
||||||
|
|
|
||||||
113
packages/shell/tests/report.test.ts
Normal file
113
packages/shell/tests/report.test.ts
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
// "Report a problem" (frame/reportModel.ts): the summary says versions and what is switched on, and
|
||||||
|
// cannot say anything about the person: it has no field for an account, an address or a path, and
|
||||||
|
// every value is reduced to id characters before it is written.
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { dirname, join } from 'node:path';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import { FRAMEWORK_VERSION, buildReport, reportFileName, reportValue, systemFromUserAgent, webviewFromUserAgent, type ReportInfo } from '../src/frame/reportModel.ts';
|
||||||
|
|
||||||
|
const here = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const INFO: ReportInfo = {
|
||||||
|
product: 'wayBetter for X', appVersion: '1.3.2', system: 'Windows 11 (x64)', webview: 'WebView2 141.0.3537.71',
|
||||||
|
language: 'tr', languageChoice: 'site', mode: 'advanced', theme: 'night-ink', iconPack: 'phosphor',
|
||||||
|
plugins: ['reply-guard.plugin.js', 'mute-words.plugin.js'],
|
||||||
|
details: [{ label: 'Paused features', values: ['composeCounter'] }],
|
||||||
|
safeMode: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
test('the summary is one fact per line, in English', () => {
|
||||||
|
assert.equal(buildReport(INFO), [
|
||||||
|
'wayBetter for X 1.3.2',
|
||||||
|
`Framework: wayBetter ${FRAMEWORK_VERSION}`,
|
||||||
|
'System: Windows 11 (x64)',
|
||||||
|
'Webview: WebView2 141.0.3537.71',
|
||||||
|
'Language: tr (chosen: site)',
|
||||||
|
'Mode: advanced',
|
||||||
|
'Theme: night-ink',
|
||||||
|
'Icon pack: phosphor',
|
||||||
|
'Plugins on: reply-guard.plugin.js, mute-words.plugin.js',
|
||||||
|
'Paused features: composeCounter',
|
||||||
|
'Safe mode: no',
|
||||||
|
].join('\n'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('an app without modes, themes or plugins says less, never something made up', () => {
|
||||||
|
const text = buildReport({ product: 'App', appVersion: '', system: '', webview: '', language: '', languageChoice: '', plugins: null, safeMode: true });
|
||||||
|
assert.equal(text, ['App unknown version', `Framework: wayBetter ${FRAMEWORK_VERSION}`, 'System: unknown', 'Webview: unknown', 'Language: unknown (chosen: unknown)', 'Plugins on: unknown', 'Safe mode: yes'].join('\n'));
|
||||||
|
assert.match(buildReport({ ...INFO, mode: null, plugins: [], iconPack: '', details: [{ label: 'Paused features', values: [] }] }), /Mode: none chosen\n[\s\S]*Icon pack: the site's own\nPlugins on: none\nPaused features: none\n/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('nothing about the person can ride along in a value', () => {
|
||||||
|
const hostile: ReportInfo = {
|
||||||
|
product: 'wayBetter for X <script>', appVersion: '1.3.2 @someone https://x.com/someone',
|
||||||
|
system: 'Windows 11 (x64) C:\\Users\\someone', webview: 'WebView2 141 https://example.com/?q=secret',
|
||||||
|
language: 'tr@someone', languageChoice: 'https://x.com/home',
|
||||||
|
mode: 'advanced\nAccount: @someone', theme: '../../Users/someone/night-ink', iconPack: 'file:///C:/Users/someone/pack',
|
||||||
|
plugins: ['C:\\Users\\someone\\AppData\\plugins\\reply-guard.plugin.js', '/home/someone/.config/app/plugins/a b.plugin.js', '@someone', 'https://x.com/someone/status/1'],
|
||||||
|
details: [{ label: 'Open tabs: https://x.com/messages', values: ['https://x.com/messages/123', '@someone', 'ok-id'] }],
|
||||||
|
safeMode: false,
|
||||||
|
};
|
||||||
|
const text = buildReport(hostile);
|
||||||
|
// Nothing of it got through: no name, no address, no path, not even squeezed together.
|
||||||
|
for (const forbidden of ['someone', 'secret', '@', '\\', 'http', 'x.com', 'Users', 'AppData', 'home', 'messages', '<', '?']) {
|
||||||
|
assert.ok(!text.includes(forbidden), `${JSON.stringify(forbidden)} in\n${text}`);
|
||||||
|
}
|
||||||
|
assert.equal(text, [
|
||||||
|
'App unknown version',
|
||||||
|
`Framework: wayBetter ${FRAMEWORK_VERSION}`,
|
||||||
|
'System: unknown',
|
||||||
|
'Webview: unknown',
|
||||||
|
'Language: unknown (chosen: unknown)',
|
||||||
|
'Mode: unknown',
|
||||||
|
'Theme: unknown',
|
||||||
|
'Icon pack: unknown',
|
||||||
|
// A file name stands for itself, never for where it is; what is not a plain name is only counted.
|
||||||
|
'Plugins on: reply-guard.plugin.js, 1, and 2 more',
|
||||||
|
'Safe mode: no',
|
||||||
|
].join('\n'));
|
||||||
|
assert.equal(reportFileName('C:\\Users\\someone\\x.plugin.js'), 'x.plugin.js');
|
||||||
|
assert.equal(reportFileName('/opt/app/plugins/a b.plugin.js'), '', 'not trimmed into shape');
|
||||||
|
assert.equal(reportValue('a'.repeat(200)), '');
|
||||||
|
assert.equal(reportValue('night-ink'), 'night-ink');
|
||||||
|
assert.equal(reportValue(12), '12');
|
||||||
|
assert.equal(reportValue({} as never), '');
|
||||||
|
// Long lists are cut, and say so.
|
||||||
|
const many = buildReport({ ...INFO, plugins: Array.from({ length: 75 }, (_, n) => `p${n}.plugin.js`) });
|
||||||
|
assert.match(many, /p59\.plugin\.js, and 15 more$/m);
|
||||||
|
assert.match(buildReport({ ...INFO, plugins: ['@someone'] }), /^Plugins on: 1 not shown$/m);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the model has no field for an account, an address, a tab or a path', () => {
|
||||||
|
const source = readFileSync(join(here, '../src/frame/reportModel.ts'), 'utf8');
|
||||||
|
const type = source.slice(source.indexOf('export type ReportInfo'), source.indexOf('const MAX_ITEMS'));
|
||||||
|
for (const forbidden of ['account', 'handle', 'url', 'tab', 'path', 'profile', 'user', 'email', 'title']) {
|
||||||
|
assert.ok(!new RegExp(`\\b${forbidden}\\w*\\??:`, 'i').test(type), `a ${forbidden} field`);
|
||||||
|
}
|
||||||
|
// The dialog never sends the summary: no fetch, and the issue page opens bare.
|
||||||
|
const dialog = readFileSync(join(here, '../src/frame/ReportDialog.tsx'), 'utf8');
|
||||||
|
assert.ok(!/\bfetch\(|XMLHttpRequest|sendBeacon|encodeURIComponent|searchParams|\?body=|\$\{text\}/.test(dialog), 'nothing is sent and nothing is put in a URL');
|
||||||
|
assert.match(dialog, /invoke\('open_external_url', \{ url: issueUrl \}\)/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the framework version is the package version', () => {
|
||||||
|
const pkg = JSON.parse(readFileSync(join(here, '../../waybetter/package.json'), 'utf8')) as { version: string };
|
||||||
|
assert.equal(FRAMEWORK_VERSION, pkg.version);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the system and the webview are read coarsely from the user agent', () => {
|
||||||
|
const edge = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.3537.71';
|
||||||
|
assert.equal(webviewFromUserAgent(edge), 'WebView2 141.0.3537.71');
|
||||||
|
assert.equal(systemFromUserAgent(edge), 'Windows 10 or 11 (x64)');
|
||||||
|
assert.equal(systemFromUserAgent(edge, { platformVersion: '15.0.0', architecture: 'x86', bitness: '64' }), 'Windows 11 (x86_64)');
|
||||||
|
assert.equal(systemFromUserAgent(edge, { platformVersion: '10.0.0' }), 'Windows 10 (x64)');
|
||||||
|
const mac = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)';
|
||||||
|
assert.equal(webviewFromUserAgent(mac), 'WebKit 605.1.15');
|
||||||
|
assert.equal(systemFromUserAgent(mac), 'macOS');
|
||||||
|
const linux = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15';
|
||||||
|
assert.equal(systemFromUserAgent(linux), 'Linux (x86_64)');
|
||||||
|
assert.equal(webviewFromUserAgent(linux), 'WebKit 605.1.15');
|
||||||
|
assert.equal(systemFromUserAgent('something else'), 'unknown');
|
||||||
|
assert.equal(webviewFromUserAgent('something else'), 'unknown');
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue