chrome-devtools-mcp 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -20
- package/build/src/BrowserManager.js +27 -18
- package/build/src/McpContext.js +435 -87
- package/build/src/McpPage.js +189 -59
- package/build/src/McpResponse.js +61 -44
- package/build/src/TextSnapshot.js +37 -18
- package/build/src/ToolHandler.js +256 -135
- package/build/src/bin/chrome-devtools-mcp-main.js +6 -4
- package/build/src/bin/chrome-devtools.js +4 -4
- package/build/src/collectors/PageCollector.js +13 -9
- package/build/src/collectors/ServiceWorkerCollector.js +2 -2
- package/build/src/collectors/constants.js +7 -0
- package/build/src/config/ConfigParser.js +44 -149
- package/build/src/config/ConfigWatcher.js +3 -2
- package/build/src/config/ServerConfig.js +251 -0
- package/build/src/config/browser-options.js +13 -4
- package/build/src/config/cli-options.js +35 -19
- package/build/src/config/mcp-options.js +61 -35
- package/build/src/config/puppeteer-options.js +4 -2
- package/build/src/daemon/client.js +3 -3
- package/build/src/daemon/daemon.js +7 -3
- package/build/src/daemon/utils.js +2 -1
- package/build/src/devtools/DevToolsCommentBridge.js +28 -5
- package/build/src/devtools/DevtoolsUtils.js +49 -12
- package/build/src/formatters/ConsoleFormatter.js +28 -1
- package/build/src/formatters/HeapSnapshotFormatter.js +14 -18
- package/build/src/formatters/NetworkFormatter.js +54 -15
- package/build/src/formatters/RemoteObjectFormatter.js +231 -0
- package/build/src/formatters/SnapshotFormatter.js +13 -3
- package/build/src/index.js +256 -104
- package/build/src/processors/HeapSnapshotManager.js +390 -128
- package/build/src/third_party/THIRD_PARTY_NOTICES +542 -445
- package/build/src/third_party/bundled-packages.json +2 -2
- package/build/src/third_party/cli.js +9239 -0
- package/build/src/third_party/devtools-formatter-worker.js +3089 -2438
- package/build/src/third_party/devtools-heap-snapshot-worker.js +172 -1
- package/build/src/third_party/index.js +52247 -55764
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +54576 -52174
- package/build/src/tools/ToolDefinition.js +90 -12
- package/build/src/tools/comments.js +42 -3
- package/build/src/tools/console.js +6 -4
- package/build/src/tools/css.js +1 -0
- package/build/src/tools/emulation.js +5 -4
- package/build/src/tools/extensions.js +5 -0
- package/build/src/tools/input.js +21 -6
- package/build/src/tools/lighthouse.js +24 -8
- package/build/src/tools/memory.js +59 -53
- package/build/src/tools/network.js +5 -4
- package/build/src/tools/pages.js +48 -6
- package/build/src/tools/performance.js +7 -4
- package/build/src/tools/pwa.js +7 -0
- package/build/src/tools/screencast.js +3 -1
- package/build/src/tools/screenshot.js +23 -7
- package/build/src/tools/script.js +38 -6
- package/build/src/tools/slim/tools.js +21 -5
- package/build/src/tools/snapshot.js +13 -3
- package/build/src/tools/thirdPartyDeveloper.js +3 -1
- package/build/src/tools/webmcp.js +2 -0
- package/build/src/utils/TaskRunner.js +136 -0
- package/build/src/utils/WaitForHelper.js +1 -1
- package/build/src/utils/bytes.js +2 -12
- package/build/src/utils/check-for-updates.js +1 -1
- package/build/src/utils/disclaimers.js +27 -0
- package/build/src/utils/keyboard.js +14 -2
- package/build/src/utils/logger.js +69 -0
- package/build/src/utils/resourceType.js +27 -0
- package/build/src/utils/text.js +29 -0
- package/build/src/utils/timeout.js +14 -0
- package/build/src/utils/url.js +41 -0
- package/build/src/version.js +1 -1
- package/package.json +5 -4
- package/skills/a11y-debugging/SKILL.md +3 -8
package/build/src/McpResponse.js
CHANGED
|
@@ -12,11 +12,13 @@ import { NetworkFormatter } from './formatters/NetworkFormatter.js';
|
|
|
12
12
|
import { SnapshotFormatter } from './formatters/SnapshotFormatter.js';
|
|
13
13
|
import { UncaughtError } from './collectors/PageCollector.js';
|
|
14
14
|
import { TextSnapshot } from './TextSnapshot.js';
|
|
15
|
-
import { DevTools, getToonEncode, getGcfEncode } from './third_party/index.js';
|
|
15
|
+
import { DevTools, getToonEncode, getGcfEncode, } from './third_party/index.js';
|
|
16
16
|
import { handleDialog, listPages } from './tools/pages.js';
|
|
17
17
|
import { getInsightOutput, getTraceSummary, } from './processors/PerformanceTrace.js';
|
|
18
18
|
import { stableIdSymbol } from './utils/id.js';
|
|
19
19
|
import { paginate } from './utils/pagination.js';
|
|
20
|
+
import { getFilterableResourceType } from './utils/resourceType.js';
|
|
21
|
+
import { truncateText } from './utils/text.js';
|
|
20
22
|
const { formatBytesToKb } = DevTools.I18n.ByteUtilities;
|
|
21
23
|
export class McpResponse {
|
|
22
24
|
#includePages = false;
|
|
@@ -40,9 +42,8 @@ export class McpResponse {
|
|
|
40
42
|
#listWebMcpTools;
|
|
41
43
|
#devToolsData;
|
|
42
44
|
#tabId;
|
|
43
|
-
#
|
|
45
|
+
#config;
|
|
44
46
|
#page;
|
|
45
|
-
#redactNetworkHeaders = true;
|
|
46
47
|
#error;
|
|
47
48
|
#attachedWaitForResult;
|
|
48
49
|
#reconnectNotice = false;
|
|
@@ -50,15 +51,12 @@ export class McpResponse {
|
|
|
50
51
|
get #deviceScope() {
|
|
51
52
|
return this.#page?.viewport?.isMobile ? 'PHONE' : 'DESKTOP';
|
|
52
53
|
}
|
|
53
|
-
constructor(
|
|
54
|
-
this.#
|
|
54
|
+
constructor(config) {
|
|
55
|
+
this.#config = config;
|
|
55
56
|
}
|
|
56
57
|
setPage(page) {
|
|
57
58
|
this.#page = page;
|
|
58
59
|
}
|
|
59
|
-
setRedactNetworkHeaders(value) {
|
|
60
|
-
this.#redactNetworkHeaders = value;
|
|
61
|
-
}
|
|
62
60
|
/**
|
|
63
61
|
* Surfaces a one-time note that the browser reconnected and page ids changed.
|
|
64
62
|
* Set by the tool handler when the context reports a pending reconnect notice.
|
|
@@ -74,7 +72,7 @@ export class McpResponse {
|
|
|
74
72
|
}
|
|
75
73
|
setIncludePages(value) {
|
|
76
74
|
this.#includePages = value;
|
|
77
|
-
if (this.#
|
|
75
|
+
if (this.#config.resolved.categoryExtensions) {
|
|
78
76
|
this.#includeExtensionServiceWorkers = value;
|
|
79
77
|
this.#includeExtensionPages = value;
|
|
80
78
|
}
|
|
@@ -103,7 +101,7 @@ export class McpResponse {
|
|
|
103
101
|
}
|
|
104
102
|
this.#networkRequestsOptions = {
|
|
105
103
|
include: value,
|
|
106
|
-
pagination: options?.pageSize !== undefined
|
|
104
|
+
pagination: options?.pageSize !== undefined
|
|
107
105
|
? {
|
|
108
106
|
pageSize: options.pageSize,
|
|
109
107
|
pageIdx: options.pageIdx,
|
|
@@ -121,7 +119,7 @@ export class McpResponse {
|
|
|
121
119
|
}
|
|
122
120
|
this.#consoleDataOptions = {
|
|
123
121
|
include: value,
|
|
124
|
-
pagination: options?.pageSize !== undefined
|
|
122
|
+
pagination: options?.pageSize !== undefined
|
|
125
123
|
? {
|
|
126
124
|
pageSize: options.pageSize,
|
|
127
125
|
pageIdx: options.pageIdx,
|
|
@@ -275,6 +273,7 @@ export class McpResponse {
|
|
|
275
273
|
...this.#heapSnapshotOptions,
|
|
276
274
|
include: true,
|
|
277
275
|
detailedClassDiff,
|
|
276
|
+
pagination: options,
|
|
278
277
|
formatOptions: options,
|
|
279
278
|
};
|
|
280
279
|
}
|
|
@@ -311,9 +310,6 @@ export class McpResponse {
|
|
|
311
310
|
return this.#listWebMcpTools;
|
|
312
311
|
}
|
|
313
312
|
async #handleSnapshot(context) {
|
|
314
|
-
if (this.#includePages) {
|
|
315
|
-
await context.createPagesSnapshot();
|
|
316
|
-
}
|
|
317
313
|
if (!this.#snapshotParams) {
|
|
318
314
|
return undefined;
|
|
319
315
|
}
|
|
@@ -346,7 +342,7 @@ export class McpResponse {
|
|
|
346
342
|
requestFilePath: this.#attachedNetworkRequestOptions?.requestFilePath,
|
|
347
343
|
responseFilePath: this.#attachedNetworkRequestOptions?.responseFilePath,
|
|
348
344
|
saveFile: (data, filename, extension) => context.saveFile(data, filename, extension),
|
|
349
|
-
redactNetworkHeaders: this.#redactNetworkHeaders,
|
|
345
|
+
redactNetworkHeaders: this.#config.resolved.redactNetworkHeaders,
|
|
350
346
|
});
|
|
351
347
|
}
|
|
352
348
|
async #handleAttachedConsoleMessage() {
|
|
@@ -379,16 +375,16 @@ export class McpResponse {
|
|
|
379
375
|
}
|
|
380
376
|
return undefined;
|
|
381
377
|
}
|
|
382
|
-
async #
|
|
383
|
-
if (this.#
|
|
378
|
+
async #handleThirdPartyDeveloperTools() {
|
|
379
|
+
if (this.#config.resolved.categoryExperimentalThirdParty &&
|
|
384
380
|
this.#listThirdPartyDeveloperTools &&
|
|
385
381
|
this.#page) {
|
|
386
|
-
return await this.#page.
|
|
382
|
+
return await this.#page.discoverThirdPartyDeveloperTools();
|
|
387
383
|
}
|
|
388
384
|
return undefined;
|
|
389
385
|
}
|
|
390
386
|
async #handleWebMCP() {
|
|
391
|
-
if (this.#
|
|
387
|
+
if (this.#config.resolved.categoryExperimentalWebmcp &&
|
|
392
388
|
this.#listWebMcpTools &&
|
|
393
389
|
this.#page) {
|
|
394
390
|
return this.#page.getWebMcpTools();
|
|
@@ -458,8 +454,7 @@ export class McpResponse {
|
|
|
458
454
|
if (this.#networkRequestsOptions.resourceTypes?.length) {
|
|
459
455
|
const normalizedTypes = new Set(this.#networkRequestsOptions.resourceTypes);
|
|
460
456
|
requests = requests.filter(request => {
|
|
461
|
-
|
|
462
|
-
return normalizedTypes.has(type);
|
|
457
|
+
return normalizedTypes.has(getFilterableResourceType(request));
|
|
463
458
|
});
|
|
464
459
|
}
|
|
465
460
|
return await Promise.all(requests.map(request => NetworkFormatter.from(request, {
|
|
@@ -468,7 +463,7 @@ export class McpResponse {
|
|
|
468
463
|
this.#networkRequestsOptions?.networkRequestIdInDevToolsUI,
|
|
469
464
|
fetchData: false,
|
|
470
465
|
saveFile: (data, filename, extension) => context.saveFile(data, filename, extension),
|
|
471
|
-
redactNetworkHeaders: this.#redactNetworkHeaders,
|
|
466
|
+
redactNetworkHeaders: this.#config.resolved.redactNetworkHeaders,
|
|
472
467
|
})));
|
|
473
468
|
}
|
|
474
469
|
async #handleComments() {
|
|
@@ -495,14 +490,22 @@ export class McpResponse {
|
|
|
495
490
|
return { formatter, commentsSnapshotRegenerated };
|
|
496
491
|
}
|
|
497
492
|
async handle(context, dataFormat = 'default') {
|
|
498
|
-
if (this.#
|
|
493
|
+
if (this.#includePages || this.#attachedWaitForResult?.openedPages) {
|
|
499
494
|
await context.createPagesSnapshot();
|
|
500
495
|
}
|
|
496
|
+
if (this.#includePages && (!this.#page || this.#page.isClosed())) {
|
|
497
|
+
try {
|
|
498
|
+
this.#page = context.getSelectedMcpPage();
|
|
499
|
+
}
|
|
500
|
+
catch {
|
|
501
|
+
this.#page = undefined;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
501
504
|
const [snapshot, detailedNetworkRequest, detailedConsoleMessage, thirdPartyDeveloperTools, webmcpTools, consoleMessages, networkRequests, commentsResult,] = await Promise.all([
|
|
502
505
|
this.#handleSnapshot(context),
|
|
503
506
|
this.#handleAttachedNetworkRequest(context),
|
|
504
507
|
this.#handleAttachedConsoleMessage(),
|
|
505
|
-
this.#
|
|
508
|
+
this.#handleThirdPartyDeveloperTools(),
|
|
506
509
|
this.#handleWebMCP(),
|
|
507
510
|
this.#handleConsoleList(context),
|
|
508
511
|
this.#handleNetworkRequestList(context),
|
|
@@ -567,7 +570,7 @@ export class McpResponse {
|
|
|
567
570
|
const response = [];
|
|
568
571
|
if (this.#reconnectNotice) {
|
|
569
572
|
structuredContent.reconnected = true;
|
|
570
|
-
response.push(`Note: the browser was restarted or reconnected since the last call. Page ids have changed. Call ${listPages(this.#
|
|
573
|
+
response.push(`Note: the browser was restarted or reconnected since the last call. Page ids have changed. Call ${listPages(this.#config.resolved).name} to see open pages.`);
|
|
571
574
|
}
|
|
572
575
|
if (this.#textResponseLines.length) {
|
|
573
576
|
structuredContent.message = this.#textResponseLines.join('\n');
|
|
@@ -653,7 +656,7 @@ export class McpResponse {
|
|
|
653
656
|
: '';
|
|
654
657
|
response.push(`# Open dialog
|
|
655
658
|
${dialog.type()}: ${dialog.message()}${defaultValueIfNeeded}.
|
|
656
|
-
Call ${handleDialog(this.#
|
|
659
|
+
Call ${handleDialog(this.#config.resolved).name} to handle it before continuing.`);
|
|
657
660
|
structuredContent.dialog = {
|
|
658
661
|
type: dialog.type(),
|
|
659
662
|
message: dialog.message(),
|
|
@@ -760,9 +763,11 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);
|
|
|
760
763
|
const insightOutput = getInsightOutput(data.traceInsight.trace, data.traceInsight.insightSetId, data.traceInsight.insightName, this.#deviceScope);
|
|
761
764
|
if ('error' in insightOutput) {
|
|
762
765
|
response.push(insightOutput.error);
|
|
766
|
+
structuredContent.error = insightOutput.error;
|
|
763
767
|
}
|
|
764
768
|
else {
|
|
765
769
|
response.push(insightOutput.output);
|
|
770
|
+
structuredContent.traceInsight = insightOutput.output;
|
|
766
771
|
}
|
|
767
772
|
}
|
|
768
773
|
if (data.lighthouseResult) {
|
|
@@ -960,13 +965,23 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);
|
|
|
960
965
|
const detailedClassDiff = this.#heapSnapshotOptions.detailedClassDiff;
|
|
961
966
|
if (detailedClassDiff) {
|
|
962
967
|
response.push('### Heap Snapshot Detailed Diff');
|
|
968
|
+
const { classDiff, objects } = detailedClassDiff;
|
|
969
|
+
const paginationData = this.#dataWithPagination(objects, this.#heapSnapshotOptions.pagination);
|
|
970
|
+
structuredContent.pagination = paginationData.pagination;
|
|
963
971
|
response.push(compactEncode
|
|
964
972
|
? compactEncode({
|
|
965
|
-
...
|
|
966
|
-
className: formatName(
|
|
973
|
+
...classDiff,
|
|
974
|
+
className: formatName(classDiff.className, formatOptions),
|
|
967
975
|
})
|
|
968
|
-
: HeapSnapshotFormatter.
|
|
969
|
-
|
|
976
|
+
: HeapSnapshotFormatter.formatDetailedClassDiffHeader(classDiff, formatOptions));
|
|
977
|
+
response.push(...paginationData.info);
|
|
978
|
+
response.push(compactEncode
|
|
979
|
+
? compactEncode(paginationData.items)
|
|
980
|
+
: HeapSnapshotFormatter.formatDetailedClassDiffObjects(paginationData.items));
|
|
981
|
+
structuredContent.heapSnapshotDetailedClassDiff = {
|
|
982
|
+
classDiff,
|
|
983
|
+
objects: paginationData.items,
|
|
984
|
+
};
|
|
970
985
|
}
|
|
971
986
|
const duplicateStrings = this.#heapSnapshotOptions.duplicateStrings;
|
|
972
987
|
if (duplicateStrings) {
|
|
@@ -1043,18 +1058,23 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);
|
|
|
1043
1058
|
}
|
|
1044
1059
|
}
|
|
1045
1060
|
const thirdPartyDeveloperTools = data.thirdPartyDeveloperTools;
|
|
1046
|
-
if (thirdPartyDeveloperTools
|
|
1061
|
+
if (this.#listThirdPartyDeveloperTools && thirdPartyDeveloperTools) {
|
|
1047
1062
|
structuredContent.thirdPartyDeveloperTools = thirdPartyDeveloperTools;
|
|
1048
1063
|
response.push('## Third-party developer tools');
|
|
1049
|
-
|
|
1050
|
-
response.push(
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
.
|
|
1057
|
-
|
|
1064
|
+
if (thirdPartyDeveloperTools.length === 0) {
|
|
1065
|
+
response.push('No third-party developer tools available.');
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
for (const toolGroup of thirdPartyDeveloperTools) {
|
|
1069
|
+
response.push(`${toolGroup.name}: ${toolGroup.description}`);
|
|
1070
|
+
response.push('Available tools:');
|
|
1071
|
+
const toolDefinitionsMessage = toolGroup.tools
|
|
1072
|
+
.map(tool => {
|
|
1073
|
+
return `name="${tool.name}", description="${tool.description}", inputSchema=${JSON.stringify(tool.inputSchema)}`;
|
|
1074
|
+
})
|
|
1075
|
+
.join('\n');
|
|
1076
|
+
response.push(toolDefinitionsMessage);
|
|
1077
|
+
}
|
|
1058
1078
|
}
|
|
1059
1079
|
}
|
|
1060
1080
|
if (this.#listWebMcpTools && data.webmcpTools) {
|
|
@@ -1210,10 +1230,7 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);
|
|
|
1210
1230
|
}
|
|
1211
1231
|
}
|
|
1212
1232
|
function truncateTitle(title, maxLength = 50) {
|
|
1213
|
-
|
|
1214
|
-
return title;
|
|
1215
|
-
}
|
|
1216
|
-
return title.slice(0, maxLength - 3) + '...';
|
|
1233
|
+
return truncateText(title, maxLength, { includeEllipsisInLength: true });
|
|
1217
1234
|
}
|
|
1218
1235
|
const collapseWhitespace = (value) => {
|
|
1219
1236
|
return value.replace(/\s+/g, ' ').trim();
|
|
@@ -56,6 +56,16 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
56
56
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
57
|
});
|
|
58
58
|
import { logger } from './utils/logger.js';
|
|
59
|
+
import { withTimeout } from './utils/timeout.js';
|
|
60
|
+
const ACCESSIBILITY_SNAPSHOT_TIMEOUT_MS = 10_000;
|
|
61
|
+
/**
|
|
62
|
+
* InlineTextBox nodes are layout line fragments of a StaticText node. They
|
|
63
|
+
* repeat the parent text, have no backendNodeId and cannot be targeted by
|
|
64
|
+
* tools. Puppeteer only serializes them for non-interesting-only snapshots.
|
|
65
|
+
*/
|
|
66
|
+
function isLayoutOnlyNode(node) {
|
|
67
|
+
return node.role === 'InlineTextBox';
|
|
68
|
+
}
|
|
59
69
|
export class TextSnapshot {
|
|
60
70
|
static nextSnapshotId = 1;
|
|
61
71
|
static resetCounter() {
|
|
@@ -77,9 +87,12 @@ export class TextSnapshot {
|
|
|
77
87
|
}
|
|
78
88
|
static async create(page, options = {}) {
|
|
79
89
|
const verbose = options.verbose ?? false;
|
|
80
|
-
const rootNode = await page.pptrPage.accessibility.snapshot({
|
|
90
|
+
const rootNode = await withTimeout(page.pptrPage.accessibility.snapshot({
|
|
81
91
|
includeIframes: true,
|
|
82
92
|
interestingOnly: !verbose,
|
|
93
|
+
}), {
|
|
94
|
+
timeout: ACCESSIBILITY_SNAPSHOT_TIMEOUT_MS,
|
|
95
|
+
message: `Timed out after ${ACCESSIBILITY_SNAPSHOT_TIMEOUT_MS}ms waiting for the accessibility tree. The page may have a pending navigation or a crashed renderer. Navigate or reload the page, or select another page.`,
|
|
83
96
|
});
|
|
84
97
|
if (!rootNode) {
|
|
85
98
|
throw new Error('Failed to create accessibility snapshot');
|
|
@@ -96,25 +109,29 @@ export class TextSnapshot {
|
|
|
96
109
|
let id = '';
|
|
97
110
|
// @ts-expect-error untyped backendNodeId.
|
|
98
111
|
const backendNodeId = node.backendNodeId;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
if (backendNodeId !== undefined) {
|
|
113
|
+
// @ts-expect-error untyped loaderId.
|
|
114
|
+
const uniqueBackendId = `${node.loaderId}_${backendNodeId}`;
|
|
115
|
+
const existingMcpId = uniqueBackendNodeIdToMcpId.get(uniqueBackendId);
|
|
116
|
+
if (existingMcpId !== undefined) {
|
|
117
|
+
// Re-use MCP exposed ID if the uniqueId is the same.
|
|
118
|
+
id = existingMcpId;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// Only generate a new ID if we have not seen the node before.
|
|
122
|
+
id = `${snapshotId}_${idCounter++}`;
|
|
123
|
+
uniqueBackendNodeIdToMcpId.set(uniqueBackendId, id);
|
|
124
|
+
}
|
|
125
|
+
seenUniqueIds.add(uniqueBackendId);
|
|
126
|
+
seenBackendNodeIds.add(backendNodeId);
|
|
110
127
|
}
|
|
111
|
-
seenUniqueIds.add(uniqueBackendId);
|
|
112
|
-
seenBackendNodeIds.add(backendNodeId);
|
|
113
128
|
const nodeWithId = {
|
|
114
129
|
...node,
|
|
115
130
|
id,
|
|
116
131
|
children: node.children
|
|
117
|
-
? node.children
|
|
132
|
+
? node.children
|
|
133
|
+
.filter(child => !isLayoutOnlyNode(child))
|
|
134
|
+
.map(child => assignIds(child))
|
|
118
135
|
: [],
|
|
119
136
|
};
|
|
120
137
|
// The AXNode for an option doesn't contain its `value`.
|
|
@@ -125,11 +142,13 @@ export class TextSnapshot {
|
|
|
125
142
|
nodeWithId.value = optionText.toString();
|
|
126
143
|
}
|
|
127
144
|
}
|
|
128
|
-
|
|
145
|
+
if (id) {
|
|
146
|
+
idToNode.set(nodeWithId.id, nodeWithId);
|
|
147
|
+
}
|
|
129
148
|
return nodeWithId;
|
|
130
149
|
};
|
|
131
150
|
const rootNodeWithId = assignIds(rootNode);
|
|
132
|
-
await TextSnapshot
|
|
151
|
+
await TextSnapshot.#insertExtraNodes(page, idToNode, seenUniqueIds, snapshotId, idCounter, rootNodeWithId, seenBackendNodeIds, options.extraHandles ?? []);
|
|
133
152
|
const snapshot = new TextSnapshot({
|
|
134
153
|
root: rootNodeWithId,
|
|
135
154
|
snapshotId: String(snapshotId),
|
|
@@ -172,7 +191,7 @@ export class TextSnapshot {
|
|
|
172
191
|
// ExtraHandles represent DOM nodes which might not be part of the accessibility tree, e.g. DOM nodes
|
|
173
192
|
// returned by third-party developer tools. We insert them into the tree by finding the closest ancestor
|
|
174
193
|
// in the tree and inserting the node as a child. The ancestor's child nodes are re-parented if necessary.
|
|
175
|
-
static async insertExtraNodes(page, idToNode, seenUniqueIds, snapshotId, idCounter, rootNodeWithId, seenBackendNodeIds, extraHandles) {
|
|
194
|
+
static async #insertExtraNodes(page, idToNode, seenUniqueIds, snapshotId, idCounter, rootNodeWithId, seenBackendNodeIds, extraHandles) {
|
|
176
195
|
const { uniqueBackendNodeIdToMcpId } = page;
|
|
177
196
|
const createExtraNode = async (handle) => {
|
|
178
197
|
const backendNodeId = await handle.backendNodeId();
|