Skip to content

Chrome DevTools for coding agents

fix: accidental extra typing in the fill tool (#886)

Alex Rudenko3d6e59dda42b
diff --git a/src/tools/input.ts b/src/tools/input.ts
index 381b1985..cd8b2f4d 100644
--- a/src/tools/input.ts
+++ b/src/tools/input.ts
@@ -220,7 +220,6 @@ export const fill = defineTool({
},
handler: async (request, response, context) => {
await context.waitForEventsAfterAction(async () => {
- await context.getSelectedPage().keyboard.type(request.params.value);
await fillFormElement(
request.params.uid,
request.params.value,
diff --git a/tests/tools/input.test.ts b/tests/tools/input.test.ts
index 316c8d76..06a75214 100644
--- a/tests/tools/input.test.ts
+++ b/tests/tools/input.test.ts
@@ -9,6 +9,7 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import {describe, it} from 'node:test';
+import {McpResponse} from '../../src/McpResponse.js';
import {
click,
hover,
@@ -382,6 +383,79 @@ describe('input', () => {
);
});
});
+
+ it('reproduction: fill isolation', async () => {
+ await withMcpContext(async (_response, context) => {
+ const page = context.getSelectedPage();
+ await page.setContent(
+ html`<form>
+ <input
+ id="email"
+ />
+ <input
+ id="password"
+ type="password"
+ />
+ </form>`,
+ );
+ await context.createTextSnapshot();
+
+ // Fill email
+ const response1 = new McpResponse();
+ await fill.handler(
+ {
+ params: {
+ uid: '1_1', // email input
+ value: '[email protected]',
+ },
+ },
+ response1,
+ context,
+ );
+ assert.strictEqual(
+ response1.responseLines[0],
+ 'Successfully filled out the element',
+ );
+
+ // Fill password
+ const response2 = new McpResponse();
+ await fill.handler(
+ {
+ params: {
+ uid: '1_2', // password input
+ value: 'secret',
+ },
+ },
+ response2,
+ context,
+ );
+ assert.strictEqual(
+ response2.responseLines[0],
+ 'Successfully filled out the element',
+ );
+
+ // Verify values
+ const values = await page.evaluate(() => {
+ return {
+ email: (document.getElementById('email') as HTMLInputElement).value,
+ password: (document.getElementById('password') as HTMLInputElement)
+ .value,
+ };
+ });
+
+ assert.strictEqual(
+ values.email,
+ 'Email should be updated correctly',
+ );
+ assert.strictEqual(
+ values.password,
+ 'secret',
+ 'Password should be updated correctly',
+ );
+ });
+ });
});
describe('drags', () => {