feat: 增强内容脚本加载逻辑,优化错误处理和测试用例

This commit is contained in:
QLHazyCoder
2026-04-26 15:29:26 +08:00
parent 7b668fdcaf
commit 336fdb0c3a
7 changed files with 174 additions and 129 deletions
+13
View File
@@ -92,3 +92,16 @@ return { shouldReportReadyForFrame };
assert.equal(api.shouldReportReadyForFrame('plus-checkout', false), true);
assert.equal(api.shouldReportReadyForFrame('paypal-flow', true), true);
});
test('getRuntimeScriptSource follows injected source overrides after utils is already loaded', () => {
const bundle = [extractFunction('getRuntimeScriptSource')].join('\n');
const api = new Function('window', 'SCRIPT_SOURCE', `
${bundle}
return { getRuntimeScriptSource };
`);
const windowRef = {};
assert.equal(api(windowRef, 'chatgpt').getRuntimeScriptSource(), 'chatgpt');
windowRef.__MULTIPAGE_SOURCE = 'plus-checkout';
assert.equal(api(windowRef, 'chatgpt').getRuntimeScriptSource(), 'plus-checkout');
});