@@ -4752,7 +4752,7 @@ test('CAPTCHA dialog parsing handles descendant-only labels and escaped quotes',
47524752 }
47534753});
47544754
4755- test('CAPTCHA mutation preflight ignores hidden and off-viewport verification dialogs ', async () => {
4755+ test('CAPTCHA preflight ignores hidden dialogs while ambiguous all-tree reads fail closed ', async () => {
47564756 for (const [build, gate, AgentClass] of [
47574757 ['chrome', CaptchaGateCh, AgentCh],
47584758 ['firefox', CaptchaGateFx, AgentFx],
@@ -4787,8 +4787,15 @@ test('CAPTCHA mutation preflight ignores hidden and off-viewport verification di
47874787 },
47884788 {},
47894789 );
4790- assert.equal(observation.gate, null, `${build}: hidden dialog from an all-tree read armed the gate`);
4791- assert.equal(agent._captchaGateStates.has(1), false, `${build}: hidden all-tree dialog persisted a gate`);
4790+ assert.ok(
4791+ observation.gate,
4792+ `${build}: ambiguous all-tree challenge was cleared by non-unique hidden evidence`,
4793+ );
4794+ assert.equal(
4795+ agent._captchaGateStates.has(1),
4796+ true,
4797+ `${build}: ambiguous all-tree challenge failed open`,
4798+ );
47924799 });
47934800 }
47944801 await withCaptchaFakePage(build, [
@@ -4918,8 +4925,8 @@ test('CAPTCHA visibility recheck sees shadow-rooted dialogs and keeps the gate o
49184925 assert.ok(observation.gate, `${build}: unrelated hidden challenge cleared the tree-only CAPTCHA gate`);
49194926 assert.equal(agent._captchaGateStates.has(1), true, `${build}: unrelated hidden challenge failed open`);
49204927
4921- const matchingAgent = new AgentClass({});
4922- const matchingObservation = await matchingAgent ._observeCaptchaChallenge(
4928+ const sameLabelAgent = new AgentClass({});
4929+ const sameLabelObservation = await sameLabelAgent ._observeCaptchaChallenge(
49234930 1,
49244931 'get_accessibility_tree',
49254932 {
@@ -4928,15 +4935,14 @@ test('CAPTCHA visibility recheck sees shadow-rooted dialogs and keeps the gate o
49284935 },
49294936 {},
49304937 );
4931- assert.equal(
4932- matchingObservation.gate,
4933- null,
4934- `${build}: matching hidden evidence did not clear the tree observation`,
4938+ assert.ok(
4939+ sameLabelObservation.gate,
4940+ `${build}: same-label hidden template cleared the tree-only CAPTCHA gate`,
49354941 );
49364942 assert.equal(
4937- matchingAgent ._captchaGateStates.has(1),
4938- false ,
4939- `${build}: matching hidden evidence persisted a stale gate `,
4943+ sameLabelAgent ._captchaGateStates.has(1),
4944+ true ,
4945+ `${build}: same-label hidden template failed open `,
49404946 );
49414947 });
49424948
0 commit comments