with a listener: its pointer
+ // cursor marks it, for repeated clicks and for drags inside it.
+ assert.deepEqual(await one(720, 120), { found: true, tag: 'div', clickable: true, opaqueFrame: false, control: 'clickable element' });
+ assert.equal((await pair({ x: 710, y: 110 }, { x: 890, y: 150 })).clickEquivalent, true);
+ // ...but a handle or draggable item under a pointer cursor still drags.
+ assert.equal((await pair({ x: 715, y: 215 }, { x: 900, y: 215 })).clickEquivalent, false, 'a knob with a grab cursor');
+ assert.equal((await pair({ x: 720, y: 280 }, { x: 720, y: 320 })).clickEquivalent, false, 'draggable list items');
+ } finally {
+ await browser.close();
+ }
+});
+
+test('vision input (Firefox path) and the DOM probe place points inside scaled same-origin frames, and refuse frames they cannot enter', async () => {
+ const browser = await chromium.launch({ channel: 'chromium' });
+ try {
+ const page = await browser.newPage({ viewport: { width: 1000, height: 700 } });
+ // Each frame holds a button at its own (200,100)-(300,140) and a track at
+ // (0,180)-(400,220) whose document logs the press, the moves and the release.
+ const inner = (left = 200, top = 100) => `
+ `;
+ const browser = await chromium.launch({ channel: 'chromium' });
+ try {
+ const page = await browser.newPage({ viewport: { width: 800, height: 400 } });
+ await page.setContent(page_);
+ for (const build of ['chrome', 'firefox']) {
+ const { Agent } = await import(`../src/${build}/src/agent/agent.js`);
+ const probe = args => page.evaluate(({ source, args }) => {
+ const fn = new Function(`return (${source})`)();
+ return fn('click', args);
+ }, { source: Agent._submitActionProbe.toString(), args });
+ // Plain content under a vision point: a non-submit target.
+ const plain = await probe({ x: 120, y: 50, coordinate_space: 'css', __wbCaptionPass: 'final', __wbCaptionReadings: {} });
+ assert.equal(plain?.resolvedPlainContent, true, `${build}: ${JSON.stringify(plain)}`);
+ assert.equal(plain.isSubmit, false);
+ // The same point from a coordinate click outside a vision run is not classified.
+ assert.equal((await probe({ x: 120, y: 50, __wbCaptionPass: 'final', __wbCaptionReadings: {} }))?.resolvedPlainContent, undefined);
+ // A control is never plain content.
+ assert.notEqual((await probe({ x: 560, y: 40, coordinate_space: 'css', __wbCaptionPass: 'final', __wbCaptionReadings: {} }))?.resolvedPlainContent, true);
+ // A frame is opaque to the top document's probe, never plain content.
+ assert.notEqual((await probe({ x: 600, y: 260, coordinate_space: 'css', __wbCaptionPass: 'final', __wbCaptionReadings: {} }))?.resolvedPlainContent, true);
+ // Text inside a web component whose host is the button is that button.
+ assert.notEqual((await probe({ x: 560, y: 140, coordinate_space: 'css', __wbCaptionPass: 'final', __wbCaptionReadings: {} }))?.resolvedPlainContent, true);
+ // The submit button inside the web component is the submit, not its host.
+ const pay = await probe({ x: 90, y: 230, coordinate_space: 'css', __wbCaptionPass: 'final', __wbCaptionReadings: {} });
+ assert.equal(pay?.isSubmit, true, `${build}: ${JSON.stringify(pay)?.slice(0, 400)}`);
+ }
+ } finally {
+ await browser.close();
+ }
+});