@eddym06/custom-chrome-mcp 1.0.4 โ 1.1.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/CONDITIONAL_DESCRIPTIONS.md +174 -0
- package/FUTURE_FEATURES.txt +1503 -0
- package/README.md +300 -3
- package/TEST_WORKFLOW.md +311 -0
- package/USAGE_GUIDE.md +393 -0
- package/demo_features.ts +115 -0
- package/dist/chrome-connector.d.ts +31 -4
- package/dist/chrome-connector.d.ts.map +1 -1
- package/dist/chrome-connector.js +402 -53
- package/dist/chrome-connector.js.map +1 -1
- package/dist/index.js +69 -12
- package/dist/index.js.map +1 -1
- package/dist/tests/execute-script-tests.d.ts +62 -0
- package/dist/tests/execute-script-tests.d.ts.map +1 -0
- package/dist/tests/execute-script-tests.js +280 -0
- package/dist/tests/execute-script-tests.js.map +1 -0
- package/dist/tests/run-execute-tests.d.ts +7 -0
- package/dist/tests/run-execute-tests.d.ts.map +1 -0
- package/dist/tests/run-execute-tests.js +88 -0
- package/dist/tests/run-execute-tests.js.map +1 -0
- package/dist/tools/advanced-network.backup.d.ts +245 -0
- package/dist/tools/advanced-network.backup.d.ts.map +1 -0
- package/dist/tools/advanced-network.backup.js +996 -0
- package/dist/tools/advanced-network.backup.js.map +1 -0
- package/dist/tools/advanced-network.d.ts +580 -0
- package/dist/tools/advanced-network.d.ts.map +1 -0
- package/dist/tools/advanced-network.js +1325 -0
- package/dist/tools/advanced-network.js.map +1 -0
- package/dist/tools/anti-detection.d.ts.map +1 -1
- package/dist/tools/anti-detection.js +13 -8
- package/dist/tools/anti-detection.js.map +1 -1
- package/dist/tools/capture.d.ts +15 -9
- package/dist/tools/capture.d.ts.map +1 -1
- package/dist/tools/capture.js +21 -12
- package/dist/tools/capture.js.map +1 -1
- package/dist/tools/interaction.d.ts +84 -10
- package/dist/tools/interaction.d.ts.map +1 -1
- package/dist/tools/interaction.js +88 -33
- package/dist/tools/interaction.js.map +1 -1
- package/dist/tools/navigation.d.ts.map +1 -1
- package/dist/tools/navigation.js +43 -21
- package/dist/tools/navigation.js.map +1 -1
- package/dist/tools/network-accessibility.d.ts +67 -0
- package/dist/tools/network-accessibility.d.ts.map +1 -0
- package/dist/tools/network-accessibility.js +367 -0
- package/dist/tools/network-accessibility.js.map +1 -0
- package/dist/tools/playwright-launcher.d.ts +1 -1
- package/dist/tools/playwright-launcher.js +6 -6
- package/dist/tools/playwright-launcher.js.map +1 -1
- package/dist/tools/service-worker.d.ts +2 -2
- package/dist/tools/service-worker.d.ts.map +1 -1
- package/dist/tools/service-worker.js +22 -12
- package/dist/tools/service-worker.js.map +1 -1
- package/dist/tools/session.d.ts.map +1 -1
- package/dist/tools/session.js +23 -14
- package/dist/tools/session.js.map +1 -1
- package/dist/tools/system.d.ts +2 -2
- package/dist/tools/system.d.ts.map +1 -1
- package/dist/tools/system.js +9 -5
- package/dist/tools/system.js.map +1 -1
- package/dist/utils/truncate.d.ts +29 -0
- package/dist/utils/truncate.d.ts.map +1 -0
- package/dist/utils/truncate.js +46 -0
- package/dist/utils/truncate.js.map +1 -0
- package/dist/verify-tools.d.ts +7 -0
- package/dist/verify-tools.d.ts.map +1 -0
- package/dist/verify-tools.js +137 -0
- package/dist/verify-tools.js.map +1 -0
- package/package.json +3 -3
- package/recordings/demo_recording.har +3036 -0
- package/.npmrc.example +0 -2
- package/test-playwright.js +0 -57
package/dist/index.js
CHANGED
|
@@ -15,6 +15,8 @@ import { createCaptureTools } from './tools/capture.js';
|
|
|
15
15
|
import { createSessionTools } from './tools/session.js';
|
|
16
16
|
import { createSystemTools } from './tools/system.js';
|
|
17
17
|
import { createPlaywrightLauncherTools } from './tools/playwright-launcher.js';
|
|
18
|
+
import { createNetworkAccessibilityTools } from './tools/network-accessibility.js';
|
|
19
|
+
import { createAdvancedNetworkTools } from './tools/advanced-network.js';
|
|
18
20
|
// Parse command line arguments
|
|
19
21
|
const args = process.argv.slice(2);
|
|
20
22
|
const portArg = args.find(arg => arg.startsWith('--port='));
|
|
@@ -40,6 +42,8 @@ const allTools = [
|
|
|
40
42
|
...createCaptureTools(connector),
|
|
41
43
|
...createSessionTools(connector),
|
|
42
44
|
...createSystemTools(connector),
|
|
45
|
+
...createNetworkAccessibilityTools(connector), // Network interception + Accessibility tree
|
|
46
|
+
...createAdvancedNetworkTools(connector), // Advanced network tools (Response, Mock, WebSocket, HAR, Patterns, Injection)
|
|
43
47
|
];
|
|
44
48
|
// Create tool map for quick lookup
|
|
45
49
|
const toolMap = new Map(allTools.map(tool => [tool.name, tool]));
|
|
@@ -48,18 +52,36 @@ function zodTypeToJsonSchema(schema) {
|
|
|
48
52
|
if (!schema)
|
|
49
53
|
return { type: 'string' };
|
|
50
54
|
let current = schema;
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
current
|
|
55
|
+
let description = current.description;
|
|
56
|
+
let defaultValue = undefined;
|
|
57
|
+
// Unwrap Optional/Default/Effects wrappers and collect metadata
|
|
58
|
+
while (current._def.typeName === 'ZodOptional' ||
|
|
59
|
+
current._def.typeName === 'ZodDefault' ||
|
|
60
|
+
current._def.typeName === 'ZodEffects') {
|
|
61
|
+
if (current.description)
|
|
62
|
+
description = current.description;
|
|
63
|
+
if (current._def.typeName === 'ZodDefault') {
|
|
64
|
+
defaultValue = current._def.defaultValue();
|
|
65
|
+
}
|
|
66
|
+
if (current._def.typeName === 'ZodEffects') {
|
|
67
|
+
current = current._def.schema;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
current = current._def.innerType;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// If we still haven't found a description on the wrappers, check the inner type
|
|
74
|
+
if (!description && current.description) {
|
|
75
|
+
description = current.description;
|
|
57
76
|
}
|
|
58
77
|
const def = current._def;
|
|
59
78
|
let type = 'string'; // Default fallback
|
|
60
79
|
const jsonSchema = {};
|
|
61
|
-
if (
|
|
62
|
-
jsonSchema.description =
|
|
80
|
+
if (description) {
|
|
81
|
+
jsonSchema.description = description;
|
|
82
|
+
}
|
|
83
|
+
if (defaultValue !== undefined) {
|
|
84
|
+
jsonSchema.default = defaultValue;
|
|
63
85
|
}
|
|
64
86
|
switch (def.typeName) {
|
|
65
87
|
case 'ZodString':
|
|
@@ -75,6 +97,15 @@ function zodTypeToJsonSchema(schema) {
|
|
|
75
97
|
type = 'string';
|
|
76
98
|
jsonSchema.enum = def.values;
|
|
77
99
|
break;
|
|
100
|
+
case 'ZodArray':
|
|
101
|
+
type = 'array';
|
|
102
|
+
jsonSchema.items = zodTypeToJsonSchema(def.type);
|
|
103
|
+
break;
|
|
104
|
+
case 'ZodNativeEnum':
|
|
105
|
+
type = 'string';
|
|
106
|
+
// Basic support for numeric enums or string enums
|
|
107
|
+
jsonSchema.enum = Object.values(def.values);
|
|
108
|
+
break;
|
|
78
109
|
}
|
|
79
110
|
jsonSchema.type = type;
|
|
80
111
|
return jsonSchema;
|
|
@@ -94,10 +125,19 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
94
125
|
// Check if required
|
|
95
126
|
let isOptional = false;
|
|
96
127
|
let current = zodSchema;
|
|
97
|
-
|
|
98
|
-
|
|
128
|
+
// Unwrap to check strict optionality
|
|
129
|
+
while (current._def.typeName === 'ZodOptional' ||
|
|
130
|
+
current._def.typeName === 'ZodDefault' ||
|
|
131
|
+
current._def.typeName === 'ZodEffects') {
|
|
132
|
+
if (current._def.typeName === 'ZodOptional' || current._def.typeName === 'ZodDefault') {
|
|
99
133
|
isOptional = true;
|
|
100
|
-
|
|
134
|
+
}
|
|
135
|
+
if (current._def.typeName === 'ZodEffects') {
|
|
136
|
+
current = current._def.schema;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
current = current._def.innerType;
|
|
140
|
+
}
|
|
101
141
|
}
|
|
102
142
|
if (!isOptional) {
|
|
103
143
|
required.push(key);
|
|
@@ -177,7 +217,24 @@ async function main() {
|
|
|
177
217
|
console.error(' - Session & Cookies (9 tools)');
|
|
178
218
|
console.error(' - System & Extensions (4 tools)');
|
|
179
219
|
console.error('');
|
|
180
|
-
console.error('โจ Server ready!
|
|
220
|
+
console.error('โจ Server ready!');
|
|
221
|
+
console.error('');
|
|
222
|
+
// Auto-launch Chrome on startup
|
|
223
|
+
console.error('๐ Auto-launching Chrome with Default profile...');
|
|
224
|
+
try {
|
|
225
|
+
const launchTool = allTools.find(t => t.name === 'launch_chrome_with_profile');
|
|
226
|
+
if (launchTool?.handler) {
|
|
227
|
+
const launchPromise = launchTool.handler({ profileDirectory: 'Default' });
|
|
228
|
+
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Launch timeout after 15s')), 15000));
|
|
229
|
+
await Promise.race([launchPromise, timeoutPromise]);
|
|
230
|
+
console.error('โ
Chrome launched successfully!');
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
console.error('โ ๏ธ Auto-launch failed:', error.message);
|
|
235
|
+
console.error(' You can manually use "launch_chrome_with_profile" tool later');
|
|
236
|
+
}
|
|
237
|
+
console.error('');
|
|
181
238
|
// Start MCP server with stdio transport
|
|
182
239
|
const transport = new StdioServerTransport();
|
|
183
240
|
await server.connect(transport);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO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AAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IAC/B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC9C,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,aAAa;AACb,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute Script Testing Suite
|
|
3
|
+
* Progressive tests from simple to complex
|
|
4
|
+
*/
|
|
5
|
+
export declare const executeScriptTests: ({
|
|
6
|
+
name: string;
|
|
7
|
+
script: string;
|
|
8
|
+
expectedResult: number;
|
|
9
|
+
timeoutMs: number;
|
|
10
|
+
awaitPromise?: undefined;
|
|
11
|
+
shouldFail?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
name: string;
|
|
14
|
+
script: string;
|
|
15
|
+
expectedResult: string;
|
|
16
|
+
timeoutMs: number;
|
|
17
|
+
awaitPromise?: undefined;
|
|
18
|
+
shouldFail?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
name: string;
|
|
21
|
+
script: string;
|
|
22
|
+
expectedResult: number[];
|
|
23
|
+
timeoutMs: number;
|
|
24
|
+
awaitPromise?: undefined;
|
|
25
|
+
shouldFail?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
name: string;
|
|
28
|
+
script: string;
|
|
29
|
+
expectedResult: {
|
|
30
|
+
name: string;
|
|
31
|
+
value: number;
|
|
32
|
+
};
|
|
33
|
+
timeoutMs: number;
|
|
34
|
+
awaitPromise?: undefined;
|
|
35
|
+
shouldFail?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
name: string;
|
|
38
|
+
script: string;
|
|
39
|
+
expectedResult: string;
|
|
40
|
+
timeoutMs: number;
|
|
41
|
+
awaitPromise: boolean;
|
|
42
|
+
shouldFail?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
name: string;
|
|
45
|
+
script: string;
|
|
46
|
+
expectedResult: string;
|
|
47
|
+
shouldFail: boolean;
|
|
48
|
+
timeoutMs: number;
|
|
49
|
+
awaitPromise?: undefined;
|
|
50
|
+
})[];
|
|
51
|
+
/**
|
|
52
|
+
* Test runner instructions for AI
|
|
53
|
+
*/
|
|
54
|
+
export declare const testInstructions = "\nEXECUTE_SCRIPT TESTING PROTOCOL\n\nPrerequisites:\n1. Chrome browser must be running (launch_chrome_with_profile)\n2. Navigate to a test page (e.g., https://example.com or https://apple.com)\n\nTesting Sequence:\n1. Start with LEVEL 1 tests (simple expressions)\n2. If all pass, proceed to LEVEL 2 (basic DOM)\n3. Continue through levels progressively\n4. Stop at first failure and report\n\nFor each test:\n1. Call execute_script with the test script\n2. Record: success/failure, result, execution time\n3. Compare result with expected (if not error test)\n4. Note any deviations or unexpected behavior\n\nExpected Outcomes:\n- LEVEL 1-2: Should have 100% success rate\n- LEVEL 3-4: Should have >90% success rate\n- LEVEL 5: May have some failures (network dependent)\n- LEVEL 6: Should fail gracefully with error messages (not crash)\n\nFailure Analysis:\nIf a test fails, check:\n1. Is Chrome connection active? (list_tabs)\n2. Is page loaded? (get_url, screenshot)\n3. Is timeout sufficient? (increase timeoutMs)\n4. Is error message descriptive?\n\nReport Format:\n{\n level: \"LEVEL X\",\n passed: X,\n failed: Y,\n total: Z,\n failures: [{test: \"name\", error: \"message\"}]\n}\n";
|
|
55
|
+
/**
|
|
56
|
+
* Real-world usage examples
|
|
57
|
+
*/
|
|
58
|
+
export declare const realWorldExamples: {
|
|
59
|
+
scenario: string;
|
|
60
|
+
script: string;
|
|
61
|
+
}[];
|
|
62
|
+
//# sourceMappingURL=execute-script-tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-script-tests.d.ts","sourceRoot":"","sources":["../../src/tests/execute-script-tests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2L9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,+qCAwC5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;GA4C7B,CAAC"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute Script Testing Suite
|
|
3
|
+
* Progressive tests from simple to complex
|
|
4
|
+
*/
|
|
5
|
+
export const executeScriptTests = [
|
|
6
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
7
|
+
// LEVEL 1: BASIC EXPRESSIONS (should all work)
|
|
8
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
9
|
+
{
|
|
10
|
+
name: "Simple arithmetic",
|
|
11
|
+
script: "return 1 + 1;",
|
|
12
|
+
expectedResult: 2,
|
|
13
|
+
timeoutMs: 5000
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "String concatenation",
|
|
17
|
+
script: "return 'Hello' + ' ' + 'World';",
|
|
18
|
+
expectedResult: "Hello World",
|
|
19
|
+
timeoutMs: 5000
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "Get page title",
|
|
23
|
+
script: "return document.title;",
|
|
24
|
+
expectedResult: "<any string>",
|
|
25
|
+
timeoutMs: 5000
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "Get URL",
|
|
29
|
+
script: "return window.location.href;",
|
|
30
|
+
expectedResult: "<url>",
|
|
31
|
+
timeoutMs: 5000
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "Array creation",
|
|
35
|
+
script: "return [1, 2, 3, 4, 5];",
|
|
36
|
+
expectedResult: [1, 2, 3, 4, 5],
|
|
37
|
+
timeoutMs: 5000
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "Object creation",
|
|
41
|
+
script: "return {name: 'test', value: 123};",
|
|
42
|
+
expectedResult: { name: 'test', value: 123 },
|
|
43
|
+
timeoutMs: 5000
|
|
44
|
+
},
|
|
45
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
46
|
+
// LEVEL 2: DOM QUERIES (basic)
|
|
47
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
48
|
+
{
|
|
49
|
+
name: "Count all elements",
|
|
50
|
+
script: "return document.querySelectorAll('*').length;",
|
|
51
|
+
expectedResult: "<number>",
|
|
52
|
+
timeoutMs: 5000
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "Get all link hrefs",
|
|
56
|
+
script: `
|
|
57
|
+
return Array.from(document.querySelectorAll('a'))
|
|
58
|
+
.map(a => a.href)
|
|
59
|
+
.filter(href => href.startsWith('http'));
|
|
60
|
+
`,
|
|
61
|
+
expectedResult: "<array of urls>",
|
|
62
|
+
timeoutMs: 10000
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "Get all button texts",
|
|
66
|
+
script: `
|
|
67
|
+
return Array.from(document.querySelectorAll('button'))
|
|
68
|
+
.map(btn => btn.textContent.trim())
|
|
69
|
+
.filter(text => text.length > 0);
|
|
70
|
+
`,
|
|
71
|
+
expectedResult: "<array of strings>",
|
|
72
|
+
timeoutMs: 10000
|
|
73
|
+
},
|
|
74
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
75
|
+
// LEVEL 3: COMPLEX QUERIES
|
|
76
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
77
|
+
{
|
|
78
|
+
name: "Extract structured data",
|
|
79
|
+
script: `
|
|
80
|
+
return Array.from(document.querySelectorAll('article, .post, .item'))
|
|
81
|
+
.slice(0, 10)
|
|
82
|
+
.map(item => ({
|
|
83
|
+
text: item.textContent.trim().substring(0, 100),
|
|
84
|
+
links: Array.from(item.querySelectorAll('a')).length,
|
|
85
|
+
images: Array.from(item.querySelectorAll('img')).length
|
|
86
|
+
}));
|
|
87
|
+
`,
|
|
88
|
+
expectedResult: "<array of objects>",
|
|
89
|
+
timeoutMs: 15000
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "Get form field info",
|
|
93
|
+
script: `
|
|
94
|
+
return Array.from(document.querySelectorAll('input, textarea, select'))
|
|
95
|
+
.map(field => ({
|
|
96
|
+
type: field.type || field.tagName,
|
|
97
|
+
name: field.name || field.id,
|
|
98
|
+
value: field.value ? '[has value]' : '[empty]'
|
|
99
|
+
}));
|
|
100
|
+
`,
|
|
101
|
+
expectedResult: "<array of form fields>",
|
|
102
|
+
timeoutMs: 10000
|
|
103
|
+
},
|
|
104
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
105
|
+
// LEVEL 4: WINDOW OBJECT ACCESS
|
|
106
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
107
|
+
{
|
|
108
|
+
name: "Check window variables",
|
|
109
|
+
script: `
|
|
110
|
+
return {
|
|
111
|
+
hasJQuery: typeof window.jQuery !== 'undefined',
|
|
112
|
+
hasReact: typeof window.React !== 'undefined',
|
|
113
|
+
hasAngular: typeof window.angular !== 'undefined',
|
|
114
|
+
hasVue: typeof window.Vue !== 'undefined'
|
|
115
|
+
};
|
|
116
|
+
`,
|
|
117
|
+
expectedResult: "<object with boolean values>",
|
|
118
|
+
timeoutMs: 5000
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "Get localStorage items",
|
|
122
|
+
script: `
|
|
123
|
+
const items = {};
|
|
124
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
125
|
+
const key = localStorage.key(i);
|
|
126
|
+
items[key] = localStorage.getItem(key).substring(0, 50);
|
|
127
|
+
}
|
|
128
|
+
return items;
|
|
129
|
+
`,
|
|
130
|
+
expectedResult: "<object>",
|
|
131
|
+
timeoutMs: 5000
|
|
132
|
+
},
|
|
133
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
134
|
+
// LEVEL 5: ASYNC OPERATIONS
|
|
135
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
136
|
+
{
|
|
137
|
+
name: "Async timeout",
|
|
138
|
+
script: `
|
|
139
|
+
return new Promise(resolve => {
|
|
140
|
+
setTimeout(() => resolve('Async completed'), 1000);
|
|
141
|
+
});
|
|
142
|
+
`,
|
|
143
|
+
expectedResult: "Async completed",
|
|
144
|
+
timeoutMs: 5000,
|
|
145
|
+
awaitPromise: true
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "Fetch test (if available)",
|
|
149
|
+
script: `
|
|
150
|
+
if (typeof fetch === 'undefined') {
|
|
151
|
+
return 'Fetch not available';
|
|
152
|
+
}
|
|
153
|
+
return 'Fetch available (use with caution in tests)';
|
|
154
|
+
`,
|
|
155
|
+
expectedResult: "<string>",
|
|
156
|
+
timeoutMs: 5000
|
|
157
|
+
},
|
|
158
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
159
|
+
// LEVEL 6: ERROR HANDLING TESTS (should fail gracefully)
|
|
160
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
161
|
+
{
|
|
162
|
+
name: "Syntax error",
|
|
163
|
+
script: "return this is invalid javascript;",
|
|
164
|
+
expectedResult: "<error>",
|
|
165
|
+
shouldFail: true,
|
|
166
|
+
timeoutMs: 5000
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "Runtime error",
|
|
170
|
+
script: "return undefinedVariable.property;",
|
|
171
|
+
expectedResult: "<error>",
|
|
172
|
+
shouldFail: true,
|
|
173
|
+
timeoutMs: 5000
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "Return DOM node (should be handled)",
|
|
177
|
+
script: "return document.body;",
|
|
178
|
+
expectedResult: "[DOM Node - use get_text or get_attribute instead]",
|
|
179
|
+
timeoutMs: 5000
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "Return function (should be handled)",
|
|
183
|
+
script: "return function() { return 'test'; };",
|
|
184
|
+
expectedResult: "[Function]",
|
|
185
|
+
timeoutMs: 5000
|
|
186
|
+
}
|
|
187
|
+
];
|
|
188
|
+
/**
|
|
189
|
+
* Test runner instructions for AI
|
|
190
|
+
*/
|
|
191
|
+
export const testInstructions = `
|
|
192
|
+
EXECUTE_SCRIPT TESTING PROTOCOL
|
|
193
|
+
|
|
194
|
+
Prerequisites:
|
|
195
|
+
1. Chrome browser must be running (launch_chrome_with_profile)
|
|
196
|
+
2. Navigate to a test page (e.g., https://example.com or https://apple.com)
|
|
197
|
+
|
|
198
|
+
Testing Sequence:
|
|
199
|
+
1. Start with LEVEL 1 tests (simple expressions)
|
|
200
|
+
2. If all pass, proceed to LEVEL 2 (basic DOM)
|
|
201
|
+
3. Continue through levels progressively
|
|
202
|
+
4. Stop at first failure and report
|
|
203
|
+
|
|
204
|
+
For each test:
|
|
205
|
+
1. Call execute_script with the test script
|
|
206
|
+
2. Record: success/failure, result, execution time
|
|
207
|
+
3. Compare result with expected (if not error test)
|
|
208
|
+
4. Note any deviations or unexpected behavior
|
|
209
|
+
|
|
210
|
+
Expected Outcomes:
|
|
211
|
+
- LEVEL 1-2: Should have 100% success rate
|
|
212
|
+
- LEVEL 3-4: Should have >90% success rate
|
|
213
|
+
- LEVEL 5: May have some failures (network dependent)
|
|
214
|
+
- LEVEL 6: Should fail gracefully with error messages (not crash)
|
|
215
|
+
|
|
216
|
+
Failure Analysis:
|
|
217
|
+
If a test fails, check:
|
|
218
|
+
1. Is Chrome connection active? (list_tabs)
|
|
219
|
+
2. Is page loaded? (get_url, screenshot)
|
|
220
|
+
3. Is timeout sufficient? (increase timeoutMs)
|
|
221
|
+
4. Is error message descriptive?
|
|
222
|
+
|
|
223
|
+
Report Format:
|
|
224
|
+
{
|
|
225
|
+
level: "LEVEL X",
|
|
226
|
+
passed: X,
|
|
227
|
+
failed: Y,
|
|
228
|
+
total: Z,
|
|
229
|
+
failures: [{test: "name", error: "message"}]
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
232
|
+
/**
|
|
233
|
+
* Real-world usage examples
|
|
234
|
+
*/
|
|
235
|
+
export const realWorldExamples = [
|
|
236
|
+
{
|
|
237
|
+
scenario: "Extract product prices from e-commerce",
|
|
238
|
+
script: `
|
|
239
|
+
return Array.from(document.querySelectorAll('.price, [data-price], .product-price'))
|
|
240
|
+
.map(el => el.textContent.trim())
|
|
241
|
+
.filter(text => text.match(/\\$|โฌ|ยฃ/));
|
|
242
|
+
`
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
scenario: "Check if user is logged in",
|
|
246
|
+
script: `
|
|
247
|
+
return {
|
|
248
|
+
hasLoginButton: !!document.querySelector('[href*="login"], button:contains("Login")'),
|
|
249
|
+
hasUserMenu: !!document.querySelector('.user-menu, .profile-menu, [data-user]'),
|
|
250
|
+
hasLogoutButton: !!document.querySelector('[href*="logout"], button:contains("Logout")')
|
|
251
|
+
};
|
|
252
|
+
`
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
scenario: "Get all image URLs",
|
|
256
|
+
script: `
|
|
257
|
+
return Array.from(document.querySelectorAll('img'))
|
|
258
|
+
.map(img => ({
|
|
259
|
+
src: img.src,
|
|
260
|
+
alt: img.alt,
|
|
261
|
+
width: img.naturalWidth,
|
|
262
|
+
height: img.naturalHeight
|
|
263
|
+
}))
|
|
264
|
+
.filter(img => img.width > 100);
|
|
265
|
+
`
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
scenario: "Inject console logger",
|
|
269
|
+
script: `
|
|
270
|
+
window.originalConsoleLog = console.log;
|
|
271
|
+
window.logHistory = [];
|
|
272
|
+
console.log = function(...args) {
|
|
273
|
+
window.logHistory.push(args);
|
|
274
|
+
window.originalConsoleLog.apply(console, args);
|
|
275
|
+
};
|
|
276
|
+
return 'Console logger injected. Access logs via window.logHistory';
|
|
277
|
+
`
|
|
278
|
+
}
|
|
279
|
+
];
|
|
280
|
+
//# sourceMappingURL=execute-script-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-script-tests.js","sourceRoot":"","sources":["../../src/tests/execute-script-tests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,kEAAkE;IAClE,+CAA+C;IAC/C,kEAAkE;IAClE;QACE,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,eAAe;QACvB,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,IAAI;KAChB;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE,iCAAiC;QACzC,cAAc,EAAE,aAAa;QAC7B,SAAS,EAAE,IAAI;KAChB;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,wBAAwB;Q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,EAAE,wCAAwC;QAClD,MAAM,EAAE;;;;KAIP;KACF;IACD;QACE,QAAQ,EAAE,4BAA4B;QACtC,MAAM,EAAE;;;;;;KAMP;KACF;IACD;QACE,QAAQ,EAAE,oBAAoB;QAC9B,MAAM,EAAE;;;;;;;;;KASP;KACF;IACD;QACE,QAAQ,EAAE,uBAAuB;QACjC,MAAM,EAAE;;;;;;;;KAQP;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-execute-tests.d.ts","sourceRoot":"","sources":["../../src/tests/run-execute-tests.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Automated Execute Script Testing
|
|
4
|
+
* Run this after building to verify execute_script works correctly
|
|
5
|
+
*/
|
|
6
|
+
import { executeScriptTests, testInstructions } from './execute-script-tests.js';
|
|
7
|
+
console.log('๐งช EXECUTE_SCRIPT TESTING SUITE');
|
|
8
|
+
console.log('โ'.repeat(80));
|
|
9
|
+
console.log('\n' + testInstructions + '\n');
|
|
10
|
+
console.log('โ'.repeat(80));
|
|
11
|
+
console.log('\n๐ TEST DEFINITIONS LOADED\n');
|
|
12
|
+
// Group tests by level
|
|
13
|
+
const testsByLevel = {
|
|
14
|
+
'LEVEL 1: BASIC EXPRESSIONS': [],
|
|
15
|
+
'LEVEL 2: DOM QUERIES (basic)': [],
|
|
16
|
+
'LEVEL 3: COMPLEX QUERIES': [],
|
|
17
|
+
'LEVEL 4: WINDOW OBJECT ACCESS': [],
|
|
18
|
+
'LEVEL 5: ASYNC OPERATIONS': [],
|
|
19
|
+
'LEVEL 6: ERROR HANDLING': []
|
|
20
|
+
};
|
|
21
|
+
let currentLevel = 'LEVEL 1: BASIC EXPRESSIONS';
|
|
22
|
+
executeScriptTests.forEach((test, index) => {
|
|
23
|
+
if (index === 6)
|
|
24
|
+
currentLevel = 'LEVEL 2: DOM QUERIES (basic)';
|
|
25
|
+
if (index === 9)
|
|
26
|
+
currentLevel = 'LEVEL 3: COMPLEX QUERIES';
|
|
27
|
+
if (index === 11)
|
|
28
|
+
currentLevel = 'LEVEL 4: WINDOW OBJECT ACCESS';
|
|
29
|
+
if (index === 13)
|
|
30
|
+
currentLevel = 'LEVEL 5: ASYNC OPERATIONS';
|
|
31
|
+
if (index === 15)
|
|
32
|
+
currentLevel = 'LEVEL 6: ERROR HANDLING';
|
|
33
|
+
testsByLevel[currentLevel].push(test);
|
|
34
|
+
});
|
|
35
|
+
// Print test summary
|
|
36
|
+
Object.entries(testsByLevel).forEach(([level, tests]) => {
|
|
37
|
+
console.log(`\n${level}`);
|
|
38
|
+
console.log('โ'.repeat(80));
|
|
39
|
+
tests.forEach((test, i) => {
|
|
40
|
+
const status = test.shouldFail ? 'โ ๏ธ ' : 'โ ';
|
|
41
|
+
console.log(` ${status}${i + 1}. ${test.name}`);
|
|
42
|
+
console.log(` Script: ${test.script.trim().substring(0, 60)}...`);
|
|
43
|
+
console.log(` Timeout: ${test.timeoutMs}ms`);
|
|
44
|
+
if (test.shouldFail) {
|
|
45
|
+
console.log(` Expected: Error (graceful failure)`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
console.log('\n\n' + 'โ'.repeat(80));
|
|
50
|
+
console.log('๐ TESTING INSTRUCTIONS');
|
|
51
|
+
console.log('โ'.repeat(80));
|
|
52
|
+
console.log(`
|
|
53
|
+
To run these tests manually with the MCP:
|
|
54
|
+
|
|
55
|
+
1. Start MCP server: npm run build && node dist/index.js
|
|
56
|
+
2. Connect via MCP client (VS Code Copilot)
|
|
57
|
+
3. Execute these commands in order:
|
|
58
|
+
|
|
59
|
+
# Setup
|
|
60
|
+
launch_chrome_with_profile()
|
|
61
|
+
navigate({ url: "https://example.com" })
|
|
62
|
+
wait_for_load_state({ state: "networkidle" })
|
|
63
|
+
|
|
64
|
+
# Run Level 1 tests (copy one by one)
|
|
65
|
+
execute_script({ script: "return 1 + 1;", timeoutMs: 5000 })
|
|
66
|
+
execute_script({ script: "return 'Hello' + ' ' + 'World';", timeoutMs: 5000 })
|
|
67
|
+
execute_script({ script: "return document.title;", timeoutMs: 5000 })
|
|
68
|
+
|
|
69
|
+
# ... etc
|
|
70
|
+
|
|
71
|
+
4. Record results in this format:
|
|
72
|
+
{
|
|
73
|
+
test: "Simple arithmetic",
|
|
74
|
+
expected: 2,
|
|
75
|
+
actual: 2,
|
|
76
|
+
success: true,
|
|
77
|
+
timeMs: 45
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
5. Report any failures with full error messages
|
|
81
|
+
|
|
82
|
+
AUTOMATED TESTING (if MCP client supports it):
|
|
83
|
+
You can also use the MCP programmatically to run all tests in sequence.
|
|
84
|
+
See the executeScriptTests array for the complete test suite.
|
|
85
|
+
`);
|
|
86
|
+
console.log('\nโ
Test definitions ready. Total tests: ' + executeScriptTests.length);
|
|
87
|
+
console.log('โ
To execute, run tests manually through MCP or use automated test runner\n');
|
|
88
|
+
//# sourceMappingURL=run-execute-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-execute-tests.js","sourceRoot":"","sources":["../../src/tests/run-execute-tests.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEjF,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AAC/C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5B,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAAC,CAAC;AAC5C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5B,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAE9C,uBAAuB;AACvB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