Skip to content

Chrome DevTools for coding agents

fix: expose timeout when Emulation is enabled (#73)

Nikolay Vitkov0208bfdcf692
diff --git a/package.json b/package.json
index 21081352..6919d750 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
},
"main": "index.js",
"scripts": {
- "build": "tsc && node --experimental-strip-types scripts/post-build.ts",
+ "build": "tsc && node --experimental-strip-types --no-warnings=ExperimentalWarning scripts/post-build.ts",
"typecheck": "tsc --noEmit",
"format": "eslint --cache --fix . && prettier --write --cache .",
"check-format": "eslint --cache . && prettier --check --cache .;",
@@ -16,10 +16,10 @@
"docs:generate": "node --experimental-strip-types scripts/generate-docs.ts",
"start": "npm run build && node build/src/index.js",
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
- "test": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
- "test:only": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
- "test:only:no-build": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
- "test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"",
+ "test": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
+ "test:only": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
+ "test:only:no-build": "node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
+ "test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"",
"prepare": "node --experimental-strip-types scripts/prepare.ts"
},
"files": [
diff --git a/src/McpContext.ts b/src/McpContext.ts
index 77b2f25a..69143a18 100644
--- a/src/McpContext.ts
+++ b/src/McpContext.ts
@@ -243,6 +243,11 @@ export class McpContext implements Context {
page.setDefaultNavigationTimeout(NAVIGATION_TIMEOUT * networkMultiplier);
}
+ getNavigationTimeout() {
+ const page = this.getSelectedPage();
+ return page.getDefaultNavigationTimeout();
+ }
+
async getElementByUid(uid: string): Promise<ElementHandle<Element>> {
if (!this.#textSnapshot?.idToNode.size) {
throw new Error('No snapshot found. Use browser_snapshot to capture one');
diff --git a/src/McpResponse.ts b/src/McpResponse.ts
index 278b3401..63a2e155 100644
--- a/src/McpResponse.ts
+++ b/src/McpResponse.ts
@@ -117,6 +117,9 @@ export class McpResponse implements Response {
if (networkConditions) {
response.push(`## Network emulation`);
response.push(`Emulating: ${networkConditions}`);
+ response.push(
+ `Navigation timeout set to ${context.getNavigationTimeout()} ms`,
+ );
}
const cpuThrottlingRate = context.getCpuThrottlingRate();
diff --git a/tests/McpResponse.test.ts b/tests/McpResponse.test.ts
index 8cb48fc4..e4fcdc6b 100644
--- a/tests/McpResponse.test.ts
+++ b/tests/McpResponse.test.ts
@@ -104,7 +104,8 @@ uid=1_0 RootWebArea "My test page"
result[0].text,
`# test response
## Network emulation
-Emulating: Slow 3G`,
+Emulating: Slow 3G
+Navigation timeout set to 100000 ms`,
);
});
});