Fix PayPal hosted checkout flow

This commit is contained in:
QLHazyCoder
2026-05-20 12:11:19 +08:00
parent 0b58e1116e
commit d1061b1c4a
10 changed files with 182 additions and 142 deletions
+29
View File
@@ -127,6 +127,35 @@ return { shouldReportReadyForFrame };
assert.equal(api.shouldReportReadyForFrame('unknown-source', true), false);
});
test('simulateClick logs the button text captured before click side effects', () => {
const bundle = [extractFunction('simulateClick')].join('\n');
const logs = [];
const consoleMessages = [];
const api = new Function('logs', 'console', 'location', `
function throwIfStopped() {}
const LOG_PREFIX = '[test]';
function log(message) { logs.push(message); }
${bundle}
return { simulateClick };
`)(logs, { log: (...args) => consoleMessages.push(args.join(' ')) }, { pathname: '/checkout' });
const button = {
tagName: 'BUTTON',
textContent: '订阅',
getAttribute: () => '',
click() {
this.textContent = '正在处理';
},
};
api.simulateClick(button);
assert.equal(button.textContent, '正在处理');
assert.equal(logs.at(-1), '已点击(click) [BUTTON] "订阅"');
assert.match(consoleMessages.at(-1), /BUTTON 订阅/);
assert.doesNotMatch(logs.at(-1), /正在处理/);
});
test('getRuntimeScriptSource follows injected source overrides after utils is already loaded', () => {
const bundle = [extractFunction('getRuntimeScriptSource')].join('\n');
const api = new Function('window', 'SCRIPT_SOURCE', `