收口微信页面事件诊断日志

微信 web-view 页面事件日志改为固定阶段标签

原生壳门禁拒绝输出 WebView 原生事件体

同步宿主壳方案和共享决策记录
This commit is contained in:
2026-06-21 15:58:55 +08:00
parent 3991b6cc23
commit 520aa049d3
5 changed files with 100 additions and 17 deletions
+52
View File
@@ -2817,6 +2817,55 @@ function assertWechatAuthFailureBoundaries() {
}
}
function assertWechatWebViewPageEventBoundaries() {
const webViewShellSource = fs.readFileSync(
'miniprogram/shell/webView.js',
'utf8',
);
const webViewTestSource = fs.readFileSync(
'miniprogram/shell/webView.test.js',
'utf8',
);
for (const snippet of [
'function logWebViewPageEvent(label, _detail)',
'function logWebViewPageFailure(label, _detail)',
'console.info(`[web-view] ${label}`)',
'console.error(`[web-view] ${label}`)',
"logWebViewPageEvent('loaded', event.detail)",
"logWebViewPageFailure('load failed', event.detail)",
"logWebViewPageEvent('message', event.detail)",
]) {
if (!webViewShellSource.includes(snippet)) {
throw new Error(`wechat web-view page event diagnostics must include ${snippet}`);
}
}
for (const forbiddenSnippet of [
"console.info('[web-view] loaded', event.detail)",
"console.error('[web-view] load failed', event.detail)",
"console.info('[web-view] message', event.detail)",
]) {
if (webViewShellSource.includes(forbiddenSnippet)) {
throw new Error(`wechat web-view page event diagnostics must not expose native detail via ${forbiddenSnippet}`);
}
}
for (const snippet of [
'logs web-view page events without native detail payloads',
"expect(console.info).toHaveBeenCalledWith('[web-view] loaded')",
"expect(console.error).toHaveBeenCalledWith('[web-view] load failed')",
'expect(console.info.mock.calls.flat()).not.toContain(loadDetail)',
'expect(console.error.mock.calls.flat()).not.toContain(errorDetail)',
"expect(console.info).toHaveBeenCalledWith('[web-view] message')",
'expect(console.info.mock.calls.flat()).not.toContain(webViewDetail)',
]) {
if (!webViewTestSource.includes(snippet)) {
throw new Error(`wechat web-view page event boundary test must include ${snippet}`);
}
}
}
function assertWechatShareGridFailureBoundaries() {
const shareGridSource = fs.readFileSync(
'miniprogram/shell/shareGrid.js',
@@ -3131,6 +3180,9 @@ assertWechatSubscribeResultBoundaries();
console.log('[check:native-shells] wechat-auth-failure-boundaries');
assertWechatAuthFailureBoundaries();
console.log('[check:native-shells] wechat-web-view-page-event-boundaries');
assertWechatWebViewPageEventBoundaries();
console.log('[check:native-shells] wechat-share-grid-failure-boundaries');
assertWechatShareGridFailureBoundaries();