豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 3d6e59d

Browse files
authored
fix: accidental extra typing in the fill tool (#886)
Fixes #881
1 parent 7e1ec81 commit 3d6e59d

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

src/tools/input.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ export const fill = defineTool({
220220
},
221221
handler: async (request, response, context) => {
222222
await context.waitForEventsAfterAction(async () => {
223-
await context.getSelectedPage().keyboard.type(request.params.value);
224223
await fillFormElement(
225224
request.params.uid,
226225
request.params.value,

tests/tools/input.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fs from 'node:fs/promises';
99
import path from 'node:path';
1010
import {describe, it} from 'node:test';
1111

12+
import {McpResponse} from '../../src/McpResponse.js';
1213
import {
1314
click,
1415
hover,
@@ -382,6 +383,79 @@ describe('input', () => {
382383
);
383384
});
384385
});
386+
387+
it('reproduction: fill isolation', async () => {
388+
await withMcpContext(async (_response, context) => {
389+
const page = context.getSelectedPage();
390+
await page.setContent(
391+
html`<form>
392+
<input
393+
id="email"
394+
value="user@test.com"
395+
/>
396+
<input
397+
id="password"
398+
type="password"
399+
/>
400+
</form>`,
401+
);
402+
await context.createTextSnapshot();
403+
404+
// Fill email
405+
const response1 = new McpResponse();
406+
await fill.handler(
407+
{
408+
params: {
409+
uid: '1_1', // email input
410+
value: 'new@test.com',
411+
},
412+
},
413+
response1,
414+
context,
415+
);
416+
assert.strictEqual(
417+
response1.responseLines[0],
418+
'Successfully filled out the element',
419+
);
420+
421+
// Fill password
422+
const response2 = new McpResponse();
423+
await fill.handler(
424+
{
425+
params: {
426+
uid: '1_2', // password input
427+
value: 'secret',
428+
},
429+
},
430+
response2,
431+
context,
432+
);
433+
assert.strictEqual(
434+
response2.responseLines[0],
435+
'Successfully filled out the element',
436+
);
437+
438+
// Verify values
439+
const values = await page.evaluate(() => {
440+
return {
441+
email: (document.getElementById('email') as HTMLInputElement).value,
442+
password: (document.getElementById('password') as HTMLInputElement)
443+
.value,
444+
};
445+
});
446+
447+
assert.strictEqual(
448+
values.email,
449+
'new@test.com',
450+
'Email should be updated correctly',
451+
);
452+
assert.strictEqual(
453+
values.password,
454+
'secret',
455+
'Password should be updated correctly',
456+
);
457+
});
458+
});
385459
});
386460

387461
describe('drags', () => {

0 commit comments

Comments
 (0)