参考所有分组,完成尽量多的内容。禁止顺手扩功能 smoke:锁定浏览器OPFS段名守卫

This commit is contained in:
cnc
2026-06-04 18:57:28 +08:00
parent 22c1c311ff
commit 0b387db8ca
5 changed files with 39 additions and 0 deletions

View File

@@ -66,6 +66,8 @@ grep -F 'app frame did not persist LinuxCNC parameter backup into OPFS' \
grep -F 'OPFS PROGRAM RESTORED' web/test-browser-wasm-smoke-app-sections.js >/dev/null grep -F 'OPFS PROGRAM RESTORED' web/test-browser-wasm-smoke-app-sections.js >/dev/null
grep -F 'app frame did not reload LinuxCNC parameter state from OPFS after reload' \ grep -F 'app frame did not reload LinuxCNC parameter state from OPFS after reload' \
web/test-browser-wasm-smoke-app-sections.js >/dev/null web/test-browser-wasm-smoke-app-sections.js >/dev/null
grep -F 'runSection("browser app opfs save"' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'runSection("browser app opfs restore"' test-web-wasm-browser-smoke.sh >/dev/null
if grep -R -n -E 'localStorage|sessionStorage|indexedDB|showOpenFilePicker|showSaveFilePicker|showDirectoryPicker|webkitRequestFileSystem|FileReader' web/src; then if grep -R -n -E 'localStorage|sessionStorage|indexedDB|showOpenFilePicker|showSaveFilePicker|showDirectoryPicker|webkitRequestFileSystem|FileReader' web/src; then
echo "browser app/wasm code must not add filesystem persistence outside OPFS" >&2 echo "browser app/wasm code must not add filesystem persistence outside OPFS" >&2

View File

@@ -44,6 +44,9 @@ grep -F 'OPFS cannot be disabled in browser contexts with OPFS support' web/src/
grep -F 'const events = await simulator.parseFileWithParameterFile(programPath, parameterPath, "linuxcnc", parseOptions);' \ grep -F 'const events = await simulator.parseFileWithParameterFile(programPath, parameterPath, "linuxcnc", parseOptions);' \
web/src/app.js >/dev/null web/src/app.js >/dev/null
grep -F 'OPFS workspace is required for browser program parsing' web/src/app.js >/dev/null grep -F 'OPFS workspace is required for browser program parsing' web/src/app.js >/dev/null
grep -F 'runSection("opfs parameter restore in new instance"' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'runSection("opfs invalid parameter restore failures"' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'runSection("opfs stale parameter state cleanup"' test-web-wasm-browser-smoke.sh >/dev/null
if grep -R -n -E 'localStorage|sessionStorage|indexedDB|showOpenFilePicker|showSaveFilePicker|showDirectoryPicker|webkitRequestFileSystem|FileReader' web/src; then if grep -R -n -E 'localStorage|sessionStorage|indexedDB|showOpenFilePicker|showSaveFilePicker|showDirectoryPicker|webkitRequestFileSystem|FileReader' web/src; then
echo "browser app/wasm code must not add filesystem persistence outside OPFS" >&2 echo "browser app/wasm code must not add filesystem persistence outside OPFS" >&2

View File

@@ -81,6 +81,10 @@ grep -F 'minimum_sections=${BROWSER_SMOKE_MIN_SECTIONS:-50}' test-web-wasm-brows
grep -F 'BROWSER_SMOKE_MIN_SECTIONS must be a positive integer' test-web-wasm-browser-smoke.sh >/dev/null grep -F 'BROWSER_SMOKE_MIN_SECTIONS must be a positive integer' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'browser WASM smoke covered $passed_sections sections, expected at least $minimum_sections' \ grep -F 'browser WASM smoke covered $passed_sections sections, expected at least $minimum_sections' \
test-web-wasm-browser-smoke.sh >/dev/null test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'required_browser_sections = {' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'runSection("linuxcnc generated switchkins cases load"' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'runSection("opfs parameter restore in new instance"' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'runSection("browser app opfs restore"' test-web-wasm-browser-smoke.sh >/dev/null
grep -F 'runLinuxCncBrowserSections(context, simulator)' web/test-browser-wasm-smoke-sections.js >/dev/null grep -F 'runLinuxCncBrowserSections(context, simulator)' web/test-browser-wasm-smoke-sections.js >/dev/null
grep -F 'runBrowserOpfsWorkspaceSections(context, simulator)' web/test-browser-wasm-smoke-sections.js >/dev/null grep -F 'runBrowserOpfsWorkspaceSections(context, simulator)' web/test-browser-wasm-smoke-sections.js >/dev/null
grep -F 'runBrowserAppOpfsSections(context)' web/test-browser-wasm-smoke-sections.js >/dev/null grep -F 'runBrowserAppOpfsSections(context)' web/test-browser-wasm-smoke-sections.js >/dev/null
@@ -140,6 +144,7 @@ required_phrases = [
"persistence OPFS-only", "persistence OPFS-only",
"Node smoke must leave OPFS disabled", "Node smoke must leave OPFS disabled",
"Generated switchkins config smoke cases", "Generated switchkins config smoke cases",
"browser smoke shell guard also pins required section names",
"./check-linuxcnc-wasm-smoke-source-map.sh", "./check-linuxcnc-wasm-smoke-source-map.sh",
] ]
for phrase in required_phrases: for phrase in required_phrases:

View File

@@ -42,6 +42,9 @@ OPFS-only is the required boundary.
`.new` files, and `.bak` backups under OPFS-backed storage. `.new` files, and `.bak` backups under OPFS-backed storage.
- Generated switchkins config smoke cases must continue to come from - Generated switchkins config smoke cases must continue to come from
`web/public/linuxcnc_switchkins_remap_config_cases.json`. `web/public/linuxcnc_switchkins_remap_config_cases.json`.
- The browser smoke shell guard also pins required section names for LinuxCNC
browser parsing, OPFS parameter restore/save failure handling, and browser
app OPFS reload coverage.
- Smoke wrappers must keep positive minimum coverage thresholds so accidental - Smoke wrappers must keep positive minimum coverage thresholds so accidental
section loss is visible. section loss is visible.

View File

@@ -160,6 +160,32 @@ for imported_module in (
if f'from "{imported_module}"' not in opfs_workspace: if f'from "{imported_module}"' not in opfs_workspace:
print(f"browser smoke OPFS workspace module must import {imported_module}", file=sys.stderr) print(f"browser smoke OPFS workspace module must import {imported_module}", file=sys.stderr)
sys.exit(1) sys.exit(1)
required_browser_sections = {
"web/test-browser-wasm-smoke-linuxcnc-sections.js": (
'runSection("linuxcnc browser basic parse"',
'runSection("linuxcnc generated switchkins cases load"',
'runSection("linuxcnc browser parse parameter scratch cleanup"',
),
"web/test-browser-wasm-smoke-opfs-basic-sections.js": (
'runSection("opfs program parse and restore"',
),
"web/test-browser-wasm-smoke-opfs-parameter-sections.js": (
'runSection("opfs parameter restore in new instance"',
'runSection("opfs default parameter backup"',
'runSection("opfs invalid parameter restore failures"',
'runSection("opfs stale parameter state cleanup"',
),
"web/test-browser-wasm-smoke-app-sections.js": (
'runSection("browser app opfs save"',
'runSection("browser app opfs restore"',
),
}
for section_module, required_sections in required_browser_sections.items():
section_text = Path(section_module).read_text(encoding="utf-8")
for required_section in required_sections:
if required_section not in section_text:
print(f"browser smoke module {section_module} missing required section {required_section}", file=sys.stderr)
sys.exit(1)
app_html = Path("web/index.html").read_text(encoding="utf-8") app_html = Path("web/index.html").read_text(encoding="utf-8")
if '<link rel="stylesheet" href="/styles.css" />' not in app_html: if '<link rel="stylesheet" href="/styles.css" />' not in app_html:
print("browser app HTML must load /styles.css", file=sys.stderr) print("browser app HTML must load /styles.css", file=sys.stderr)