test
This commit is contained in:
@@ -6,13 +6,16 @@ cat <<'EOF'
|
|||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
const stamp = () => new Date().toISOString();
|
const stamp = () => new Date().toISOString();
|
||||||
|
const counts = {};
|
||||||
const wrap = (name) => {
|
const wrap = (name) => {
|
||||||
const original = window[name];
|
const original = window[name];
|
||||||
if (typeof original !== "function" || original.__deployTestProbe) {
|
if (typeof original !== "function") {
|
||||||
console.log(`[probe] ${name}:`, typeof original);
|
console.log(`[probe] ${name}:`, typeof original);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
counts[name] = 0;
|
||||||
const wrapped = function (...args) {
|
const wrapped = function (...args) {
|
||||||
|
counts[name] += 1;
|
||||||
console.log(`[probe ${stamp()}] ${name} called`, args);
|
console.log(`[probe ${stamp()}] ${name} called`, args);
|
||||||
try {
|
try {
|
||||||
const ret = original.apply(this, args);
|
const ret = original.apply(this, args);
|
||||||
@@ -24,7 +27,9 @@ cat <<'EOF'
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
wrapped.__deployTestProbe = true;
|
wrapped.__deployTestProbe = true;
|
||||||
|
wrapped.__deployTestOriginal = original;
|
||||||
window[name] = wrapped;
|
window[name] = wrapped;
|
||||||
|
console.log(`[probe] ${name}: wrapped`);
|
||||||
};
|
};
|
||||||
|
|
||||||
["initSDK", "login", "commonEventFunc"].forEach(wrap);
|
["initSDK", "login", "commonEventFunc"].forEach(wrap);
|
||||||
@@ -42,10 +47,16 @@ cat <<'EOF'
|
|||||||
commonEventFunc: typeof window.commonEventFunc,
|
commonEventFunc: typeof window.commonEventFunc,
|
||||||
openIMRenderApi: typeof window.openIMRenderApi,
|
openIMRenderApi: typeof window.openIMRenderApi,
|
||||||
});
|
});
|
||||||
|
window.__deployTestProbeCounts = counts;
|
||||||
|
clearInterval(window.__deployTestProbeTimer);
|
||||||
|
window.__deployTestProbeTimer = setInterval(() => {
|
||||||
|
console.log(`[probe ${stamp()}] counts`, { ...counts });
|
||||||
|
}, 5000);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
然后退出登录/刷新页面重新登录一次,观察是否打印:
|
然后退出登录/刷新页面重新登录一次,观察是否打印:
|
||||||
- initSDK called / returned
|
- initSDK called / returned
|
||||||
- login called / returned
|
- login called / returned
|
||||||
- window error / unhandledrejection
|
- window error / unhandledrejection
|
||||||
|
- counts 里的 initSDK/login 是否从 0 变成 1
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user