@@ -4713,18 +4713,37 @@ test('CAPTCHA dialog parsing handles descendant-only labels and escaped quotes',
47134713 {
47144714 tree: 'dialog [ref_1]\n heading "Security verification" [ref_2]\n button "Dismiss" [ref_3]',
47154715 label: 'Security verification',
4716+ normalized: /security verification/,
47164717 },
47174718 {
47184719 tree: String.raw`dialog "Complete \"Security verification\" now" [ref_4]`,
47194720 label: 'Complete "Security verification" now',
4721+ normalized: /security verification/,
4722+ },
4723+ {
4724+ tree: 'dialog "Verify that you\u2019re a human" [ref_5]',
4725+ label: 'Verify that you\u2019re a human',
4726+ normalized: /verify that you re a human/,
47204727 },
47214728 ];
47224729 for (const [build, gate] of [['chrome', CaptchaGateCh], ['firefox', CaptchaGateFx]]) {
47234730 for (const example of cases) {
47244731 const challenge = gate.detectChallengeDialog(example.tree);
47254732 assert.equal(challenge?.label, example.label, `${build}: failed to parse ${example.tree}`);
4726- assert.match(challenge?.normalizedLabel || '', /security verification/ , `${build}: normalized challenge label missing`);
4733+ assert.match(challenge?.normalizedLabel || '', example.normalized , `${build}: normalized challenge label missing`);
47274734 }
4735+ const genericFailure = 'dialog "Email verification failed" [ref_6]';
4736+ assert.equal(gate.detectChallengeDialog(genericFailure), null, `${build}: generic application verification failure armed a CAPTCHA gate`);
4737+ assert.equal(
4738+ gate.detectChallengeDialog(genericFailure, { allowGenericFailure: true })?.label,
4739+ 'Email verification failed',
4740+ `${build}: active CAPTCHA could not retain a renamed failure dialog`,
4741+ );
4742+ assert.equal(
4743+ gate.detectChallengeDialog('dialog "CAPTCHA verification failed" [ref_7]')?.label,
4744+ 'CAPTCHA verification failed',
4745+ `${build}: contextual CAPTCHA failure was missed`,
4746+ );
47284747 }
47294748});
47304749
@@ -4753,9 +4772,19 @@ test('CAPTCHA mutation preflight ignores hidden and off-viewport verification di
47534772 });
47544773 }
47554774 await withCaptchaFakePage(build, [
4756- captchaEl('div', { role: 'dialog', innerText: 'Security verification ' }),
4775+ captchaEl('div', { role: 'dialog', innerText: 'Verify you are a human ' }),
47574776 ], async () => {
4758- assert.equal(gate.detectChallengeDialogInPage()?.label, 'Security verification', `${build}: visible dialog was missed`);
4777+ assert.equal(gate.detectChallengeDialogInPage()?.label, 'Verify you are a human', `${build}: article-bearing challenge dialog was missed`);
4778+ });
4779+ await withCaptchaFakePage(build, [
4780+ captchaEl('div', { role: 'dialog', innerText: 'Email verification failed' }),
4781+ ], async () => {
4782+ assert.equal(gate.detectChallengeDialogInPage(), null, `${build}: generic application failure armed preflight`);
4783+ assert.equal(
4784+ gate.detectChallengeDialogInPage({ allowGenericFailure: true })?.label,
4785+ 'Email verification failed',
4786+ `${build}: active-gate failure context was ignored`,
4787+ );
47594788 });
47604789 }
47614790});
@@ -52543,9 +52572,9 @@ test('challenge-dialog routing detects supported widgets and diagnoses unsupport
5254352572 }),
5254452573 captchaEl('div', {
5254552574 role: 'dialog',
52546- innerText: 'Verify that you\u2019re human',
52575+ innerText: 'Verify that you\u2019re a human',
5254752576 }, [
52548- captchaEl('h2', { textContent: 'Verify that you\u2019re human' }),
52577+ captchaEl('h2', { textContent: 'Verify that you\u2019re a human' }),
5254952578 captchaEl('div', {
5255052579 class: 'g-recaptcha g-recaptcha-v3',
5255152580 'data-sitekey': 'DIALOG_V3_KEY',
@@ -52562,7 +52591,7 @@ test('challenge-dialog routing detects supported widgets and diagnoses unsupport
5256252591 agent.captchaSolverEnabled = true;
5256352592 agent._currentUrl = async () => 'https://example.test/signup';
5256452593 const observed = await agent._observeCaptchaChallenge(1, 'get_accessibility_tree', {
52565- pageContent: 'dialog "Verify that you\u2019re human" [ref_150]\n button "Dismiss" [ref_151]',
52594+ pageContent: 'dialog "Verify that you\u2019re a human" [ref_150]\n button "Dismiss" [ref_151]',
5256652595 });
5256752596 assert.equal(observed.gate?.status, 'solve_required', `${build}: invisible v3 widget inside the active dialog was not routable`);
5256852597 assert.equal(observed.gate?.selectedType, 'recaptcha_v3_enterprise', `${build}: dialog-associated v3 type was lost`);
0 commit comments