Skip to content

Chrome DevTools for coding agents

fix: increase timeouts for long text input (#787)

Alex Rudenkoa83a33835148
diff --git a/scripts/test.mjs b/scripts/test.mjs
index 403bcd5d..5605156f 100644
--- a/scripts/test.mjs
+++ b/scripts/test.mjs
@@ -53,7 +53,7 @@ const nodeArgs = [
'spec',
'--test-force-exit',
'--test',
- '--test-timeout=30000',
+ '--test-timeout=60000',
...flags,
...files,
];
diff --git a/src/tools/input.ts b/src/tools/input.ts
index bfbcf6b6..46e68fcd 100644
--- a/src/tools/input.ts
+++ b/src/tools/input.ts
@@ -159,7 +159,12 @@ async function fillFormElement(
if (aXNode && aXNode.role === 'combobox') {
await selectOption(handle, aXNode, value);
} else {
- await handle.asLocator().fill(value);
+ // Increase timeout for longer input values.
+ const timeoutPerChar = 10; // ms
+ const fillTimeout =
+ context.getSelectedPage().getDefaultTimeout() +
+ value.length * timeoutPerChar;
+ await handle.asLocator().setTimeout(fillTimeout).fill(value);
}
} finally {
void handle.dispose();
@@ -183,6 +188,7 @@ 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 cb8ae711..0150671c 100644
--- a/tests/tools/input.test.ts
+++ b/tests/tools/input.test.ts
@@ -301,6 +301,38 @@ describe('input', () => {
assert.strictEqual(selectedValue, 'v2');
});
});
+
+ it('fills out a textarea with long text', async () => {
+ await withMcpContext(async (response, context) => {
+ const page = context.getSelectedPage();
+ await page.setContent(html`<textarea />`);
+ await page.focus('textarea');
+ await context.createTextSnapshot();
+ await page.setDefaultTimeout(1000);
+ await fill.handler(
+ {
+ params: {
+ uid: '1_1',
+ value: '1'.repeat(3000),
+ },
+ },
+ response,
+ context,
+ );
+ assert.strictEqual(
+ response.responseLines[0],
+ 'Successfully filled out the element',
+ );
+ assert.ok(response.includeSnapshot);
+ assert.ok(
+ await page.evaluate(() => {
+ return (
+ document.body.querySelector('textarea')?.value.length === 3_000
+ );
+ }),
+ );
+ });
+ });
});
describe('drags', () => {
diff --git a/tests/tools/performance.test.ts b/tests/tools/performance.test.ts
index b1fc2ad5..26e3d210 100644
--- a/tests/tools/performance.test.ts
+++ b/tests/tools/performance.test.ts
@@ -140,7 +140,7 @@ describe('performance', () => {
});
});
- it.only('supports filePath', async () => {
+ it('supports filePath', async () => {
const rawData = loadTraceAsBuffer('basic-trace.json.gz');
// rawData is the decompressed buffer (based on loadTraceAsBuffer implementation).
// We want to simulate saving it as a .gz file, so the tool should compress it.