Chrome DevTools for coding agents
fix(pages): reject devtools:// URLs in navigate_page and new_page (#2935) (#3128)
Yuri (IURII) Trukhinc94c03deda1e
diff --git a/src/utils/url.ts b/src/utils/url.tsindex 2506df1c..836a7e55 100644--- a/src/utils/url.ts+++ b/src/utils/url.ts@@ -264,6 +264,10 @@ export function validateUrl(url: string, options: ValidateUrlOptions): URL {);}+ if (parsed.protocol === 'devtools:') {+ throw new Error(`Navigating to devtools: URLs is not allowed.`);+ }+if (!isAllowedUrl(url, {categoryExtensions})) {if (parsed.protocol === 'chrome-extension:') {throw new Error(diff --git a/tests/utils/url.test.ts b/tests/utils/url.test.tsindex bc5fb87c..57a5c2c7 100644--- a/tests/utils/url.test.ts+++ b/tests/utils/url.test.ts@@ -318,6 +318,17 @@ describe('validateUrl', () => {);});+ it('should reject devtools: URLs', () => {+ assert.throws(+ () =>+ validateUrl(+ 'devtools://devtools/bundled/devtools_app.html',+ defaultOptions,+ ),+ /Navigating to devtools: URLs is not allowed\./,+ );+ });+it('should allow file URLs when fileNavigations is true or omitted', () => {assert.strictEqual(validateUrl('file:///tmp/example.txt', defaultOptions).protocol,