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

Commit f34cffe

Browse files
committed
merge
2 parents 271909b + 59f6477 commit f34cffe

30 files changed

+2109
-1176
lines changed

.github/workflows/pre-release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ jobs:
2323
with:
2424
cache: npm
2525
node-version-file: '.nvmrc'
26+
registry-url: 'https://registry.npmjs.org'
27+
28+
# Ensure npm 11.5.1 or later is installed
29+
- name: Update npm
30+
run: npm install -g npm@latest
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Build and bundle
36+
run: npm run bundle
37+
env:
38+
NODE_ENV: 'production'
2639

2740
- name: Verify server.json
2841
run: npm run verify-server-json-version
42+
43+
- name: Verify npm package
44+
run: npm run verify-npm-package

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ The Chrome DevTools MCP server supports the following configuration option:
497497
If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.
498498
- **Type:** boolean
499499

500+
- **`--experimentalScreencast`/ `--experimental-screencast`**
501+
Exposes experimental screencast tools (requires ffmpeg). Install ffmpeg https://www.ffmpeg.org/download.html and ensure it is available in the MCP server PATH.
502+
- **Type:** boolean
503+
500504
- **`--chromeArg`/ `--chrome-arg`**
501505
Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.
502506
- **Type:** array

docs/tool-reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->
22

3-
# Chrome DevTools MCP Tool Reference (~6922 cl100k_base tokens)
3+
# Chrome DevTools MCP Tool Reference (~6980 cl100k_base tokens)
44

55
- **[Audits](#audits)** (1 tools)
66
- [`lighthouse_audit`](#lighthouse_audit)
@@ -188,6 +188,7 @@
188188

189189
- **url** (string) **(required)**: URL to load in a new page.
190190
- **background** (boolean) _(optional)_: Whether to open the page in the background without bringing it to the front. Default is false (foreground).
191+
- **isolatedContext** (string) _(optional)_: If specified, the page is created in an isolated browser context with the given name. Pages in the same browser context share cookies and storage. Pages in different browser contexts are fully isolated.
191192
- **timeout** (integer) _(optional)_: Maximum wait time in milliseconds. If set to 0, the default timeout will be used.
192193

193194
---

package-lock.json

Lines changed: 164 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"prepare": "node --experimental-strip-types scripts/prepare.ts",
2424
"verify-server-json-version": "node --experimental-strip-types scripts/verify-server-json-version.ts",
2525
"update-lighthouse": "node --experimental-strip-types scripts/update-lighthouse.ts",
26+
"verify-npm-package": "node scripts/verify-npm-package.mjs",
2627
"eval": "npm run build && CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=true node --experimental-strip-types scripts/eval_gemini.ts",
2728
"count-tokens": "node --experimental-strip-types scripts/count_tokens.ts"
2829
},
2930
"files": [
3031
"build/src",
31-
"build/node_modules",
3232
"LICENSE",
3333
"!*.tsbuildinfo"
3434
],
@@ -64,8 +64,8 @@
6464
"globals": "^17.0.0",
6565
"lighthouse": "13.0.2",
6666
"prettier": "^3.6.2",
67-
"puppeteer": "24.37.4",
68-
"rollup": "4.57.1",
67+
"puppeteer": "24.37.5",
68+
"rollup": "4.58.0",
6969
"rollup-plugin-cleanup": "^3.2.1",
7070
"rollup-plugin-license": "^3.6.0",
7171
"sinon": "^21.0.0",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import assert from 'node:assert';
8+
9+
import type {TestScenario} from '../eval_gemini.ts';
10+
11+
export const scenario: TestScenario = {
12+
prompt:
13+
'Create a new page <TEST_URL> in an isolated context called contextB. Take a screenshot there.',
14+
maxTurns: 3,
15+
htmlRoute: {
16+
path: '/test.html',
17+
htmlContent: `
18+
<h1>test</h1>
19+
`,
20+
},
21+
expectations: calls => {
22+
console.log(JSON.stringify(calls, null, 2));
23+
assert.strictEqual(calls.length, 2);
24+
assert.ok(calls[0].name === 'new_page', 'First call should be navigation');
25+
assert.deepStrictEqual(calls[0].args.isolatedContext, 'contextB');
26+
assert.ok(
27+
calls[1].name === 'take_screenshot',
28+
'Second call should be a screenshot',
29+
);
30+
},
31+
};

scripts/test.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ async function runTests(attempt) {
6868
env: {
6969
...process.env,
7070
CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS: true,
71+
CHROME_DEVTOOLS_MCP_CRASH_ON_UNCAUGHT: true,
7172
},
7273
});
7374

scripts/verify-npm-package.mjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import {execSync} from 'node:child_process';
8+
9+
// Checks that the select build files are present using `npm publish --dry-run`.
10+
function verifyPackageContents() {
11+
try {
12+
const output = execSync('npm publish --dry-run --json --silent', {
13+
encoding: 'utf8',
14+
});
15+
// skip non-JSON output from prepare.
16+
const data = JSON.parse(output.substring(output.indexOf('{')));
17+
const files = data.files.map(f => f.path);
18+
// Check some important files.
19+
const requiredPaths = [
20+
'build/src/index.js',
21+
'build/src/third_party/index.js',
22+
];
23+
for (const requiredPath of requiredPaths) {
24+
const hasBuildFolder = files.some(path => path.startsWith(requiredPath));
25+
if (!hasBuildFolder) {
26+
console.error(
27+
`Assertion Failed: "${requiredPath}" not found in tarball.`,
28+
);
29+
process.exit(1);
30+
}
31+
}
32+
console.log(
33+
`npm publish --dry-run contained ${JSON.stringify(requiredPaths)}`,
34+
);
35+
} catch (err) {
36+
console.error('failed to parse npm publish output', err);
37+
process.exit(1);
38+
}
39+
}
40+
41+
verifyPackageContents();

skills/a11y-debugging/SKILL.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
name: a11y-debugging
3+
description: Uses Chrome DevTools MCP for accessibility (a11y) debugging and auditing based on web.dev guidelines. Use when testing semantic HTML, ARIA labels, focus states, keyboard navigation, tap targets, and color contrast.
4+
---
5+
6+
## Core Concepts
7+
8+
**Accessibility Tree vs DOM**: Visually hiding an element (e.g., `CSS opacity: 0`) behaves differently for screen readers than `display: none` or `aria-hidden="true"`. The `take_snapshot` tool returns the accessibility tree of the page, which represents what assistive technologies "see", making it the most reliable source of truth for semantic structure.
9+
10+
**Reading web.dev documentation**: If you need to research specific accessibility guidelines (like `https://web.dev/articles/accessible-tap-targets`), you can append `.md.txt` to the URL (e.g., `https://web.dev/articles/accessible-tap-targets.md.txt`) to fetch the clean, raw markdown version. This is much easier to read!
11+
12+
## Workflow Patterns
13+
14+
### 1. Browser Issues & Audits
15+
16+
Chrome automatically checks for common accessibility problems. Use `list_console_messages` to check for these native audits first:
17+
18+
- `types`: `["issue"]`
19+
- `includePreservedMessages`: `true` (to catch issues that occurred during page load)
20+
21+
This often reveals missing labels, invalid ARIA attributes, and other critical errors without manual investigation.
22+
23+
### 2. Semantics & Structure
24+
25+
The accessibility tree exposes the heading hierarchy and semantic landmarks.
26+
27+
1. Navigate to the page.
28+
2. Use `take_snapshot` to capture the accessibility tree.
29+
3. **Check Heading Levels**: Ensure heading levels (`h1`, `h2`, `h3`, etc.) are logical and do not skip levels. The snapshot will include heading roles.
30+
4. **Content Reordering**: Verify that the DOM order (which drives the accessibility tree) matches the visual reading order. Use `take_screenshot` to inspect the visual layout and compare it against the snapshot structure to catch CSS floats or absolute positioning that jumbles the logical flow.
31+
32+
### 3. Labels, Forms & Text Alternatives
33+
34+
1. Locate buttons, inputs, and images in the `take_snapshot` output.
35+
2. Ensure interactive elements have an accessible name (e.g., a button should not just say `""` if it only contains an icon).
36+
3. **Orphaned Inputs**: Verify that all form inputs have associated labels. Use `evaluate_script` to check for inputs missing `id` (for `label[for]`) or `aria-label`:
37+
```js
38+
() =>
39+
Array.from(document.querySelectorAll('input, select, textarea'))
40+
.filter(i => {
41+
const hasId = i.id && document.querySelector(`label[for="${i.id}"]`);
42+
const hasAria =
43+
i.getAttribute('aria-label') || i.getAttribute('aria-labelledby');
44+
return !hasId && !hasAria && !i.closest('label');
45+
})
46+
.map(i => ({
47+
tag: i.tagName,
48+
id: i.id,
49+
name: i.name,
50+
placeholder: i.placeholder,
51+
}));
52+
```
53+
54+
````
55+
56+
4. Check images for `alt` text.
57+
58+
### 4. Focus & Keyboard Navigation
59+
60+
Testing "keyboard traps" and proper focus management without visual feedback relies on tracking the focused element.
61+
62+
1. Use the `press_key` tool with `"Tab"` or `"Shift+Tab"` to move focus.
63+
2. Use `take_snapshot` to capture the updated accessibility tree.
64+
3. Locate the element marked as focused in the snapshot to verify focus moved to the expected interactive element.
65+
4. If a modal opens, focus must move into the modal and "trap" within it until closed.
66+
67+
### 5. Tap Targets and Visuals
68+
69+
According to web.dev, tap targets should be at least 48x48 pixels with sufficient spacing. Since the accessibility tree doesn't show sizes, use `evaluate_script`:
70+
71+
```js
72+
// Usage in console: copy, paste, and call with element: fn(element)
73+
el => {
74+
const rect = el.getBoundingClientRect();
75+
return {width: rect.width, height: rect.height};
76+
};
77+
````
78+
79+
_Pass the element's `uid` from the snapshot as an argument to `evaluate_script`._
80+
81+
### 6. Color Contrast
82+
83+
To verify color contrast ratios, start by checking for native accessibility issues:
84+
85+
1. Call `list_console_messages` with `types: ["issue"]`.
86+
2. Look for "Low Contrast" issues in the output.
87+
88+
If native audits do not report issues (which may happen in some headless environments) or if you need to check a specific element manually, you can use the following script as a fallback approximation.
89+
90+
**Note**: This script uses a simplified algorithm and may not account for transparency, gradients, or background images. For production-grade auditing, consider injecting `axe-core`.
91+
92+
```js
93+
el => {
94+
function getRGB(colorStr) {
95+
const match = colorStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
96+
return match
97+
? [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])]
98+
: [255, 255, 255];
99+
}
100+
function luminance(r, g, b) {
101+
const a = [r, g, b].map(function (v) {
102+
v /= 255;
103+
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
104+
});
105+
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
106+
}
107+
108+
const style = window.getComputedStyle(el);
109+
const fg = getRGB(style.color);
110+
let bg = getRGB(style.backgroundColor);
111+
112+
// Basic contrast calculation (Note: Doesn't account for transparency over background images)
113+
const l1 = luminance(fg[0], fg[1], fg[2]);
114+
const l2 = luminance(bg[0], bg[1], bg[2]);
115+
const ratio = (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
116+
117+
return {
118+
color: style.color,
119+
bg: style.backgroundColor,
120+
contrastRatio: ratio.toFixed(2),
121+
};
122+
};
123+
```
124+
125+
_Pass the element's `uid` to test the contrast against WCAG AA (4.5:1 for normal text, 3:1 for large text)._
126+
127+
### 7. Global Page Checks
128+
129+
Verify document-level accessibility settings often missed in component testing:
130+
131+
```js
132+
() => ({
133+
lang:
134+
document.documentElement.lang ||
135+
'MISSING - Screen readers need this for pronunciation',
136+
title: document.title || 'MISSING - Required for context',
137+
viewport:
138+
document.querySelector('meta[name="viewport"]')?.content ||
139+
'MISSING - Check for user-scalable=no (bad practice)',
140+
reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)').matches
141+
? 'Enabled'
142+
: 'Disabled',
143+
});
144+
```
145+
146+
## Troubleshooting
147+
148+
If standard a11y queries fail or the `evaluate_script` snippets return unexpected results:
149+
150+
- **Visual Inspection**: If automated scripts cannot determine contrast (e.g., text over gradient images or complex backgrounds), use `take_screenshot` to capture the element. While models cannot measure exact contrast ratios from images, they can visually assess legibility and identifying obvious issues.

0 commit comments

Comments
 (0)