feat: enhance signup flow with multiple profile page patterns and improved error handling during verification
This commit is contained in:
+1
-1
@@ -10729,7 +10729,7 @@ const signupFlowHelpers = self.MultiPageSignupFlowHelpers?.createSignupFlowHelpe
|
|||||||
},
|
},
|
||||||
isSignupProfilePageUrl: (rawUrl) => {
|
isSignupProfilePageUrl: (rawUrl) => {
|
||||||
const parsed = parseUrlSafely(rawUrl);
|
const parsed = parseUrlSafely(rawUrl);
|
||||||
return Boolean(parsed && isSignupPageHost(parsed.hostname) && /\/create-account\/profile(?:[/?#]|$)/i.test(parsed.pathname || ''));
|
return Boolean(parsed && isSignupPageHost(parsed.hostname) && /\/(?:create-account\/profile|u\/signup\/profile|signup\/profile)(?:[/?#]|$)/i.test(parsed.pathname || ''));
|
||||||
},
|
},
|
||||||
isRetryableContentScriptTransportError,
|
isRetryableContentScriptTransportError,
|
||||||
isHotmailProvider,
|
isHotmailProvider,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
function fallbackSignupProfilePageUrl(rawUrl) {
|
function fallbackSignupProfilePageUrl(rawUrl) {
|
||||||
const parsed = parseUrlSafely(rawUrl);
|
const parsed = parseUrlSafely(rawUrl);
|
||||||
if (!parsed) return false;
|
if (!parsed) return false;
|
||||||
return /\/create-account\/profile(?:[/?#]|$)/i.test(parsed.pathname || '');
|
return /\/(?:create-account\/profile|u\/signup\/profile|signup\/profile)(?:[/?#]|$)/i.test(parsed.pathname || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveSignupPostIdentityState(rawUrl) {
|
function resolveSignupPostIdentityState(rawUrl) {
|
||||||
|
|||||||
@@ -135,7 +135,7 @@
|
|||||||
if (!['auth.openai.com', 'auth0.openai.com', 'accounts.openai.com'].includes(host)) {
|
if (!['auth.openai.com', 'auth0.openai.com', 'accounts.openai.com'].includes(host)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return /\/create-account\/profile(?:[/?#]|$)/i.test(String(parsed.pathname || ''));
|
return /\/(?:create-account\/profile|u\/signup\/profile|signup\/profile)(?:[/?#]|$)/i.test(String(parsed.pathname || ''));
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -225,11 +225,21 @@
|
|||||||
|
|
||||||
const authState = String(result?.state || '').trim();
|
const authState = String(result?.state || '').trim();
|
||||||
const authUrl = String(result?.url || '').trim();
|
const authUrl = String(result?.url || '').trim();
|
||||||
|
const verificationErrorText = String(result?.verificationErrorText || '').trim();
|
||||||
lastSnapshot = {
|
lastSnapshot = {
|
||||||
state: authState || 'unknown',
|
state: authState || 'unknown',
|
||||||
url: authUrl,
|
url: authUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (authState === 'verification_page' && verificationErrorText) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
reason: 'invalid_code',
|
||||||
|
invalidCode: true,
|
||||||
|
errorText: verificationErrorText,
|
||||||
|
url: authUrl,
|
||||||
|
};
|
||||||
|
}
|
||||||
if (authState === 'oauth_consent_page') {
|
if (authState === 'oauth_consent_page') {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -1068,7 +1078,8 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
let result;
|
let result;
|
||||||
if (typeof sendToContentScriptResilient === 'function') {
|
const shouldAvoidReplaySubmit = step === 8;
|
||||||
|
if (typeof sendToContentScriptResilient === 'function' && !shouldAvoidReplaySubmit) {
|
||||||
try {
|
try {
|
||||||
result = await sendToContentScriptResilient('signup-page', message, {
|
result = await sendToContentScriptResilient('signup-page', message, {
|
||||||
timeoutMs: Math.max(baseResponseTimeoutMs + 15000, 30000),
|
timeoutMs: Math.max(baseResponseTimeoutMs + 15000, 30000),
|
||||||
@@ -1131,6 +1142,56 @@
|
|||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
} else if (shouldAvoidReplaySubmit) {
|
||||||
|
try {
|
||||||
|
result = await sendToContentScript('signup-page', message, {
|
||||||
|
responseTimeoutMs: baseResponseTimeoutMs,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
if (isRetryableVerificationTransportError(err)) {
|
||||||
|
await addLog('认证页正在切换,等待页面重新就绪后继续确认验证码提交结果...', 'warn', {
|
||||||
|
step: completionStep,
|
||||||
|
stepKey: 'fetch-login-code',
|
||||||
|
});
|
||||||
|
const fallback = await detectStep8PostSubmitFallback({
|
||||||
|
step,
|
||||||
|
timeoutMs: 9000,
|
||||||
|
pollIntervalMs: 300,
|
||||||
|
});
|
||||||
|
if (fallback.invalidCode) {
|
||||||
|
return {
|
||||||
|
invalidCode: true,
|
||||||
|
errorText: fallback.errorText || '验证码被拒绝。',
|
||||||
|
url: fallback.url || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (fallback.success) {
|
||||||
|
if (fallback.addPhonePage) {
|
||||||
|
await addLog('验证码提交后通信中断,但页面已进入手机号验证页,按提交成功继续。', 'warn', {
|
||||||
|
step: completionStep,
|
||||||
|
stepKey: 'fetch-login-code',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await addLog('验证码提交后通信中断,但页面已进入 OAuth 授权页,按提交成功继续。', 'warn', {
|
||||||
|
step: completionStep,
|
||||||
|
stepKey: 'fetch-login-code',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
assumed: true,
|
||||||
|
transportRecovered: true,
|
||||||
|
addPhonePage: Boolean(fallback.addPhonePage),
|
||||||
|
url: fallback.url || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (fallback.restartStep7) {
|
||||||
|
const urlPart = fallback.url ? ` URL: ${fallback.url}` : '';
|
||||||
|
throw new Error(`STEP8_RESTART_STEP7::步骤 ${completionStep}:验证码提交后认证页进入登录超时报错页,请回到步骤 ${authLoginStep} 重新开始。${urlPart}`.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result = await sendToContentScript('signup-page', message, {
|
result = await sendToContentScript('signup-page', message, {
|
||||||
responseTimeoutMs: baseResponseTimeoutMs,
|
responseTimeoutMs: baseResponseTimeoutMs,
|
||||||
@@ -1275,20 +1336,8 @@
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const remainingBeforeResendMs = resendIntervalMs > 0 && lastResendAt > 0
|
|
||||||
? Math.max(0, resendIntervalMs - (Date.now() - lastResendAt))
|
|
||||||
: 0;
|
|
||||||
if (remainingBeforeResendMs > 0) {
|
|
||||||
await addLog(
|
|
||||||
`步骤 ${step}:提交失败后距离下次重新发送验证码还差 ${Math.ceil(remainingBeforeResendMs / 1000)} 秒,先继续刷新邮箱(${attempt + 1}/${maxSubmitAttempts})...`,
|
|
||||||
'warn'
|
|
||||||
);
|
|
||||||
await sleepWithStop(Math.min(remainingBeforeResendMs, 2000));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remainingAutomaticResendCount <= 0) {
|
if (remainingAutomaticResendCount <= 0) {
|
||||||
await addLog(`步骤 ${step}:已达到自动重新发送验证码次数上限,将直接使用当前时间窗口继续重试。`, 'warn');
|
await addLog(`步骤 ${step}:已达到自动重新发送验证码次数上限,将排除已拒绝验证码并继续轮询新邮件。`, 'warn');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+289
-13
@@ -2627,7 +2627,7 @@ function isSignupProfilePageUrl(rawUrl = location.href) {
|
|||||||
if (!['auth.openai.com', 'auth0.openai.com', 'accounts.openai.com'].includes(host)) {
|
if (!['auth.openai.com', 'auth0.openai.com', 'accounts.openai.com'].includes(host)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return /\/create-account\/profile(?:[/?#]|$)/i.test(String(parsed.pathname || ''));
|
return /\/(?:create-account\/profile|u\/signup\/profile|signup\/profile)(?:[/?#]|$)/i.test(String(parsed.pathname || ''));
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3991,6 +3991,7 @@ function serializeLoginAuthState(snapshot) {
|
|||||||
url: snapshot?.url || location.href,
|
url: snapshot?.url || location.href,
|
||||||
path: snapshot?.path || location.pathname || '',
|
path: snapshot?.path || location.pathname || '',
|
||||||
displayedEmail: snapshot?.displayedEmail || '',
|
displayedEmail: snapshot?.displayedEmail || '',
|
||||||
|
verificationErrorText: getVerificationErrorText(),
|
||||||
retryEnabled: Boolean(snapshot?.retryEnabled),
|
retryEnabled: Boolean(snapshot?.retryEnabled),
|
||||||
titleMatched: Boolean(snapshot?.titleMatched),
|
titleMatched: Boolean(snapshot?.titleMatched),
|
||||||
detailMatched: Boolean(snapshot?.detailMatched),
|
detailMatched: Boolean(snapshot?.detailMatched),
|
||||||
@@ -6028,14 +6029,23 @@ function getSerializableRect(el) {
|
|||||||
// Step 5: Fill Name & Birthday / Age
|
// Step 5: Fill Name & Birthday / Age
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
||||||
function getStep5DirectCompletionPayload({ isAgeMode = false } = {}) {
|
function getStep5DirectCompletionPayload({ isAgeMode = false, navigationStarted = false, outcome = null } = {}) {
|
||||||
const payload = {
|
const payload = {
|
||||||
skippedPostSubmitCheck: true,
|
profileSubmitted: true,
|
||||||
directProceedToStep6: true,
|
postSubmitChecked: true,
|
||||||
};
|
};
|
||||||
if (isAgeMode) {
|
if (isAgeMode) {
|
||||||
payload.ageMode = true;
|
payload.ageMode = true;
|
||||||
}
|
}
|
||||||
|
if (navigationStarted) {
|
||||||
|
payload.navigationStarted = true;
|
||||||
|
}
|
||||||
|
if (outcome?.state) {
|
||||||
|
payload.outcome = outcome.state;
|
||||||
|
}
|
||||||
|
if (outcome?.url) {
|
||||||
|
payload.url = outcome.url;
|
||||||
|
}
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6084,6 +6094,252 @@ async function waitForCombinedSignupVerificationProfilePage(timeout = 2500) {
|
|||||||
return isCombinedSignupVerificationProfilePage();
|
return isCombinedSignupVerificationProfilePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStep5ProfilePathPatterns() {
|
||||||
|
return [
|
||||||
|
/\/create-account\/profile(?:[/?#]|$)/i,
|
||||||
|
/\/u\/signup\/profile(?:[/?#]|$)/i,
|
||||||
|
/\/signup\/profile(?:[/?#]|$)/i,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStep5AuthRetryPathPatterns() {
|
||||||
|
const signupPatterns = typeof getSignupAuthRetryPathPatterns === 'function'
|
||||||
|
? getSignupAuthRetryPathPatterns()
|
||||||
|
: [];
|
||||||
|
return [
|
||||||
|
...signupPatterns,
|
||||||
|
...getStep5ProfilePathPatterns(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function isStep5ProfilePageUrl(rawUrl = location.href) {
|
||||||
|
return isSignupProfilePageUrl(rawUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStep5AuthRetryPageState() {
|
||||||
|
if (typeof getAuthTimeoutErrorPageState === 'function') {
|
||||||
|
return getAuthTimeoutErrorPageState({
|
||||||
|
pathPatterns: getStep5AuthRetryPathPatterns(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof getCurrentAuthRetryPageState === 'function') {
|
||||||
|
return getCurrentAuthRetryPageState('signup');
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStep5SubmitButton() {
|
||||||
|
const direct = document.querySelector('button[type="submit"], input[type="submit"]');
|
||||||
|
if (direct && isVisibleElement(direct)) {
|
||||||
|
return direct;
|
||||||
|
}
|
||||||
|
|
||||||
|
const candidates = document.querySelectorAll('button, [role="button"], input[type="button"], input[type="submit"]');
|
||||||
|
return Array.from(candidates).find((el) => {
|
||||||
|
if (!isVisibleElement(el)) return false;
|
||||||
|
const text = typeof getActionText === 'function'
|
||||||
|
? getActionText(el)
|
||||||
|
: [
|
||||||
|
el?.textContent,
|
||||||
|
el?.value,
|
||||||
|
el?.getAttribute?.('aria-label'),
|
||||||
|
el?.getAttribute?.('title'),
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
return /完成|创建|create|continue|finish|done|agree/i.test(text);
|
||||||
|
}) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitForStep5SubmitButton(timeout = 5000) {
|
||||||
|
const start = Date.now();
|
||||||
|
|
||||||
|
while (Date.now() - start < timeout) {
|
||||||
|
throwIfStopped();
|
||||||
|
const button = getStep5SubmitButton();
|
||||||
|
if (button) {
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
await sleep(150);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isStep5SubmitButtonClickable(button) {
|
||||||
|
return Boolean(button)
|
||||||
|
&& isVisibleElement(button)
|
||||||
|
&& !button.disabled
|
||||||
|
&& button.getAttribute?.('aria-disabled') !== 'true';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isStep5ProfileStillVisible() {
|
||||||
|
if (isStep5ProfilePageUrl()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof isStep5Ready === 'function' ? isStep5Ready() : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStep5PostSubmitSuccessState() {
|
||||||
|
if (getStep5AuthRetryPageState()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLikelyLoggedInChatgptHomeUrl()) {
|
||||||
|
return {
|
||||||
|
state: 'logged_in_home',
|
||||||
|
url: location.href,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof isOAuthConsentPage === 'function' && isOAuthConsentPage()) {
|
||||||
|
return {
|
||||||
|
state: 'oauth_consent',
|
||||||
|
url: location.href,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof isAddPhonePageReady === 'function' && isAddPhonePageReady()) {
|
||||||
|
return {
|
||||||
|
state: 'add_phone',
|
||||||
|
url: location.href,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isStep5ProfileStillVisible()) {
|
||||||
|
return {
|
||||||
|
state: 'left_profile',
|
||||||
|
url: location.href,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function installStep5NavigationCompletionReporter(completeOnce) {
|
||||||
|
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') {
|
||||||
|
return () => {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const onNavigationStarted = () => {
|
||||||
|
completeOnce({
|
||||||
|
navigationStarted: true,
|
||||||
|
outcome: {
|
||||||
|
state: 'navigation_started',
|
||||||
|
url: location.href,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('pagehide', onNavigationStarted, { once: true });
|
||||||
|
window.addEventListener('beforeunload', onNavigationStarted, { once: true });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('pagehide', onNavigationStarted);
|
||||||
|
window.removeEventListener('beforeunload', onNavigationStarted);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitForStep5SubmitOutcome(options = {}) {
|
||||||
|
const {
|
||||||
|
timeoutMs = 45000,
|
||||||
|
maxAuthRetryRecoveries = 2,
|
||||||
|
maxSubmitClicks = 3,
|
||||||
|
retryClickIntervalMs = 3500,
|
||||||
|
} = options;
|
||||||
|
const start = Date.now();
|
||||||
|
let authRetryRecoveryCount = 0;
|
||||||
|
let submitClickCount = 1;
|
||||||
|
let lastSubmitClickAt = Date.now();
|
||||||
|
let lastStep5Error = '';
|
||||||
|
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
throwIfStopped();
|
||||||
|
|
||||||
|
const retryState = getStep5AuthRetryPageState();
|
||||||
|
if (retryState?.userAlreadyExistsBlocked) {
|
||||||
|
throw createSignupUserAlreadyExistsError();
|
||||||
|
}
|
||||||
|
if (retryState?.maxCheckAttemptsBlocked) {
|
||||||
|
throw createAuthMaxCheckAttemptsError();
|
||||||
|
}
|
||||||
|
if (retryState) {
|
||||||
|
if (authRetryRecoveryCount >= maxAuthRetryRecoveries) {
|
||||||
|
throw new Error(`步骤 5:资料提交后连续进入认证重试页 ${maxAuthRetryRecoveries} 次,页面仍未恢复。URL: ${location.href}`);
|
||||||
|
}
|
||||||
|
authRetryRecoveryCount += 1;
|
||||||
|
log(`步骤 5:资料提交后进入认证重试页,正在自动恢复(${authRetryRecoveryCount}/${maxAuthRetryRecoveries})...`, 'warn');
|
||||||
|
await recoverCurrentAuthRetryPage({
|
||||||
|
flow: 'signup',
|
||||||
|
logLabel: '步骤 5:资料提交后检测到认证重试页,正在点击“重试”恢复',
|
||||||
|
maxClickAttempts: 2,
|
||||||
|
pathPatterns: getStep5AuthRetryPathPatterns(),
|
||||||
|
step: 5,
|
||||||
|
timeoutMs: 12000,
|
||||||
|
});
|
||||||
|
lastSubmitClickAt = Date.now();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const successState = getStep5PostSubmitSuccessState();
|
||||||
|
if (successState) {
|
||||||
|
return successState;
|
||||||
|
}
|
||||||
|
|
||||||
|
const step5Error = typeof getStep5ErrorText === 'function' ? getStep5ErrorText() : '';
|
||||||
|
if (step5Error) {
|
||||||
|
lastStep5Error = step5Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
isStep5ProfileStillVisible()
|
||||||
|
&& submitClickCount < maxSubmitClicks
|
||||||
|
&& Date.now() - lastSubmitClickAt >= retryClickIntervalMs
|
||||||
|
) {
|
||||||
|
const submitButton = getStep5SubmitButton();
|
||||||
|
if (isStep5SubmitButtonClickable(submitButton)) {
|
||||||
|
submitClickCount += 1;
|
||||||
|
log(`步骤 5:资料提交后仍停留在资料页,正在重新点击“完成帐户创建”(第 ${submitClickCount}/${maxSubmitClicks} 次)...`, 'warn');
|
||||||
|
await humanPause(350, 900);
|
||||||
|
simulateClick(submitButton);
|
||||||
|
lastSubmitClickAt = Date.now();
|
||||||
|
await sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await sleep(250);
|
||||||
|
}
|
||||||
|
|
||||||
|
const finalRetryState = getStep5AuthRetryPageState();
|
||||||
|
if (finalRetryState?.userAlreadyExistsBlocked) {
|
||||||
|
throw createSignupUserAlreadyExistsError();
|
||||||
|
}
|
||||||
|
if (finalRetryState?.maxCheckAttemptsBlocked) {
|
||||||
|
throw createAuthMaxCheckAttemptsError();
|
||||||
|
}
|
||||||
|
if (finalRetryState) {
|
||||||
|
throw new Error(`步骤 5:资料提交后仍停留在认证重试页,自动恢复未完成。URL: ${location.href}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const finalSuccessState = getStep5PostSubmitSuccessState();
|
||||||
|
if (finalSuccessState) {
|
||||||
|
return finalSuccessState;
|
||||||
|
}
|
||||||
|
|
||||||
|
const finalStep5Error = (typeof getStep5ErrorText === 'function' ? getStep5ErrorText() : '') || lastStep5Error;
|
||||||
|
if (finalStep5Error) {
|
||||||
|
throw new Error(`步骤 5:资料提交后页面返回错误:${finalStep5Error}。URL: ${location.href}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`步骤 5:资料提交后未检测到页面跳转或恢复成功(已点击提交 ${submitClickCount}/${maxSubmitClicks} 次)。URL: ${location.href}`);
|
||||||
|
}
|
||||||
|
|
||||||
async function step5_fillNameBirthday(payload) {
|
async function step5_fillNameBirthday(payload) {
|
||||||
const { firstName, lastName, age, year, month, day, prefillOnly = false } = payload;
|
const { firstName, lastName, age, year, month, day, prefillOnly = false } = payload;
|
||||||
if (!firstName || !lastName) throw new Error('未提供姓名数据。');
|
if (!firstName || !lastName) throw new Error('未提供姓名数据。');
|
||||||
@@ -6291,7 +6547,7 @@ async function step5_fillNameBirthday(payload) {
|
|||||||
|
|
||||||
// Click "完成帐户创建" button
|
// Click "完成帐户创建" button
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
const completeBtn = document.querySelector('button[type="submit"]')
|
const completeBtn = await waitForStep5SubmitButton(5000)
|
||||||
|| await waitForElementByText('button', /完成|create|continue|finish|done|agree/i, 5000).catch(() => null);
|
|| await waitForElementByText('button', /完成|create|continue|finish|done|agree/i, 5000).catch(() => null);
|
||||||
if (!completeBtn) {
|
if (!completeBtn) {
|
||||||
throw new Error('未找到“完成帐户创建”按钮。URL: ' + location.href);
|
throw new Error('未找到“完成帐户创建”按钮。URL: ' + location.href);
|
||||||
@@ -6299,20 +6555,40 @@ async function step5_fillNameBirthday(payload) {
|
|||||||
|
|
||||||
const isAgeMode = !birthdayMode && Boolean(ageInput);
|
const isAgeMode = !birthdayMode && Boolean(ageInput);
|
||||||
if (isAgeMode) {
|
if (isAgeMode) {
|
||||||
log('步骤 5:当前为年龄输入模式,点击“完成帐户创建”后将直接完成当前步骤。', 'warn');
|
log('步骤 5:当前为年龄输入模式,点击“完成帐户创建”后将等待页面结果。', 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let reportedCompletionPayload = null;
|
||||||
|
function completeStep5Once(extra = {}) {
|
||||||
|
if (reportedCompletionPayload) {
|
||||||
|
return reportedCompletionPayload;
|
||||||
|
}
|
||||||
|
|
||||||
|
const completionPayload = getStep5DirectCompletionPayload({
|
||||||
|
isAgeMode,
|
||||||
|
navigationStarted: Boolean(extra.navigationStarted),
|
||||||
|
outcome: extra.outcome || null,
|
||||||
|
});
|
||||||
|
reportedCompletionPayload = completionPayload;
|
||||||
|
reportComplete(5, completionPayload);
|
||||||
|
return completionPayload;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanupNavigationReporter = installStep5NavigationCompletionReporter(completeStep5Once);
|
||||||
|
|
||||||
await humanPause(500, 1300);
|
await humanPause(500, 1300);
|
||||||
simulateClick(completeBtn);
|
simulateClick(completeBtn);
|
||||||
|
log('步骤 5:已点击“完成帐户创建”,正在等待页面跳转、重试页或提交结果。');
|
||||||
|
|
||||||
const completionPayload = getStep5DirectCompletionPayload({ isAgeMode });
|
try {
|
||||||
reportComplete(5, completionPayload);
|
const outcome = await waitForStep5SubmitOutcome();
|
||||||
|
cleanupNavigationReporter();
|
||||||
|
|
||||||
if (isAgeMode) {
|
const completionPayload = completeStep5Once({ outcome });
|
||||||
log('步骤 5:年龄模式已点击“完成帐户创建”,当前步骤直接完成,不再等待页面结果。', 'warn');
|
log(`步骤 5:资料提交结果已确认(${outcome.state || 'success'}),准备继续后续步骤。`, 'ok');
|
||||||
return completionPayload;
|
return completionPayload;
|
||||||
|
} catch (error) {
|
||||||
|
cleanupNavigationReporter();
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
log('步骤 5:已点击“完成帐户创建”,当前步骤直接完成,不再等待页面结果。');
|
|
||||||
return completionPayload;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,21 @@ function extractFunction(name) {
|
|||||||
function getStep5Bundle() {
|
function getStep5Bundle() {
|
||||||
return [
|
return [
|
||||||
extractFunction('getStep5DirectCompletionPayload'),
|
extractFunction('getStep5DirectCompletionPayload'),
|
||||||
|
extractFunction('isSignupProfilePageUrl'),
|
||||||
extractFunction('isStep5AllConsentText'),
|
extractFunction('isStep5AllConsentText'),
|
||||||
extractFunction('findStep5AllConsentCheckbox'),
|
extractFunction('findStep5AllConsentCheckbox'),
|
||||||
extractFunction('isStep5CheckboxChecked'),
|
extractFunction('isStep5CheckboxChecked'),
|
||||||
|
extractFunction('getStep5ProfilePathPatterns'),
|
||||||
|
extractFunction('getStep5AuthRetryPathPatterns'),
|
||||||
|
extractFunction('isStep5ProfilePageUrl'),
|
||||||
|
extractFunction('getStep5AuthRetryPageState'),
|
||||||
|
extractFunction('getStep5SubmitButton'),
|
||||||
|
extractFunction('waitForStep5SubmitButton'),
|
||||||
|
extractFunction('isStep5SubmitButtonClickable'),
|
||||||
|
extractFunction('isStep5ProfileStillVisible'),
|
||||||
|
extractFunction('getStep5PostSubmitSuccessState'),
|
||||||
|
extractFunction('installStep5NavigationCompletionReporter'),
|
||||||
|
extractFunction('waitForStep5SubmitOutcome'),
|
||||||
extractFunction('step5_fillNameBirthday'),
|
extractFunction('step5_fillNameBirthday'),
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
@@ -73,6 +85,9 @@ const completeButton = {
|
|||||||
tagName: 'BUTTON',
|
tagName: 'BUTTON',
|
||||||
textContent: '\\u5b8c\\u6210\\u8d26\\u6237\\u521b\\u5efa',
|
textContent: '\\u5b8c\\u6210\\u8d26\\u6237\\u521b\\u5efa',
|
||||||
hidden: false,
|
hidden: false,
|
||||||
|
getAttribute() {
|
||||||
|
return '';
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const allConsentLabel = {
|
const allConsentLabel = {
|
||||||
hidden: false,
|
hidden: false,
|
||||||
@@ -110,6 +125,7 @@ const document = {
|
|||||||
return null;
|
return null;
|
||||||
case 'input[name="age"]':
|
case 'input[name="age"]':
|
||||||
return ageInput;
|
return ageInput;
|
||||||
|
case 'button[type="submit"], input[type="submit"]':
|
||||||
case 'button[type="submit"]':
|
case 'button[type="submit"]':
|
||||||
return completeButton;
|
return completeButton;
|
||||||
default:
|
default:
|
||||||
@@ -136,6 +152,8 @@ function log(message, level = 'info') {
|
|||||||
logs.push({ message, level });
|
logs.push({ message, level });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function throwIfStopped() {}
|
||||||
|
|
||||||
async function waitForElement() {
|
async function waitForElement() {
|
||||||
return nameInput;
|
return nameInput;
|
||||||
}
|
}
|
||||||
@@ -155,6 +173,14 @@ function isVisibleElement(el) {
|
|||||||
return Boolean(el) && !el.hidden;
|
return Boolean(el) && !el.hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isActionEnabled(el) {
|
||||||
|
return Boolean(el) && !el.disabled && el.getAttribute?.('aria-disabled') !== 'true';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActionText(el) {
|
||||||
|
return el.textContent || '';
|
||||||
|
}
|
||||||
|
|
||||||
async function setReactAriaBirthdaySelect() {
|
async function setReactAriaBirthdaySelect() {
|
||||||
throw new Error('setReactAriaBirthdaySelect should not run in age-mode test');
|
throw new Error('setReactAriaBirthdaySelect should not run in age-mode test');
|
||||||
}
|
}
|
||||||
@@ -168,6 +194,9 @@ function simulateClick(el) {
|
|||||||
if (el === allConsentLabel || el === allConsentCheckbox) {
|
if (el === allConsentLabel || el === allConsentCheckbox) {
|
||||||
allConsentCheckbox.checked = true;
|
allConsentCheckbox.checked = true;
|
||||||
}
|
}
|
||||||
|
if (el === completeButton) {
|
||||||
|
location.href = 'https://chatgpt.com/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reportComplete(step, payload) {
|
function reportComplete(step, payload) {
|
||||||
@@ -178,6 +207,17 @@ function normalizeInlineText(text) {
|
|||||||
return String(text || '').replace(/\\s+/g, ' ').trim();
|
return String(text || '').replace(/\\s+/g, ' ').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSignupAuthRetryPathPatterns() { return []; }
|
||||||
|
function getAuthTimeoutErrorPageState() { return null; }
|
||||||
|
async function recoverCurrentAuthRetryPage() { throw new Error('should not recover retry page'); }
|
||||||
|
function createSignupUserAlreadyExistsError() { return new Error('user already exists'); }
|
||||||
|
function createAuthMaxCheckAttemptsError() { return new Error('max_check_attempts'); }
|
||||||
|
function getStep5ErrorText() { return ''; }
|
||||||
|
function isStep5Ready() { return /^https:\\/\\/auth\\.openai\\.com\\//.test(location.href); }
|
||||||
|
function isLikelyLoggedInChatgptHomeUrl() { return /^https:\\/\\/chatgpt\\.com\\//.test(location.href); }
|
||||||
|
function isOAuthConsentPage() { return false; }
|
||||||
|
function isAddPhonePageReady() { return false; }
|
||||||
|
|
||||||
${getStep5Bundle()}
|
${getStep5Bundle()}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -205,9 +245,11 @@ return {
|
|||||||
|
|
||||||
const snapshot = api.snapshot();
|
const snapshot = api.snapshot();
|
||||||
assert.deepStrictEqual(result, {
|
assert.deepStrictEqual(result, {
|
||||||
skippedPostSubmitCheck: true,
|
profileSubmitted: true,
|
||||||
directProceedToStep6: true,
|
postSubmitChecked: true,
|
||||||
ageMode: true,
|
ageMode: true,
|
||||||
|
outcome: 'logged_in_home',
|
||||||
|
url: 'https://chatgpt.com/',
|
||||||
});
|
});
|
||||||
assert.equal(snapshot.nameValue, 'Mia Harris');
|
assert.equal(snapshot.nameValue, 'Mia Harris');
|
||||||
assert.equal(snapshot.ageValue, '19');
|
assert.equal(snapshot.ageValue, '19');
|
||||||
@@ -220,9 +262,11 @@ return {
|
|||||||
{
|
{
|
||||||
step: 5,
|
step: 5,
|
||||||
payload: {
|
payload: {
|
||||||
skippedPostSubmitCheck: true,
|
profileSubmitted: true,
|
||||||
directProceedToStep6: true,
|
postSubmitChecked: true,
|
||||||
ageMode: true,
|
ageMode: true,
|
||||||
|
outcome: 'logged_in_home',
|
||||||
|
url: 'https://chatgpt.com/',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -51,21 +51,43 @@ function extractFunction(name) {
|
|||||||
return source.slice(start, end);
|
return source.slice(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStep5OutcomeBundle() {
|
||||||
|
return [
|
||||||
|
extractFunction('getStep5ProfilePathPatterns'),
|
||||||
|
extractFunction('getStep5AuthRetryPathPatterns'),
|
||||||
|
extractFunction('isStep5ProfilePageUrl'),
|
||||||
|
extractFunction('getStep5AuthRetryPageState'),
|
||||||
|
extractFunction('getStep5SubmitButton'),
|
||||||
|
extractFunction('waitForStep5SubmitButton'),
|
||||||
|
extractFunction('isStep5SubmitButtonClickable'),
|
||||||
|
extractFunction('isStep5ProfileStillVisible'),
|
||||||
|
extractFunction('getStep5PostSubmitSuccessState'),
|
||||||
|
extractFunction('installStep5NavigationCompletionReporter'),
|
||||||
|
extractFunction('waitForStep5SubmitOutcome'),
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
function getStep5Bundle() {
|
function getStep5Bundle() {
|
||||||
return [
|
return [
|
||||||
extractFunction('getStep5DirectCompletionPayload'),
|
extractFunction('getStep5DirectCompletionPayload'),
|
||||||
|
extractFunction('isSignupProfilePageUrl'),
|
||||||
extractFunction('isStep5AllConsentText'),
|
extractFunction('isStep5AllConsentText'),
|
||||||
extractFunction('findStep5AllConsentCheckbox'),
|
extractFunction('findStep5AllConsentCheckbox'),
|
||||||
extractFunction('isStep5CheckboxChecked'),
|
extractFunction('isStep5CheckboxChecked'),
|
||||||
|
getStep5OutcomeBundle(),
|
||||||
extractFunction('step5_fillNameBirthday'),
|
extractFunction('step5_fillNameBirthday'),
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
test('step 5 clicks submit and completes immediately on birthday page', async () => {
|
test('step 5 waits for post-submit outcome before completing on birthday page', async () => {
|
||||||
const step5Source = extractFunction('step5_fillNameBirthday');
|
const step5Source = extractFunction('step5_fillNameBirthday');
|
||||||
assert.ok(
|
assert.ok(
|
||||||
!step5Source.includes('waitForStep5SubmitOutcome('),
|
step5Source.includes('waitForStep5SubmitOutcome('),
|
||||||
'Step 5 提交后不应再等待页面结果'
|
'Step 5 提交后必须等待页面结果'
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
!step5Source.includes('不再等待页面结果'),
|
||||||
|
'Step 5 不应再保留直接完成的旧日志'
|
||||||
);
|
);
|
||||||
|
|
||||||
const api = new Function(`
|
const api = new Function(`
|
||||||
@@ -84,6 +106,7 @@ const completeButton = {
|
|||||||
tagName: 'BUTTON',
|
tagName: 'BUTTON',
|
||||||
textContent: '完成帐户创建',
|
textContent: '完成帐户创建',
|
||||||
hidden: false,
|
hidden: false,
|
||||||
|
getAttribute() { return ''; },
|
||||||
};
|
};
|
||||||
|
|
||||||
const birthdaySelects = {
|
const birthdaySelects = {
|
||||||
@@ -92,6 +115,10 @@ const birthdaySelects = {
|
|||||||
'天': { label: '天', button: { hidden: false }, nativeSelect: {} },
|
'天': { label: '天', button: { hidden: false }, nativeSelect: {} },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const location = {
|
||||||
|
href: 'https://auth.openai.com/u/signup/profile',
|
||||||
|
};
|
||||||
|
|
||||||
const document = {
|
const document = {
|
||||||
querySelector(selector) {
|
querySelector(selector) {
|
||||||
switch (selector) {
|
switch (selector) {
|
||||||
@@ -102,6 +129,7 @@ const document = {
|
|||||||
return null;
|
return null;
|
||||||
case 'input[name="birthday"]':
|
case 'input[name="birthday"]':
|
||||||
return hiddenBirthday;
|
return hiddenBirthday;
|
||||||
|
case 'button[type="submit"], input[type="submit"]':
|
||||||
case 'button[type="submit"]':
|
case 'button[type="submit"]':
|
||||||
return completeButton;
|
return completeButton;
|
||||||
default:
|
default:
|
||||||
@@ -112,15 +140,14 @@ const document = {
|
|||||||
if (selector === 'input[name="allCheckboxes"][type="checkbox"]') {
|
if (selector === 'input[name="allCheckboxes"][type="checkbox"]') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
if (selector === 'button, [role="button"], input[type="button"], input[type="submit"]') {
|
||||||
|
return [completeButton];
|
||||||
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
execCommand() {},
|
execCommand() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const location = {
|
|
||||||
href: 'https://auth.openai.com/u/signup/profile',
|
|
||||||
};
|
|
||||||
|
|
||||||
function Event(type, init = {}) {
|
function Event(type, init = {}) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.bubbles = Boolean(init.bubbles);
|
this.bubbles = Boolean(init.bubbles);
|
||||||
@@ -130,10 +157,8 @@ function log(message, level = 'info') {
|
|||||||
logs.push({ message, level });
|
logs.push({ message, level });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitForElement() {
|
function throwIfStopped() {}
|
||||||
return nameInput;
|
async function waitForElement() { return nameInput; }
|
||||||
}
|
|
||||||
|
|
||||||
async function humanPause() {}
|
async function humanPause() {}
|
||||||
async function sleep() {}
|
async function sleep() {}
|
||||||
|
|
||||||
@@ -149,6 +174,14 @@ function isVisibleElement(el) {
|
|||||||
return Boolean(el) && !el.hidden;
|
return Boolean(el) && !el.hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isActionEnabled(el) {
|
||||||
|
return Boolean(el) && !el.disabled && el.getAttribute?.('aria-disabled') !== 'true';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActionText(el) {
|
||||||
|
return el.textContent || '';
|
||||||
|
}
|
||||||
|
|
||||||
async function setReactAriaBirthdaySelect(select, value) {
|
async function setReactAriaBirthdaySelect(select, value) {
|
||||||
selectedBirthday[select.label] = String(value).padStart(select.label === '年' ? 4 : 2, '0');
|
selectedBirthday[select.label] = String(value).padStart(select.label === '年' ? 4 : 2, '0');
|
||||||
if (selectedBirthday['年'] && selectedBirthday['月'] && selectedBirthday['天']) {
|
if (selectedBirthday['年'] && selectedBirthday['月'] && selectedBirthday['天']) {
|
||||||
@@ -162,17 +195,30 @@ async function waitForElementByText() {
|
|||||||
|
|
||||||
function simulateClick(el) {
|
function simulateClick(el) {
|
||||||
clicks.push(el.textContent || el.tagName || 'element');
|
clicks.push(el.textContent || el.tagName || 'element');
|
||||||
|
if (el === completeButton) {
|
||||||
|
location.href = 'https://chatgpt.com/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reportComplete(step, payload) {
|
function reportComplete(step, payload) {
|
||||||
completions.push({ step, payload });
|
completions.push({ step, payload });
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeInlineText(text) {
|
function normalizeInlineText(text) {
|
||||||
return String(text || '').replace(/\\s+/g, ' ').trim();
|
return String(text || '').replace(/\\s+/g, ' ').trim();
|
||||||
}
|
}
|
||||||
|
function getSignupAuthRetryPathPatterns() { return []; }
|
||||||
|
function getAuthTimeoutErrorPageState() { return null; }
|
||||||
|
async function recoverCurrentAuthRetryPage() { throw new Error('should not recover retry page'); }
|
||||||
|
function createSignupUserAlreadyExistsError() { return new Error('user already exists'); }
|
||||||
|
function createAuthMaxCheckAttemptsError() { return new Error('max_check_attempts'); }
|
||||||
|
function getStep5ErrorText() { return ''; }
|
||||||
|
function isStep5Ready() { return /^https:\\/\\/auth\\.openai\\.com\\//.test(location.href); }
|
||||||
|
function isLikelyLoggedInChatgptHomeUrl() { return /^https:\\/\\/chatgpt\\.com\\//.test(location.href); }
|
||||||
|
function isOAuthConsentPage() { return false; }
|
||||||
|
function isAddPhonePageReady() { return false; }
|
||||||
|
|
||||||
${getStep5Bundle()}
|
${getStep5Bundle()}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async run(payload) {
|
async run(payload) {
|
||||||
@@ -199,20 +245,20 @@ return {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const snapshot = api.snapshot();
|
const snapshot = api.snapshot();
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(result, {
|
||||||
result,
|
profileSubmitted: true,
|
||||||
{
|
postSubmitChecked: true,
|
||||||
skippedPostSubmitCheck: true,
|
outcome: 'logged_in_home',
|
||||||
directProceedToStep6: true,
|
url: 'https://chatgpt.com/',
|
||||||
},
|
});
|
||||||
'生日模式点击提交后应直接返回完成载荷'
|
|
||||||
);
|
|
||||||
assert.deepStrictEqual(snapshot.completions, [
|
assert.deepStrictEqual(snapshot.completions, [
|
||||||
{
|
{
|
||||||
step: 5,
|
step: 5,
|
||||||
payload: {
|
payload: {
|
||||||
skippedPostSubmitCheck: true,
|
profileSubmitted: true,
|
||||||
directProceedToStep6: true,
|
postSubmitChecked: true,
|
||||||
|
outcome: 'logged_in_home',
|
||||||
|
url: 'https://chatgpt.com/',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -220,7 +266,185 @@ return {
|
|||||||
assert.equal(snapshot.nameValue, 'Test User');
|
assert.equal(snapshot.nameValue, 'Test User');
|
||||||
assert.equal(snapshot.birthdayValue, '2003-06-19');
|
assert.equal(snapshot.birthdayValue, '2003-06-19');
|
||||||
assert.ok(
|
assert.ok(
|
||||||
snapshot.logs.some(({ message }) => /不再等待页面结果/.test(message)),
|
snapshot.logs.some(({ message }) => /资料提交结果已确认/.test(message)),
|
||||||
'日志应明确说明 Step 5 已直接完成'
|
'日志应明确说明 Step 5 已完成提交后检测'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('step 5 retries submit while profile page remains visible', async () => {
|
||||||
|
const api = new Function(`
|
||||||
|
const realDateNow = Date.now;
|
||||||
|
let now = 0;
|
||||||
|
const logs = [];
|
||||||
|
const completions = [];
|
||||||
|
const clicks = [];
|
||||||
|
const nameInput = { value: '', hidden: false };
|
||||||
|
const ageInput = { value: '', hidden: false };
|
||||||
|
const completeButton = {
|
||||||
|
tagName: 'BUTTON',
|
||||||
|
textContent: '完成帐户创建',
|
||||||
|
hidden: false,
|
||||||
|
getAttribute() { return ''; },
|
||||||
|
};
|
||||||
|
const location = {
|
||||||
|
href: 'https://auth.openai.com/u/signup/profile',
|
||||||
|
};
|
||||||
|
const document = {
|
||||||
|
querySelector(selector) {
|
||||||
|
switch (selector) {
|
||||||
|
case '[role="spinbutton"][data-type="year"]':
|
||||||
|
case '[role="spinbutton"][data-type="month"]':
|
||||||
|
case '[role="spinbutton"][data-type="day"]':
|
||||||
|
case 'input[name="birthday"]':
|
||||||
|
return null;
|
||||||
|
case 'input[name="age"]':
|
||||||
|
return /^https:\\/\\/auth\\.openai\\.com\\//.test(location.href) ? ageInput : null;
|
||||||
|
case 'button[type="submit"], input[type="submit"]':
|
||||||
|
case 'button[type="submit"]':
|
||||||
|
return completeButton;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
querySelectorAll(selector) {
|
||||||
|
if (selector === 'input[name="allCheckboxes"][type="checkbox"]') return [];
|
||||||
|
if (selector === 'input[type="checkbox"]') return [];
|
||||||
|
if (selector === 'button, [role="button"], input[type="button"], input[type="submit"]') return [completeButton];
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
execCommand() {},
|
||||||
|
};
|
||||||
|
|
||||||
|
Date.now = () => now;
|
||||||
|
function log(message, level = 'info') { logs.push({ message, level }); }
|
||||||
|
function throwIfStopped() {}
|
||||||
|
async function waitForElement() { return nameInput; }
|
||||||
|
async function humanPause() {}
|
||||||
|
async function sleep(ms = 0) { now += ms || 250; }
|
||||||
|
function fillInput(input, value) { input.value = value; }
|
||||||
|
function findBirthdayReactAriaSelect() { return null; }
|
||||||
|
function isVisibleElement(el) { return Boolean(el) && !el.hidden; }
|
||||||
|
function isActionEnabled(el) { return Boolean(el) && !el.disabled && el.getAttribute?.('aria-disabled') !== 'true'; }
|
||||||
|
function getActionText(el) { return el.textContent || ''; }
|
||||||
|
async function setReactAriaBirthdaySelect() { throw new Error('setReactAriaBirthdaySelect should not run'); }
|
||||||
|
async function waitForElementByText() { return completeButton; }
|
||||||
|
function simulateClick(el) {
|
||||||
|
clicks.push(el.textContent || el.tagName || 'element');
|
||||||
|
if (el === completeButton && clicks.filter((text) => text === '完成帐户创建').length >= 3) {
|
||||||
|
location.href = 'https://chatgpt.com/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function reportComplete(step, payload) { completions.push({ step, payload }); }
|
||||||
|
function normalizeInlineText(text) { return String(text || '').replace(/\\s+/g, ' ').trim(); }
|
||||||
|
function getSignupAuthRetryPathPatterns() { return []; }
|
||||||
|
function getAuthTimeoutErrorPageState() { return null; }
|
||||||
|
async function recoverCurrentAuthRetryPage() { throw new Error('should not recover retry page'); }
|
||||||
|
function createSignupUserAlreadyExistsError() { return new Error('user already exists'); }
|
||||||
|
function createAuthMaxCheckAttemptsError() { return new Error('max_check_attempts'); }
|
||||||
|
function getStep5ErrorText() { return ''; }
|
||||||
|
function isStep5Ready() { return /^https:\\/\\/auth\\.openai\\.com\\//.test(location.href); }
|
||||||
|
function isLikelyLoggedInChatgptHomeUrl() { return /^https:\\/\\/chatgpt\\.com\\//.test(location.href); }
|
||||||
|
function isOAuthConsentPage() { return false; }
|
||||||
|
function isAddPhonePageReady() { return false; }
|
||||||
|
|
||||||
|
${getStep5Bundle()}
|
||||||
|
|
||||||
|
return {
|
||||||
|
run() {
|
||||||
|
return step5_fillNameBirthday({
|
||||||
|
firstName: 'Mia',
|
||||||
|
lastName: 'Harris',
|
||||||
|
age: 19,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
snapshot() {
|
||||||
|
return { logs, completions, clicks, nameValue: nameInput.value, ageValue: ageInput.value };
|
||||||
|
},
|
||||||
|
restore() {
|
||||||
|
Date.now = realDateNow;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
`)();
|
||||||
|
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = await api.run();
|
||||||
|
} finally {
|
||||||
|
api.restore();
|
||||||
|
}
|
||||||
|
const snapshot = api.snapshot();
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, {
|
||||||
|
profileSubmitted: true,
|
||||||
|
postSubmitChecked: true,
|
||||||
|
ageMode: true,
|
||||||
|
outcome: 'logged_in_home',
|
||||||
|
url: 'https://chatgpt.com/',
|
||||||
|
});
|
||||||
|
assert.equal(snapshot.nameValue, 'Mia Harris');
|
||||||
|
assert.equal(snapshot.ageValue, '19');
|
||||||
|
assert.equal(snapshot.clicks.filter((text) => text === '完成帐户创建').length, 3);
|
||||||
|
assert.equal(snapshot.logs.some(({ message }) => /仍停留在资料页,正在重新点击/.test(message)), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('step 5 recovers auth retry page after profile submit', async () => {
|
||||||
|
const api = new Function(`
|
||||||
|
let retryVisible = true;
|
||||||
|
let recoverCalls = 0;
|
||||||
|
const location = { href: 'https://auth.openai.com/create-account/profile' };
|
||||||
|
const document = {
|
||||||
|
querySelector() { return null; },
|
||||||
|
querySelectorAll() { return []; },
|
||||||
|
};
|
||||||
|
|
||||||
|
function throwIfStopped() {}
|
||||||
|
function log() {}
|
||||||
|
async function sleep() {}
|
||||||
|
async function humanPause() {}
|
||||||
|
function simulateClick() {}
|
||||||
|
function isVisibleElement() { return true; }
|
||||||
|
function isActionEnabled() { return true; }
|
||||||
|
function getActionText(el) { return el?.textContent || ''; }
|
||||||
|
function getSignupAuthRetryPathPatterns() { return []; }
|
||||||
|
function getAuthTimeoutErrorPageState() {
|
||||||
|
if (!retryVisible) return null;
|
||||||
|
return {
|
||||||
|
retryEnabled: true,
|
||||||
|
userAlreadyExistsBlocked: false,
|
||||||
|
maxCheckAttemptsBlocked: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async function recoverCurrentAuthRetryPage() {
|
||||||
|
recoverCalls += 1;
|
||||||
|
retryVisible = false;
|
||||||
|
location.href = 'https://chatgpt.com/';
|
||||||
|
}
|
||||||
|
function createSignupUserAlreadyExistsError() { return new Error('user already exists'); }
|
||||||
|
function createAuthMaxCheckAttemptsError() { return new Error('max_check_attempts'); }
|
||||||
|
function getStep5ErrorText() { return ''; }
|
||||||
|
function isStep5Ready() { return /^https:\\/\\/auth\\.openai\\.com\\//.test(location.href); }
|
||||||
|
function isLikelyLoggedInChatgptHomeUrl() { return /^https:\\/\\/chatgpt\\.com\\//.test(location.href); }
|
||||||
|
function isOAuthConsentPage() { return false; }
|
||||||
|
function isAddPhonePageReady() { return false; }
|
||||||
|
|
||||||
|
${extractFunction('isSignupProfilePageUrl')}
|
||||||
|
${getStep5OutcomeBundle()}
|
||||||
|
|
||||||
|
return {
|
||||||
|
run() {
|
||||||
|
return waitForStep5SubmitOutcome({ timeoutMs: 1000 });
|
||||||
|
},
|
||||||
|
snapshot() {
|
||||||
|
return { recoverCalls };
|
||||||
|
},
|
||||||
|
};
|
||||||
|
`)();
|
||||||
|
|
||||||
|
const result = await api.run();
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, {
|
||||||
|
state: 'logged_in_home',
|
||||||
|
url: 'https://chatgpt.com/',
|
||||||
|
});
|
||||||
|
assert.equal(api.snapshot().recoverCalls, 1);
|
||||||
|
});
|
||||||
|
|||||||
@@ -448,7 +448,12 @@ test('verification flow keeps step 8 successful when code submit transport fails
|
|||||||
pollCloudflareTempEmailVerificationCode: async () => ({}),
|
pollCloudflareTempEmailVerificationCode: async () => ({}),
|
||||||
pollHotmailVerificationCode: async () => ({}),
|
pollHotmailVerificationCode: async () => ({}),
|
||||||
pollLuckmailVerificationCode: async () => ({}),
|
pollLuckmailVerificationCode: async () => ({}),
|
||||||
sendToContentScript: async () => ({}),
|
sendToContentScript: async (_source, message) => {
|
||||||
|
if (message.type === 'FILL_CODE') {
|
||||||
|
throw new Error('message channel is closed before a response was received');
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
sendToContentScriptResilient: async (_source, message) => {
|
sendToContentScriptResilient: async (_source, message) => {
|
||||||
if (message.type === 'FILL_CODE') {
|
if (message.type === 'FILL_CODE') {
|
||||||
throw new Error('message channel is closed before a response was received');
|
throw new Error('message channel is closed before a response was received');
|
||||||
@@ -1282,6 +1287,151 @@ test('verification flow uses resilient signup-page transport when submitting ver
|
|||||||
assert.ok(resilientCalls[0].options.timeoutMs >= 30000);
|
assert.ok(resilientCalls[0].options.timeoutMs >= 30000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('verification flow does not replay step 8 code submit after transient auth-page transport failure', async () => {
|
||||||
|
const directMessages = [];
|
||||||
|
const resilientMessages = [];
|
||||||
|
|
||||||
|
const helpers = api.createVerificationFlowHelpers({
|
||||||
|
addLog: async () => {},
|
||||||
|
chrome: {
|
||||||
|
tabs: {
|
||||||
|
update: async () => {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
|
||||||
|
completeStepFromBackground: async () => {},
|
||||||
|
confirmCustomVerificationStepBypassRequest: async () => ({ confirmed: true }),
|
||||||
|
getHotmailVerificationPollConfig: () => ({}),
|
||||||
|
getHotmailVerificationRequestTimestamp: () => 0,
|
||||||
|
getState: async () => ({}),
|
||||||
|
getTabId: async () => 1,
|
||||||
|
HOTMAIL_PROVIDER: 'hotmail-api',
|
||||||
|
isRetryableContentScriptTransportError: (error) => /did not respond/i.test(String(error?.message || error || '')),
|
||||||
|
isStopError: () => false,
|
||||||
|
LUCKMAIL_PROVIDER: 'luckmail-api',
|
||||||
|
MAIL_2925_VERIFICATION_INTERVAL_MS: 15000,
|
||||||
|
MAIL_2925_VERIFICATION_MAX_ATTEMPTS: 15,
|
||||||
|
pollCloudflareTempEmailVerificationCode: async () => ({}),
|
||||||
|
pollHotmailVerificationCode: async () => ({}),
|
||||||
|
pollLuckmailVerificationCode: async () => ({}),
|
||||||
|
sendToContentScript: async (_source, message) => {
|
||||||
|
directMessages.push(message.type);
|
||||||
|
if (message.type === 'FILL_CODE') {
|
||||||
|
throw new Error('步骤 8:页面通信异常 did not respond in 30s');
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
sendToContentScriptResilient: async (_source, message) => {
|
||||||
|
resilientMessages.push(message.type);
|
||||||
|
if (message.type === 'GET_LOGIN_AUTH_STATE') {
|
||||||
|
return {
|
||||||
|
state: 'verification_page',
|
||||||
|
verificationErrorText: '代码不正确',
|
||||||
|
url: 'https://auth.openai.com/email-verification',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
throw new Error('FILL_CODE should not be replayed through resilient transport');
|
||||||
|
},
|
||||||
|
sendToMailContentScriptResilient: async () => ({}),
|
||||||
|
setState: async () => {},
|
||||||
|
setStepStatus: async () => {},
|
||||||
|
sleepWithStop: async () => {},
|
||||||
|
throwIfStopped: () => {},
|
||||||
|
VERIFICATION_POLL_MAX_ROUNDS: 5,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await helpers.submitVerificationCode(8, '510725', { completionStep: 11 });
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, {
|
||||||
|
invalidCode: true,
|
||||||
|
errorText: '代码不正确',
|
||||||
|
url: 'https://auth.openai.com/email-verification',
|
||||||
|
});
|
||||||
|
assert.deepStrictEqual(directMessages, ['FILL_CODE']);
|
||||||
|
assert.deepStrictEqual(resilientMessages, ['GET_LOGIN_AUTH_STATE']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('verification flow requests a new code immediately after Cloudflare Temp Email code is rejected', async () => {
|
||||||
|
const events = [];
|
||||||
|
const pollPayloads = [];
|
||||||
|
const completed = [];
|
||||||
|
|
||||||
|
const helpers = api.createVerificationFlowHelpers({
|
||||||
|
addLog: async () => {},
|
||||||
|
chrome: {
|
||||||
|
tabs: {
|
||||||
|
update: async () => {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
|
||||||
|
completeStepFromBackground: async (_step, payload) => {
|
||||||
|
completed.push(payload);
|
||||||
|
},
|
||||||
|
confirmCustomVerificationStepBypassRequest: async () => ({ confirmed: true }),
|
||||||
|
getHotmailVerificationPollConfig: () => ({}),
|
||||||
|
getHotmailVerificationRequestTimestamp: () => 0,
|
||||||
|
getState: async () => ({}),
|
||||||
|
getTabId: async () => 1,
|
||||||
|
HOTMAIL_PROVIDER: 'hotmail-api',
|
||||||
|
isStopError: () => false,
|
||||||
|
LUCKMAIL_PROVIDER: 'luckmail-api',
|
||||||
|
MAIL_2925_VERIFICATION_INTERVAL_MS: 15000,
|
||||||
|
MAIL_2925_VERIFICATION_MAX_ATTEMPTS: 15,
|
||||||
|
pollCloudflareTempEmailVerificationCode: async (_step, _state, payload) => {
|
||||||
|
pollPayloads.push(payload);
|
||||||
|
const code = pollPayloads.length === 1 ? '111111' : '222222';
|
||||||
|
events.push(['poll', code]);
|
||||||
|
return { code, emailTimestamp: pollPayloads.length };
|
||||||
|
},
|
||||||
|
pollHotmailVerificationCode: async () => ({}),
|
||||||
|
pollLuckmailVerificationCode: async () => ({}),
|
||||||
|
sendToContentScript: async (_source, message) => {
|
||||||
|
if (message.type === 'RESEND_VERIFICATION_CODE') {
|
||||||
|
events.push(['resend', message.step]);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (message.type === 'FILL_CODE') {
|
||||||
|
events.push(['submit', message.payload.code]);
|
||||||
|
return message.payload.code === '111111'
|
||||||
|
? { invalidCode: true, errorText: '代码不正确' }
|
||||||
|
: { success: true };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
sendToMailContentScriptResilient: async () => ({}),
|
||||||
|
setState: async () => {},
|
||||||
|
setStepStatus: async () => {},
|
||||||
|
sleepWithStop: async () => {},
|
||||||
|
throwIfStopped: () => {},
|
||||||
|
VERIFICATION_POLL_MAX_ROUNDS: 5,
|
||||||
|
});
|
||||||
|
|
||||||
|
await helpers.resolveVerificationStep(
|
||||||
|
8,
|
||||||
|
{
|
||||||
|
email: 'user@example.com',
|
||||||
|
loginVerificationRequestedAt: Date.now(),
|
||||||
|
verificationResendCount: 1,
|
||||||
|
},
|
||||||
|
{ provider: 'cloudflare-temp-email', label: 'Cloudflare Temp Email' },
|
||||||
|
{
|
||||||
|
completionStep: 11,
|
||||||
|
lastResendAt: Date.now(),
|
||||||
|
resendIntervalMs: 25000,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(events, [
|
||||||
|
['poll', '111111'],
|
||||||
|
['submit', '111111'],
|
||||||
|
['resend', 8],
|
||||||
|
['poll', '222222'],
|
||||||
|
['submit', '222222'],
|
||||||
|
]);
|
||||||
|
assert.deepStrictEqual(pollPayloads[1].excludeCodes, ['111111']);
|
||||||
|
assert.equal(completed[0].code, '222222');
|
||||||
|
});
|
||||||
|
|
||||||
test('verification flow forwards optional signup profile payload when submitting signup verification code', async () => {
|
test('verification flow forwards optional signup profile payload when submitting signup verification code', async () => {
|
||||||
const resilientCalls = [];
|
const resilientCalls = [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user