feat: 增强内容脚本加载逻辑,优化错误处理和测试用例
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user