@midscene/web 1.15.3 → 1.15.4-beta-20261013083552.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/dist/es/agent-tools-puppeteer.mjs +3 -2
- package/dist/es/agent-tools-puppeteer.mjs.map +1 -1
- package/dist/es/bridge-mode/io-client.mjs +1 -1
- package/dist/es/bridge-mode/io-server.mjs +2 -2
- package/dist/es/bridge-mode/io-server.mjs.map +1 -1
- package/dist/es/bridge-mode/page-browser-side.mjs +1 -1
- package/dist/es/bridge-mode/page-browser-side.mjs.map +1 -1
- package/dist/es/cli.mjs +1 -1
- package/dist/es/common/persistent-puppeteer-viewport.mjs +27 -0
- package/dist/es/common/persistent-puppeteer-viewport.mjs.map +1 -0
- package/dist/es/{playwright → common}/test-runner/cookies.mjs +56 -79
- package/dist/es/common/test-runner/cookies.mjs.map +1 -0
- package/dist/es/common/test-runner/driver.mjs +0 -0
- package/dist/es/common/test-runner/nodes.mjs +139 -0
- package/dist/es/common/test-runner/nodes.mjs.map +1 -0
- package/dist/es/common/test-runner/utils.mjs +24 -0
- package/dist/es/common/test-runner/utils.mjs.map +1 -0
- package/dist/es/playwright/test-runner/agent-nodes.mjs +3 -10
- package/dist/es/playwright/test-runner/agent-nodes.mjs.map +1 -1
- package/dist/es/playwright/test-runner/driver.mjs +42 -0
- package/dist/es/playwright/test-runner/driver.mjs.map +1 -0
- package/dist/es/playwright/test-runner/index.mjs +1 -4
- package/dist/es/playwright/test-runner/utils.mjs +1 -21
- package/dist/es/playwright/test-runner/utils.mjs.map +1 -1
- package/dist/es/puppeteer/browser-agent.mjs +9 -1
- package/dist/es/puppeteer/browser-agent.mjs.map +1 -1
- package/dist/es/puppeteer/page-agent.mjs +19 -1
- package/dist/es/puppeteer/page-agent.mjs.map +1 -1
- package/dist/es/puppeteer/test-runner/agent-nodes.mjs +6 -0
- package/dist/es/puppeteer/test-runner/agent-nodes.mjs.map +1 -0
- package/dist/es/puppeteer/test-runner/driver.mjs +44 -0
- package/dist/es/puppeteer/test-runner/driver.mjs.map +1 -0
- package/dist/es/puppeteer/test-runner/index.mjs +3 -0
- package/dist/es/puppeteer/test-runner/types.mjs +0 -0
- package/dist/es/puppeteer/test-runner/utils.mjs +8 -0
- package/dist/es/puppeteer/test-runner/utils.mjs.map +1 -0
- package/dist/lib/agent-tools-puppeteer.js +3 -2
- package/dist/lib/agent-tools-puppeteer.js.map +1 -1
- package/dist/lib/bridge-mode/io-client.js +1 -1
- package/dist/lib/bridge-mode/io-server.js +2 -2
- package/dist/lib/bridge-mode/io-server.js.map +1 -1
- package/dist/lib/bridge-mode/page-browser-side.js +1 -1
- package/dist/lib/bridge-mode/page-browser-side.js.map +1 -1
- package/dist/lib/cli.js +1 -1
- package/dist/lib/common/persistent-puppeteer-viewport.js +61 -0
- package/dist/lib/common/persistent-puppeteer-viewport.js.map +1 -0
- package/dist/lib/{playwright → common}/test-runner/cookies.js +58 -81
- package/dist/lib/common/test-runner/cookies.js.map +1 -0
- package/dist/lib/common/test-runner/driver.js +20 -0
- package/dist/lib/common/test-runner/driver.js.map +1 -0
- package/dist/lib/common/test-runner/nodes.js +185 -0
- package/dist/lib/common/test-runner/nodes.js.map +1 -0
- package/dist/lib/common/test-runner/utils.js +61 -0
- package/dist/lib/common/test-runner/utils.js.map +1 -0
- package/dist/lib/playwright/test-runner/agent-nodes.js +3 -10
- package/dist/lib/playwright/test-runner/agent-nodes.js.map +1 -1
- package/dist/lib/playwright/test-runner/driver.js +76 -0
- package/dist/lib/playwright/test-runner/driver.js.map +1 -0
- package/dist/lib/playwright/test-runner/index.js +5 -8
- package/dist/lib/playwright/test-runner/utils.js +4 -24
- package/dist/lib/playwright/test-runner/utils.js.map +1 -1
- package/dist/lib/puppeteer/browser-agent.js +9 -1
- package/dist/lib/puppeteer/browser-agent.js.map +1 -1
- package/dist/lib/puppeteer/page-agent.js +19 -1
- package/dist/lib/puppeteer/page-agent.js.map +1 -1
- package/dist/lib/puppeteer/test-runner/agent-nodes.js +40 -0
- package/dist/lib/puppeteer/test-runner/agent-nodes.js.map +1 -0
- package/dist/lib/puppeteer/test-runner/driver.js +78 -0
- package/dist/lib/puppeteer/test-runner/driver.js.map +1 -0
- package/dist/lib/puppeteer/test-runner/index.js +51 -0
- package/dist/lib/puppeteer/test-runner/index.js.map +1 -0
- package/dist/lib/puppeteer/test-runner/types.js +20 -0
- package/dist/lib/puppeteer/test-runner/types.js.map +1 -0
- package/dist/lib/puppeteer/test-runner/utils.js +48 -0
- package/dist/lib/puppeteer/test-runner/utils.js.map +1 -0
- package/dist/types/agent-tools-puppeteer.d.ts.map +1 -1
- package/dist/types/common/persistent-puppeteer-viewport.d.ts +5 -0
- package/dist/types/common/persistent-puppeteer-viewport.d.ts.map +1 -0
- package/dist/types/common/test-runner/cookies.d.ts +52 -0
- package/dist/types/common/test-runner/cookies.d.ts.map +1 -0
- package/dist/types/common/test-runner/driver.d.ts +38 -0
- package/dist/types/common/test-runner/driver.d.ts.map +1 -0
- package/dist/types/common/test-runner/nodes.d.ts +38 -0
- package/dist/types/common/test-runner/nodes.d.ts.map +1 -0
- package/dist/types/common/test-runner/utils.d.ts +3 -0
- package/dist/types/common/test-runner/utils.d.ts.map +1 -0
- package/dist/types/playwright/test-runner/agent-nodes.d.ts +1 -2
- package/dist/types/playwright/test-runner/agent-nodes.d.ts.map +1 -1
- package/dist/types/playwright/test-runner/driver.d.ts +4 -0
- package/dist/types/playwright/test-runner/driver.d.ts.map +1 -0
- package/dist/types/playwright/test-runner/index.d.ts +2 -8
- package/dist/types/playwright/test-runner/index.d.ts.map +1 -1
- package/dist/types/playwright/test-runner/types.d.ts +5 -14
- package/dist/types/playwright/test-runner/types.d.ts.map +1 -1
- package/dist/types/playwright/test-runner/utils.d.ts +1 -2
- package/dist/types/playwright/test-runner/utils.d.ts.map +1 -1
- package/dist/types/puppeteer/browser-agent.d.ts +5 -0
- package/dist/types/puppeteer/browser-agent.d.ts.map +1 -1
- package/dist/types/puppeteer/index.d.ts +1 -1
- package/dist/types/puppeteer/index.d.ts.map +1 -1
- package/dist/types/puppeteer/page-agent.d.ts +8 -1
- package/dist/types/puppeteer/page-agent.d.ts.map +1 -1
- package/dist/types/puppeteer/test-runner/agent-nodes.d.ts +2 -0
- package/dist/types/puppeteer/test-runner/agent-nodes.d.ts.map +1 -0
- package/dist/types/puppeteer/test-runner/driver.d.ts +4 -0
- package/dist/types/puppeteer/test-runner/driver.d.ts.map +1 -0
- package/dist/types/puppeteer/test-runner/index.d.ts +5 -0
- package/dist/types/puppeteer/test-runner/index.d.ts.map +1 -0
- package/dist/types/puppeteer/test-runner/types.d.ts +18 -0
- package/dist/types/puppeteer/test-runner/types.d.ts.map +1 -0
- package/dist/types/puppeteer/test-runner/utils.d.ts +4 -0
- package/dist/types/puppeteer/test-runner/utils.d.ts.map +1 -0
- package/package.json +9 -4
- package/dist/es/playwright/test-runner/clear-cookies.mjs +0 -45
- package/dist/es/playwright/test-runner/clear-cookies.mjs.map +0 -1
- package/dist/es/playwright/test-runner/cookies.mjs.map +0 -1
- package/dist/es/playwright/test-runner/goto-url.mjs +0 -60
- package/dist/es/playwright/test-runner/goto-url.mjs.map +0 -1
- package/dist/es/playwright/test-runner/viewport.mjs +0 -35
- package/dist/es/playwright/test-runner/viewport.mjs.map +0 -1
- package/dist/lib/playwright/test-runner/clear-cookies.js +0 -82
- package/dist/lib/playwright/test-runner/clear-cookies.js.map +0 -1
- package/dist/lib/playwright/test-runner/cookies.js.map +0 -1
- package/dist/lib/playwright/test-runner/goto-url.js +0 -97
- package/dist/lib/playwright/test-runner/goto-url.js.map +0 -1
- package/dist/lib/playwright/test-runner/viewport.js +0 -72
- package/dist/lib/playwright/test-runner/viewport.js.map +0 -1
- package/dist/types/playwright/test-runner/clear-cookies.d.ts +0 -17
- package/dist/types/playwright/test-runner/clear-cookies.d.ts.map +0 -1
- package/dist/types/playwright/test-runner/cookies.d.ts +0 -33
- package/dist/types/playwright/test-runner/cookies.d.ts.map +0 -1
- package/dist/types/playwright/test-runner/goto-url.d.ts +0 -26
- package/dist/types/playwright/test-runner/goto-url.d.ts.map +0 -1
- package/dist/types/playwright/test-runner/viewport.d.ts +0 -14
- package/dist/types/playwright/test-runner/viewport.d.ts.map +0 -1
|
@@ -24,7 +24,7 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
27
|
+
resolveCookieInput: ()=>resolveCookieInput,
|
|
28
28
|
setCookiesInputSchema: ()=>setCookiesInputSchema
|
|
29
29
|
});
|
|
30
30
|
const promises_namespaceObject = require("node:fs/promises");
|
|
@@ -32,9 +32,9 @@ const external_node_path_namespaceObject = require("node:path");
|
|
|
32
32
|
const v4_namespaceObject = require("zod/v4");
|
|
33
33
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
34
34
|
const setCookiesInputSchema = v4_namespaceObject.z.strictObject({
|
|
35
|
-
cookiesEnv: v4_namespaceObject.z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).optional().describe('The environment variable containing a Cookie header, cookie array JSON, or
|
|
35
|
+
cookiesEnv: v4_namespaceObject.z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).optional().describe('The environment variable containing a Cookie header, cookie array JSON, or browser storage-state JSON.'),
|
|
36
36
|
profile: v4_namespaceObject.z.string().regex(/\S/).optional().describe('A cookie profile resolved by getCookieProfile().'),
|
|
37
|
-
storageStatePath: v4_namespaceObject.z.string().regex(/\S/).optional().describe('A path to a
|
|
37
|
+
storageStatePath: v4_namespaceObject.z.string().regex(/\S/).optional().describe('A path to a browser storage-state JSON file.'),
|
|
38
38
|
url: v4_namespaceObject.z.string().url().optional().describe('The HTTP(S) URL used to scope Cookie-header values or cookies without domain/path.')
|
|
39
39
|
}).superRefine((input, ctx)=>{
|
|
40
40
|
const sourceCount = [
|
|
@@ -86,48 +86,6 @@ const parseCookieJson = (raw)=>{
|
|
|
86
86
|
throw new TypeError('setCookies source must contain valid JSON or a Cookie header.');
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
-
const resolveCookieSource = async (reference, defaultUrl, ctx, options)=>{
|
|
90
|
-
switch(reference.kind){
|
|
91
|
-
case 'env':
|
|
92
|
-
{
|
|
93
|
-
let env;
|
|
94
|
-
try {
|
|
95
|
-
env = await options.getEnv?.(ctx) ?? process.env;
|
|
96
|
-
} catch {
|
|
97
|
-
throw new Error(`Failed to resolve cookie environment ${reference.name}; the original error was redacted because it may contain cookie values.`);
|
|
98
|
-
}
|
|
99
|
-
const raw = env[reference.name];
|
|
100
|
-
if (!raw?.trim()) throw new Error(`Environment variable ${reference.name} is missing or blank.`);
|
|
101
|
-
const trimmed = raw.trim();
|
|
102
|
-
return {
|
|
103
|
-
reference,
|
|
104
|
-
cookies: /^[\[{]/.test(trimmed) ? parseCookieJson(trimmed) : parseCookieHeader(trimmed, defaultUrl)
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
case 'profile':
|
|
108
|
-
if (!options.getCookieProfile) throw new Error('setCookies.profile requires a configured getCookieProfile callback.');
|
|
109
|
-
try {
|
|
110
|
-
return {
|
|
111
|
-
reference,
|
|
112
|
-
cookies: await options.getCookieProfile({
|
|
113
|
-
profile: reference.name,
|
|
114
|
-
context: ctx.context,
|
|
115
|
-
signal: ctx.signal
|
|
116
|
-
})
|
|
117
|
-
};
|
|
118
|
-
} catch {
|
|
119
|
-
throw new Error(`Failed to resolve cookie profile ${reference.name}; the original error was redacted because it may contain cookie values.`);
|
|
120
|
-
}
|
|
121
|
-
case 'storage-state':
|
|
122
|
-
{
|
|
123
|
-
const path = options.resolveStorageStatePath ? await options.resolveStorageStatePath(reference.name, ctx) : (0, external_node_path_namespaceObject.resolve)(process.cwd(), reference.name);
|
|
124
|
-
return {
|
|
125
|
-
reference,
|
|
126
|
-
cookies: parseCookieJson(await (0, promises_namespaceObject.readFile)(path, 'utf8'))
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
89
|
const normalizeCookie = (candidate, defaultUrl, index)=>{
|
|
132
90
|
if (!candidate || 'object' != typeof candidate || Array.isArray(candidate)) throw new TypeError(`setCookies cookie at index ${index} must be an object.`);
|
|
133
91
|
const cookie = candidate;
|
|
@@ -151,46 +109,65 @@ const normalizeCookies = (source, defaultUrl)=>{
|
|
|
151
109
|
if (0 === candidates.length) throw new TypeError('setCookies source contains no cookies.');
|
|
152
110
|
return candidates.map((cookie, index)=>normalizeCookie(cookie, defaultUrl, index));
|
|
153
111
|
};
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
112
|
+
const resolveCookieInput = async (input, ctx, options)=>{
|
|
113
|
+
const defaultUrl = void 0 === input.url ? void 0 : (0, external_utils_js_namespaceObject.resolveWebUrl)(input.url, void 0, 'setCookies.url');
|
|
114
|
+
const reference = toCookieSourceReference(input);
|
|
115
|
+
let source;
|
|
116
|
+
switch(reference.kind){
|
|
117
|
+
case 'env':
|
|
118
|
+
{
|
|
119
|
+
let env;
|
|
120
|
+
try {
|
|
121
|
+
env = await options.getEnv?.(ctx) ?? process.env;
|
|
122
|
+
} catch {
|
|
123
|
+
throw new Error(`Failed to resolve cookie environment ${reference.name}; the original error was redacted because it may contain cookie values.`);
|
|
124
|
+
}
|
|
125
|
+
const raw = env[reference.name];
|
|
126
|
+
if (!raw?.trim()) throw new Error(`Environment variable ${reference.name} is missing or blank.`);
|
|
127
|
+
const trimmed = raw.trim();
|
|
128
|
+
source = /^[\[{]/.test(trimmed) ? parseCookieJson(trimmed) : parseCookieHeader(trimmed, defaultUrl);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case 'profile':
|
|
132
|
+
if (!options.getCookieProfile) throw new Error('setCookies.profile requires a configured getCookieProfile callback.');
|
|
133
|
+
try {
|
|
134
|
+
source = await options.getCookieProfile({
|
|
135
|
+
profile: reference.name,
|
|
136
|
+
context: ctx.context,
|
|
137
|
+
signal: ctx.signal
|
|
138
|
+
});
|
|
139
|
+
} catch {
|
|
140
|
+
throw new Error(`Failed to resolve cookie profile ${reference.name}; the original error was redacted because it may contain cookie values.`);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case 'storage-state':
|
|
144
|
+
{
|
|
145
|
+
let contents;
|
|
146
|
+
try {
|
|
147
|
+
const path = options.resolveStorageStatePath ? await options.resolveStorageStatePath(reference.name, ctx) : (0, external_node_path_namespaceObject.resolve)(process.cwd(), reference.name);
|
|
148
|
+
contents = await (0, promises_namespaceObject.readFile)(path, 'utf8');
|
|
149
|
+
} catch {
|
|
150
|
+
throw new Error(`Failed to read cookie storage state ${reference.name}; the original error was redacted because it may contain cookie values.`);
|
|
151
|
+
}
|
|
152
|
+
source = parseCookieJson(contents);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
187
155
|
}
|
|
156
|
+
const cookies = normalizeCookies(source, defaultUrl);
|
|
157
|
+
return {
|
|
158
|
+
cookies,
|
|
159
|
+
result: {
|
|
160
|
+
source: reference.kind,
|
|
161
|
+
sourceName: reference.name,
|
|
162
|
+
count: cookies.length
|
|
163
|
+
}
|
|
164
|
+
};
|
|
188
165
|
};
|
|
166
|
+
exports.resolveCookieInput = __webpack_exports__.resolveCookieInput;
|
|
189
167
|
exports.setCookiesInputSchema = __webpack_exports__.setCookiesInputSchema;
|
|
190
|
-
exports.setCookiesNode = __webpack_exports__.setCookiesNode;
|
|
191
168
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
192
|
-
"
|
|
193
|
-
"
|
|
169
|
+
"resolveCookieInput",
|
|
170
|
+
"setCookiesInputSchema"
|
|
194
171
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
195
172
|
Object.defineProperty(exports, '__esModule', {
|
|
196
173
|
value: true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common/test-runner/cookies.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/common/test-runner/cookies.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { readFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { z } from 'zod/v4';\nimport { resolveWebUrl } from './utils';\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport type CookieSourceReference =\n | { kind: 'env'; name: string }\n | { kind: 'profile'; name: string }\n | { kind: 'storage-state'; name: string };\n\nexport interface WebNodeContext<TContext> {\n input: unknown;\n context: TContext;\n signal: AbortSignal;\n}\n\nexport interface CookieProfileContext<TContext> {\n profile: string;\n context: TContext;\n signal: AbortSignal;\n}\n\nexport interface WebCookieSourceOptions<TAgent> {\n getEnv?(\n ctx: WebNodeContext<TAgent>,\n ): Awaitable<Readonly<Record<string, string | undefined>>>;\n getCookieProfile?(input: CookieProfileContext<TAgent>): Awaitable<unknown>;\n resolveStorageStatePath?(\n path: string,\n ctx: WebNodeContext<TAgent>,\n ): Awaitable<string>;\n}\n\nexport interface PortableWebCookie extends Record<string, unknown> {\n name: string;\n value: string;\n url?: string;\n domain?: string;\n path?: string;\n}\n\nexport const setCookiesInputSchema = z\n .strictObject({\n cookiesEnv: z\n .string()\n .regex(/^[A-Za-z_][A-Za-z0-9_]*$/)\n .optional()\n .describe(\n 'The environment variable containing a Cookie header, cookie array JSON, or browser storage-state JSON.',\n ),\n profile: z\n .string()\n .regex(/\\S/)\n .optional()\n .describe('A cookie profile resolved by getCookieProfile().'),\n storageStatePath: z\n .string()\n .regex(/\\S/)\n .optional()\n .describe('A path to a browser storage-state JSON file.'),\n url: z\n .string()\n .url()\n .optional()\n .describe(\n 'The HTTP(S) URL used to scope Cookie-header values or cookies without domain/path.',\n ),\n })\n .superRefine((input, ctx) => {\n const sourceCount = [\n input.cookiesEnv,\n input.profile,\n input.storageStatePath,\n ].filter((value) => value !== undefined).length;\n if (sourceCount !== 1) {\n ctx.addIssue({\n code: 'custom',\n message:\n 'exactly one of cookiesEnv, profile, and storageStatePath is required',\n });\n }\n });\n\nexport type SetCookiesNodeInput = z.infer<typeof setCookiesInputSchema>;\n\nexport interface SetCookiesNodeResult {\n source: CookieSourceReference['kind'];\n sourceName: string;\n count: number;\n}\n\nconst toCookieSourceReference = (\n input: SetCookiesNodeInput,\n): CookieSourceReference => {\n if (input.cookiesEnv !== undefined) {\n return { kind: 'env', name: input.cookiesEnv };\n }\n if (input.profile !== undefined) {\n return { kind: 'profile', name: input.profile };\n }\n if (input.storageStatePath !== undefined) {\n return { kind: 'storage-state', name: input.storageStatePath };\n }\n throw new TypeError('setCookies requires one cookie source.');\n};\n\nconst parseCookieHeader = (raw: string, url: string | undefined) => {\n if (url === undefined) {\n throw new TypeError(\n 'setCookies.url is required when cookiesEnv contains a Cookie header.',\n );\n }\n const segments = raw\n .split(';')\n .map((segment) => segment.trim())\n .filter(Boolean);\n if (segments.length === 0) {\n throw new TypeError('setCookies Cookie header contains no cookies.');\n }\n return segments.map((segment) => {\n const separator = segment.indexOf('=');\n if (separator <= 0) {\n throw new TypeError(\n 'setCookies Cookie header contains an invalid name/value pair.',\n );\n }\n const name = segment.slice(0, separator).trim();\n const value = segment.slice(separator + 1).trim();\n if (!name) {\n throw new TypeError('setCookies Cookie header contains an empty name.');\n }\n return { name, value, url } satisfies PortableWebCookie;\n });\n};\n\nconst parseCookieJson = (raw: string): unknown => {\n try {\n return JSON.parse(raw);\n } catch {\n throw new TypeError(\n 'setCookies source must contain valid JSON or a Cookie header.',\n );\n }\n};\n\nconst normalizeCookie = (\n candidate: unknown,\n defaultUrl: string | undefined,\n index: number,\n): PortableWebCookie => {\n if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {\n throw new TypeError(\n `setCookies cookie at index ${index} must be an object.`,\n );\n }\n const cookie = candidate as Record<string, unknown>;\n if (typeof cookie.name !== 'string' || !cookie.name.trim()) {\n throw new TypeError(\n `setCookies cookie at index ${index} requires a non-blank name.`,\n );\n }\n if (typeof cookie.value !== 'string') {\n throw new TypeError(\n `setCookies cookie at index ${index} requires a string value.`,\n );\n }\n\n const normalized = { ...cookie } as PortableWebCookie;\n const hasUrl = typeof cookie.url === 'string' && cookie.url.length > 0;\n const hasDomain =\n typeof cookie.domain === 'string' && cookie.domain.length > 0;\n if (!hasUrl && !hasDomain) {\n if (defaultUrl === undefined) {\n throw new TypeError(\n `setCookies cookie at index ${index} requires url or domain, or setCookies.url must be provided.`,\n );\n }\n normalized.url = defaultUrl;\n }\n if (hasDomain && typeof cookie.path !== 'string') normalized.path = '/';\n return normalized;\n};\n\nconst normalizeCookies = (\n source: unknown,\n defaultUrl: string | undefined,\n): PortableWebCookie[] => {\n const candidates = Array.isArray(source)\n ? source\n : source &&\n typeof source === 'object' &&\n Array.isArray((source as { cookies?: unknown }).cookies)\n ? (source as { cookies: unknown[] }).cookies\n : undefined;\n if (!candidates) {\n throw new TypeError(\n 'setCookies JSON must be a cookie array or an object with a cookies array.',\n );\n }\n if (candidates.length === 0) {\n throw new TypeError('setCookies source contains no cookies.');\n }\n return candidates.map((cookie, index) =>\n normalizeCookie(cookie, defaultUrl, index),\n );\n};\n\nexport const resolveCookieInput = async <TAgent>(\n input: SetCookiesNodeInput,\n ctx: WebNodeContext<TAgent>,\n options: WebCookieSourceOptions<TAgent>,\n): Promise<{\n cookies: PortableWebCookie[];\n result: SetCookiesNodeResult;\n}> => {\n const defaultUrl =\n input.url === undefined\n ? undefined\n : resolveWebUrl(input.url, undefined, 'setCookies.url');\n const reference = toCookieSourceReference(input);\n let source: unknown;\n switch (reference.kind) {\n case 'env': {\n let env: Readonly<Record<string, string | undefined>>;\n try {\n env = (await options.getEnv?.(ctx)) ?? process.env;\n } catch {\n throw new Error(\n `Failed to resolve cookie environment ${reference.name}; the original error was redacted because it may contain cookie values.`,\n );\n }\n const raw = env[reference.name];\n if (!raw?.trim()) {\n throw new Error(\n `Environment variable ${reference.name} is missing or blank.`,\n );\n }\n const trimmed = raw.trim();\n source = /^[\\[{]/.test(trimmed)\n ? parseCookieJson(trimmed)\n : parseCookieHeader(trimmed, defaultUrl);\n break;\n }\n case 'profile': {\n if (!options.getCookieProfile) {\n throw new Error(\n 'setCookies.profile requires a configured getCookieProfile callback.',\n );\n }\n try {\n source = await options.getCookieProfile({\n profile: reference.name,\n context: ctx.context,\n signal: ctx.signal,\n });\n } catch {\n throw new Error(\n `Failed to resolve cookie profile ${reference.name}; the original error was redacted because it may contain cookie values.`,\n );\n }\n break;\n }\n case 'storage-state': {\n let contents: string;\n try {\n const path = options.resolveStorageStatePath\n ? await options.resolveStorageStatePath(reference.name, ctx)\n : resolve(process.cwd(), reference.name);\n contents = await readFile(path, 'utf8');\n } catch {\n throw new Error(\n `Failed to read cookie storage state ${reference.name}; the original error was redacted because it may contain cookie values.`,\n );\n }\n source = parseCookieJson(contents);\n break;\n }\n }\n const cookies = normalizeCookies(source, defaultUrl);\n return {\n cookies,\n result: {\n source: reference.kind,\n sourceName: reference.name,\n count: cookies.length,\n },\n };\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","setCookiesInputSchema","z","input","ctx","sourceCount","value","undefined","toCookieSourceReference","TypeError","parseCookieHeader","raw","url","segments","segment","Boolean","separator","name","parseCookieJson","JSON","normalizeCookie","candidate","defaultUrl","index","Array","cookie","normalized","hasUrl","hasDomain","normalizeCookies","source","candidates","resolveCookieInput","options","resolveWebUrl","reference","env","process","Error","trimmed","contents","path","resolve","readFile","cookies"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;ACqCO,MAAMI,wBAAwBC,mBAAAA,CAAAA,CAAAA,YACtB,CAAC;IACZ,YAAYA,mBAAAA,CAAAA,CAAAA,MACH,GACN,KAAK,CAAC,4BACN,QAAQ,GACR,QAAQ,CACP;IAEJ,SAASA,mBAAAA,CAAAA,CAAAA,MACA,GACN,KAAK,CAAC,MACN,QAAQ,GACR,QAAQ,CAAC;IACZ,kBAAkBA,mBAAAA,CAAAA,CAAAA,MACT,GACN,KA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ACvB,SAAS/B,IAAI,OAAO;oBACpB,QAAQA,IAAI,MAAM;gBACpB;YACF,EAAE,OAAM;gBACN,MAAM,IAAIkC,MACR,CAAC,iCAAiC,EAAEH,UAAU,IAAI,CAAC,uEAAuE,CAAC;YAE/H;YACA;QAEF,KAAK;YAAiB;gBACpB,IAAIK;gBACJ,IAAI;oBACF,MAAMC,OAAOR,QAAQ,uBAAuB,GACxC,MAAMA,QAAQ,uBAAuB,CAACE,UAAU,IAAI,EAAE/B,OACtDsC,AAAAA,IAAAA,mCAAAA,OAAAA,AAAAA,EAAQL,QAAQ,GAAG,IAAIF,UAAU,IAAI;oBACzCK,WAAW,MAAMG,AAAAA,IAAAA,yBAAAA,QAAAA,AAAAA,EAASF,MAAM;gBAClC,EAAE,OAAM;oBACN,MAAM,IAAIH,MACR,CAAC,oCAAoC,EAAEH,UAAU,IAAI,CAAC,uEAAuE,CAAC;gBAElI;gBACAL,SAASZ,gBAAgBsB;gBACzB;YACF;IACF;IACA,MAAMI,UAAUf,iBAAiBC,QAAQR;IACzC,OAAO;QACLsB;QACA,QAAQ;YACN,QAAQT,UAAU,IAAI;YACtB,YAAYA,UAAU,IAAI;YAC1B,OAAOS,QAAQ,MAAM;QACvB;IACF;AACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common/test-runner/driver.js","sources":["webpack/runtime/make_namespace_object"],"sourcesContent":["// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","Symbol","Object"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOC,UAA0BA,OAAO,WAAW,EACrDC,OAAO,cAAc,CAAC,UAASD,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEC,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createWebTestRunnerNodeDefinitions: ()=>createWebTestRunnerNodeDefinitions,
|
|
28
|
+
gotoUrlInputSchema: ()=>gotoUrlInputSchema,
|
|
29
|
+
setCookiesInputSchema: ()=>external_cookies_js_namespaceObject.setCookiesInputSchema,
|
|
30
|
+
setViewportSizeInputSchema: ()=>setViewportSizeInputSchema,
|
|
31
|
+
clearCookiesInputSchema: ()=>clearCookiesInputSchema
|
|
32
|
+
});
|
|
33
|
+
const v4_namespaceObject = require("zod/v4");
|
|
34
|
+
const external_cookies_js_namespaceObject = require("./cookies.js");
|
|
35
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
36
|
+
const DEFAULT_NAVIGATION_TIMEOUT_MS = 60000;
|
|
37
|
+
const DEFAULT_WAIT_UNTIL = 'domcontentloaded';
|
|
38
|
+
const gotoUrlInputSchema = v4_namespaceObject.z.strictObject({
|
|
39
|
+
url: v4_namespaceObject.z.string().min(1).describe('An absolute HTTP(S) URL or a path relative to testRunner.baseURL or the current page URL.'),
|
|
40
|
+
waitUntil: v4_namespaceObject.z["enum"]([
|
|
41
|
+
'commit',
|
|
42
|
+
'domcontentloaded',
|
|
43
|
+
'load',
|
|
44
|
+
'networkidle',
|
|
45
|
+
'networkidle0',
|
|
46
|
+
'networkidle2'
|
|
47
|
+
]).default(DEFAULT_WAIT_UNTIL).describe('The navigation lifecycle event. domcontentloaded, load, and networkidle are portable across browser drivers.'),
|
|
48
|
+
timeoutMs: v4_namespaceObject.z.number().positive().max(600000).default(DEFAULT_NAVIGATION_TIMEOUT_MS).describe('The navigation timeout in milliseconds.')
|
|
49
|
+
});
|
|
50
|
+
const clearCookiesInputSchema = v4_namespaceObject.z.strictObject({
|
|
51
|
+
name: v4_namespaceObject.z.string().regex(/\S/).optional().describe('Cookie name to clear.'),
|
|
52
|
+
domain: v4_namespaceObject.z.string().regex(/\S/).optional().describe('Cookie domain to clear.'),
|
|
53
|
+
path: v4_namespaceObject.z.string().regex(/\S/).optional().describe('Cookie path to clear.')
|
|
54
|
+
});
|
|
55
|
+
const setViewportSizeInputSchema = v4_namespaceObject.z.strictObject({
|
|
56
|
+
width: v4_namespaceObject.z.number().int().positive().describe('Viewport width in CSS pixels.'),
|
|
57
|
+
height: v4_namespaceObject.z.number().int().positive().describe('Viewport height in CSS pixels.')
|
|
58
|
+
});
|
|
59
|
+
const resolveNavigationUrl = (target, currentUrl, configuredBase)=>{
|
|
60
|
+
const trimmed = target.trim();
|
|
61
|
+
if (!trimmed) throw new TypeError('gotoUrl.url must not be blank.');
|
|
62
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(trimmed)) return (0, external_utils_js_namespaceObject.resolveWebUrl)(trimmed, void 0, 'gotoUrl.url');
|
|
63
|
+
if (void 0 !== configuredBase) return (0, external_utils_js_namespaceObject.resolveWebUrl)(trimmed, configuredBase, 'gotoUrl.url');
|
|
64
|
+
if (!/^https?:\/\//i.test(currentUrl)) throw new TypeError(`gotoUrl.url cannot resolve a relative URL from ${JSON.stringify(currentUrl)}. Use an absolute HTTP(S) URL for the first navigation or configure testRunner.baseURL.`);
|
|
65
|
+
return (0, external_utils_js_namespaceObject.resolveWebUrl)(trimmed, currentUrl, 'gotoUrl.url');
|
|
66
|
+
};
|
|
67
|
+
const createWebTestRunnerNodeDefinitions = (adapter)=>{
|
|
68
|
+
const gotoUrlNode = {
|
|
69
|
+
name: 'gotoUrl',
|
|
70
|
+
title: 'Open a Web URL',
|
|
71
|
+
description: 'Navigate the current browser Page to an absolute HTTP(S) URL or a path relative to testRunner.baseURL or the current page URL.',
|
|
72
|
+
stringInputKey: 'url',
|
|
73
|
+
inputSchema: gotoUrlInputSchema,
|
|
74
|
+
async execute (agent, input, executionContext) {
|
|
75
|
+
const runtimeAgent = adapter.requireAgent(agent);
|
|
76
|
+
const driver = adapter.createDriver(runtimeAgent);
|
|
77
|
+
(0, external_utils_js_namespaceObject.throwIfAborted)(executionContext.signal, 'gotoUrl');
|
|
78
|
+
const url = resolveNavigationUrl(input.url, driver.currentUrl(), adapter.getOptions(runtimeAgent)?.baseURL ?? driver.baseUrl());
|
|
79
|
+
const response = await driver.goto(url, {
|
|
80
|
+
waitUntil: input.waitUntil,
|
|
81
|
+
timeoutMs: input.timeoutMs
|
|
82
|
+
});
|
|
83
|
+
(0, external_utils_js_namespaceObject.throwIfAborted)(executionContext.signal, 'gotoUrl');
|
|
84
|
+
const result = {
|
|
85
|
+
url: driver.currentUrl(),
|
|
86
|
+
status: response.status,
|
|
87
|
+
title: await driver.title()
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
summary: `Navigated to ${result.url}`,
|
|
91
|
+
data: result
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const setCookiesNode = {
|
|
96
|
+
name: 'setCookies',
|
|
97
|
+
title: 'Set browser cookies',
|
|
98
|
+
description: 'Load cookies from an environment variable, configured profile, or browser storage-state file without persisting cookie values in workflow input or output.',
|
|
99
|
+
stringInputKey: false,
|
|
100
|
+
inputSchema: external_cookies_js_namespaceObject.setCookiesInputSchema,
|
|
101
|
+
async execute (agent, input, executionContext) {
|
|
102
|
+
const runtimeAgent = adapter.requireAgent(agent);
|
|
103
|
+
const driver = adapter.createDriver(runtimeAgent);
|
|
104
|
+
(0, external_utils_js_namespaceObject.throwIfAborted)(executionContext.signal, 'setCookies');
|
|
105
|
+
const { cookies, result } = await (0, external_cookies_js_namespaceObject.resolveCookieInput)(input, {
|
|
106
|
+
...executionContext,
|
|
107
|
+
input,
|
|
108
|
+
context: runtimeAgent
|
|
109
|
+
}, adapter.getOptions(runtimeAgent) ?? {});
|
|
110
|
+
(0, external_utils_js_namespaceObject.throwIfAborted)(executionContext.signal, 'setCookies');
|
|
111
|
+
try {
|
|
112
|
+
await driver.setCookies(cookies);
|
|
113
|
+
} catch {
|
|
114
|
+
throw new Error(`Failed to set ${cookies.length} browser cookie(s); the browser error was redacted because it may contain cookie values.`);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
summary: `Set ${result.count} browser cookie(s) from ${result.source} ${result.sourceName}`,
|
|
118
|
+
data: result
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const clearCookiesNode = {
|
|
123
|
+
name: 'clearCookies',
|
|
124
|
+
title: 'Clear browser cookies',
|
|
125
|
+
description: 'Clear all cookies from the current browser context, or only cookies matching name, domain, or path.',
|
|
126
|
+
stringInputKey: false,
|
|
127
|
+
inputSchema: clearCookiesInputSchema,
|
|
128
|
+
async execute (agent, input, executionContext) {
|
|
129
|
+
const runtimeAgent = adapter.requireAgent(agent);
|
|
130
|
+
const driver = adapter.createDriver(runtimeAgent);
|
|
131
|
+
(0, external_utils_js_namespaceObject.throwIfAborted)(executionContext.signal, 'clearCookies');
|
|
132
|
+
const filters = {
|
|
133
|
+
...input
|
|
134
|
+
};
|
|
135
|
+
await driver.clearCookies(filters);
|
|
136
|
+
const filterNames = Object.keys(filters);
|
|
137
|
+
return {
|
|
138
|
+
summary: 0 === filterNames.length ? 'Cleared all browser cookies' : `Cleared browser cookies matching ${filterNames.join(', ')}`,
|
|
139
|
+
data: {
|
|
140
|
+
filters
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const setViewportSizeNode = {
|
|
146
|
+
name: 'setViewportSize',
|
|
147
|
+
title: 'Set the browser viewport size',
|
|
148
|
+
description: 'Set the current browser Page viewport size in CSS pixels and return the effective size.',
|
|
149
|
+
stringInputKey: false,
|
|
150
|
+
inputSchema: setViewportSizeInputSchema,
|
|
151
|
+
async execute (agent, input, executionContext) {
|
|
152
|
+
const runtimeAgent = adapter.requireAgent(agent);
|
|
153
|
+
const driver = adapter.createDriver(runtimeAgent);
|
|
154
|
+
(0, external_utils_js_namespaceObject.throwIfAborted)(executionContext.signal, 'setViewportSize');
|
|
155
|
+
const viewport = await driver.setViewportSize(input);
|
|
156
|
+
return {
|
|
157
|
+
summary: `Set viewport to ${viewport.width}x${viewport.height}`,
|
|
158
|
+
data: viewport
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return [
|
|
163
|
+
gotoUrlNode,
|
|
164
|
+
setCookiesNode,
|
|
165
|
+
clearCookiesNode,
|
|
166
|
+
setViewportSizeNode
|
|
167
|
+
];
|
|
168
|
+
};
|
|
169
|
+
exports.clearCookiesInputSchema = __webpack_exports__.clearCookiesInputSchema;
|
|
170
|
+
exports.createWebTestRunnerNodeDefinitions = __webpack_exports__.createWebTestRunnerNodeDefinitions;
|
|
171
|
+
exports.gotoUrlInputSchema = __webpack_exports__.gotoUrlInputSchema;
|
|
172
|
+
exports.setCookiesInputSchema = __webpack_exports__.setCookiesInputSchema;
|
|
173
|
+
exports.setViewportSizeInputSchema = __webpack_exports__.setViewportSizeInputSchema;
|
|
174
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
175
|
+
"clearCookiesInputSchema",
|
|
176
|
+
"createWebTestRunnerNodeDefinitions",
|
|
177
|
+
"gotoUrlInputSchema",
|
|
178
|
+
"setCookiesInputSchema",
|
|
179
|
+
"setViewportSizeInputSchema"
|
|
180
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
181
|
+
Object.defineProperty(exports, '__esModule', {
|
|
182
|
+
value: true
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common/test-runner/nodes.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/common/test-runner/nodes.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { AgentTestRunnerNodeDefinition } from '@midscene/core/agent';\nimport { z } from 'zod/v4';\nimport {\n type SetCookiesNodeResult,\n resolveCookieInput,\n setCookiesInputSchema,\n} from './cookies';\nimport type {\n WebCookieFilters,\n WebTestDriverAdapter,\n WebTestRunnerOptions,\n WebViewportSize,\n} from './driver';\nimport { resolveWebUrl, throwIfAborted } from './utils';\n\nconst DEFAULT_NAVIGATION_TIMEOUT_MS = 60_000;\nconst DEFAULT_WAIT_UNTIL = 'domcontentloaded' as const;\n\nexport const gotoUrlInputSchema = z.strictObject({\n url: z\n .string()\n .min(1)\n .describe(\n 'An absolute HTTP(S) URL or a path relative to testRunner.baseURL or the current page URL.',\n ),\n waitUntil: z\n .enum([\n 'commit',\n 'domcontentloaded',\n 'load',\n 'networkidle',\n 'networkidle0',\n 'networkidle2',\n ])\n .default(DEFAULT_WAIT_UNTIL)\n .describe(\n 'The navigation lifecycle event. domcontentloaded, load, and networkidle are portable across browser drivers.',\n ),\n timeoutMs: z\n .number()\n .positive()\n .max(10 * 60_000)\n .default(DEFAULT_NAVIGATION_TIMEOUT_MS)\n .describe('The navigation timeout in milliseconds.'),\n});\n\nexport type GotoUrlNodeInput = z.infer<typeof gotoUrlInputSchema>;\n\nexport interface GotoUrlNodeResult {\n url: string;\n status: number | null;\n title: string;\n}\n\nexport const clearCookiesInputSchema = z.strictObject({\n name: z.string().regex(/\\S/).optional().describe('Cookie name to clear.'),\n domain: z.string().regex(/\\S/).optional().describe('Cookie domain to clear.'),\n path: z.string().regex(/\\S/).optional().describe('Cookie path to clear.'),\n});\n\nexport type ClearCookiesNodeInput = z.infer<typeof clearCookiesInputSchema>;\n\nexport const setViewportSizeInputSchema = z.strictObject({\n width: z.number().int().positive().describe('Viewport width in CSS pixels.'),\n height: z\n .number()\n .int()\n .positive()\n .describe('Viewport height in CSS pixels.'),\n});\n\nexport type SetViewportSizeNodeInput = z.infer<\n typeof setViewportSizeInputSchema\n>;\n\nconst resolveNavigationUrl = (\n target: string,\n currentUrl: string,\n configuredBase: string | undefined,\n): string => {\n const trimmed = target.trim();\n if (!trimmed) throw new TypeError('gotoUrl.url must not be blank.');\n if (/^[a-z][a-z\\d+.-]*:/i.test(trimmed)) {\n return resolveWebUrl(trimmed, undefined, 'gotoUrl.url');\n }\n if (configuredBase !== undefined) {\n return resolveWebUrl(trimmed, configuredBase, 'gotoUrl.url');\n }\n if (!/^https?:\\/\\//i.test(currentUrl)) {\n throw new TypeError(\n `gotoUrl.url cannot resolve a relative URL from ${JSON.stringify(currentUrl)}. Use an absolute HTTP(S) URL for the first navigation or configure testRunner.baseURL.`,\n );\n }\n return resolveWebUrl(trimmed, currentUrl, 'gotoUrl.url');\n};\n\n/** Create the browser-neutral built-in Web Nodes for one browser adapter. */\nexport const createWebTestRunnerNodeDefinitions = <\n TAgent,\n TOptions extends WebTestRunnerOptions<TAgent>,\n>(\n adapter: WebTestDriverAdapter<TAgent, TOptions>,\n): readonly AgentTestRunnerNodeDefinition[] => {\n const gotoUrlNode: AgentTestRunnerNodeDefinition<\n z.output<typeof gotoUrlInputSchema>,\n GotoUrlNodeResult\n > = {\n name: 'gotoUrl',\n title: 'Open a Web URL',\n description:\n 'Navigate the current browser Page to an absolute HTTP(S) URL or a path relative to testRunner.baseURL or the current page URL.',\n stringInputKey: 'url',\n inputSchema: gotoUrlInputSchema,\n async execute(agent, input, executionContext) {\n const runtimeAgent = adapter.requireAgent(agent);\n const driver = adapter.createDriver(runtimeAgent);\n throwIfAborted(executionContext.signal, 'gotoUrl');\n const url = resolveNavigationUrl(\n input.url,\n driver.currentUrl(),\n adapter.getOptions(runtimeAgent)?.baseURL ?? driver.baseUrl(),\n );\n const response = await driver.goto(url, {\n waitUntil: input.waitUntil,\n timeoutMs: input.timeoutMs,\n });\n throwIfAborted(executionContext.signal, 'gotoUrl');\n const result = {\n url: driver.currentUrl(),\n status: response.status,\n title: await driver.title(),\n };\n return { summary: `Navigated to ${result.url}`, data: result };\n },\n };\n\n const setCookiesNode: AgentTestRunnerNodeDefinition<\n z.output<typeof setCookiesInputSchema>,\n SetCookiesNodeResult\n > = {\n name: 'setCookies',\n title: 'Set browser cookies',\n description:\n 'Load cookies from an environment variable, configured profile, or browser storage-state file without persisting cookie values in workflow input or output.',\n stringInputKey: false,\n inputSchema: setCookiesInputSchema,\n async execute(agent, input, executionContext) {\n const runtimeAgent = adapter.requireAgent(agent);\n const driver = adapter.createDriver(runtimeAgent);\n throwIfAborted(executionContext.signal, 'setCookies');\n const { cookies, result } = await resolveCookieInput(\n input,\n { ...executionContext, input, context: runtimeAgent },\n adapter.getOptions(runtimeAgent) ?? {},\n );\n throwIfAborted(executionContext.signal, 'setCookies');\n try {\n await driver.setCookies(cookies);\n } catch {\n throw new Error(\n `Failed to set ${cookies.length} browser cookie(s); the browser error was redacted because it may contain cookie values.`,\n );\n }\n return {\n summary: `Set ${result.count} browser cookie(s) from ${result.source} ${result.sourceName}`,\n data: result,\n };\n },\n };\n\n const clearCookiesNode: AgentTestRunnerNodeDefinition<\n z.output<typeof clearCookiesInputSchema>,\n { filters: WebCookieFilters }\n > = {\n name: 'clearCookies',\n title: 'Clear browser cookies',\n description:\n 'Clear all cookies from the current browser context, or only cookies matching name, domain, or path.',\n stringInputKey: false,\n inputSchema: clearCookiesInputSchema,\n async execute(agent, input, executionContext) {\n const runtimeAgent = adapter.requireAgent(agent);\n const driver = adapter.createDriver(runtimeAgent);\n throwIfAborted(executionContext.signal, 'clearCookies');\n const filters: WebCookieFilters = { ...input };\n await driver.clearCookies(filters);\n const filterNames = Object.keys(filters);\n return {\n summary:\n filterNames.length === 0\n ? 'Cleared all browser cookies'\n : `Cleared browser cookies matching ${filterNames.join(', ')}`,\n data: { filters },\n };\n },\n };\n\n const setViewportSizeNode: AgentTestRunnerNodeDefinition<\n z.output<typeof setViewportSizeInputSchema>,\n WebViewportSize\n > = {\n name: 'setViewportSize',\n title: 'Set the browser viewport size',\n description:\n 'Set the current browser Page viewport size in CSS pixels and return the effective size.',\n stringInputKey: false,\n inputSchema: setViewportSizeInputSchema,\n async execute(agent, input, executionContext) {\n const runtimeAgent = adapter.requireAgent(agent);\n const driver = adapter.createDriver(runtimeAgent);\n throwIfAborted(executionContext.signal, 'setViewportSize');\n const viewport = await driver.setViewportSize(input);\n return {\n summary: `Set viewport to ${viewport.width}x${viewport.height}`,\n data: viewport,\n };\n },\n };\n\n return [gotoUrlNode, setCookiesNode, clearCookiesNode, setViewportSizeNode];\n};\n\nexport { setCookiesInputSchema };\nexport type { SetCookiesNodeInput, SetCookiesNodeResult } from './cookies';\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","DEFAULT_NAVIGATION_TIMEOUT_MS","DEFAULT_WAIT_UNTIL","gotoUrlInputSchema","z","clearCookiesInputSchema","setViewportSizeInputSchema","resolveNavigationUrl","target","currentUrl","configuredBase","trimmed","TypeError","resolveWebUrl","undefined","JSON","createWebTestRunnerNodeDefinitions","adapter","gotoUrlNode","agent","input","executionContext","runtimeAgent","driver","throwIfAborted","url","response","result","setCookiesNode","setCookiesInputSchema","cookies","resolveCookieInput","Error","clearCookiesNode","filters","filterNames","setViewportSizeNode","viewport"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD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,EAAEC,gBAAgB;YAC1C,MAAMC,eAAeL,QAAQ,YAAY,CAACE;YAC1C,MAAMI,SAASN,QAAQ,YAAY,CAACK;YACpCE,IAAAA,kCAAAA,cAAAA,AAAAA,EAAeH,iBAAiB,MAAM,EAAE;YACxC,MAAMa,UAA4B;gBAAE,GAAGd,KAAK;YAAC;YAC7C,MAAMG,OAAO,YAAY,CAACW;YAC1B,MAAMC,cAActC,OAAO,IAAI,CAACqC;YAChC,OAAO;gBACL,SACEC,AAAuB,MAAvBA,YAAY,MAAM,GACd,gCACA,CAAC,iCAAiC,EAAEA,YAAY,IAAI,CAAC,OAAO;gBAClE,MAAM;oBAAED;gBAAQ;YAClB;QACF;IACF;IAEA,MAAME,sBAGF;QACF,MAAM;QACN,OAAO;QACP,aACE;QACF,gBAAgB;QAChB,aAAa9B;QACb,MAAM,SAAQa,KAAK,EAAEC,KAAK,EAAEC,gBAAgB;YAC1C,MAAMC,eAAeL,QAAQ,YAAY,CAACE;YAC1C,MAAMI,SAASN,QAAQ,YAAY,CAACK;YACpCE,IAAAA,kCAAAA,cAAAA,AAAAA,EAAeH,iBAAiB,MAAM,EAAE;YACxC,MAAMgB,WAAW,MAAMd,OAAO,eAAe,CAACH;YAC9C,OAAO;gBACL,SAAS,CAAC,gBAAgB,EAAEiB,SAAS,KAAK,CAAC,CAAC,EAAEA,SAAS,MAAM,EAAE;gBAC/D,MAAMA;YACR;QACF;IACF;IAEA,OAAO;QAACnB;QAAaU;QAAgBK;QAAkBG;KAAoB;AAC7E"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
resolveWebUrl: ()=>resolveWebUrl,
|
|
28
|
+
throwIfAborted: ()=>throwIfAborted
|
|
29
|
+
});
|
|
30
|
+
const SUPPORTED_WEB_PROTOCOLS = new Set([
|
|
31
|
+
'http:',
|
|
32
|
+
'https:'
|
|
33
|
+
]);
|
|
34
|
+
const throwIfAborted = (signal, operation)=>{
|
|
35
|
+
if (signal.aborted) throw signal.reason ?? new Error(`${operation} aborted.`);
|
|
36
|
+
};
|
|
37
|
+
const resolveWebUrl = (target, baseUrl, label)=>{
|
|
38
|
+
const trimmed = target.trim();
|
|
39
|
+
if (!trimmed) throw new TypeError(`${label} must not be blank.`);
|
|
40
|
+
let resolved;
|
|
41
|
+
try {
|
|
42
|
+
resolved = void 0 === baseUrl ? new URL(trimmed) : new URL(trimmed, baseUrl);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new TypeError(void 0 === baseUrl ? `${label} must be an absolute HTTP(S) URL.` : `${label} is not a valid URL.`, {
|
|
45
|
+
cause: error
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (!SUPPORTED_WEB_PROTOCOLS.has(resolved.protocol)) throw new TypeError(`${label} does not support the ${resolved.protocol} protocol.`);
|
|
49
|
+
return resolved.toString();
|
|
50
|
+
};
|
|
51
|
+
exports.resolveWebUrl = __webpack_exports__.resolveWebUrl;
|
|
52
|
+
exports.throwIfAborted = __webpack_exports__.throwIfAborted;
|
|
53
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
54
|
+
"resolveWebUrl",
|
|
55
|
+
"throwIfAborted"
|
|
56
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
57
|
+
Object.defineProperty(exports, '__esModule', {
|
|
58
|
+
value: true
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common/test-runner/utils.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/common/test-runner/utils.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const SUPPORTED_WEB_PROTOCOLS = new Set(['http:', 'https:']);\n\nexport const throwIfAborted = (signal: AbortSignal, operation: string) => {\n if (signal.aborted) {\n throw signal.reason ?? new Error(`${operation} aborted.`);\n }\n};\n\nexport const resolveWebUrl = (\n target: string,\n baseUrl: string | undefined,\n label: string,\n): string => {\n const trimmed = target.trim();\n if (!trimmed) throw new TypeError(`${label} must not be blank.`);\n\n let resolved: URL;\n try {\n resolved =\n baseUrl === undefined ? new URL(trimmed) : new URL(trimmed, baseUrl);\n } catch (error) {\n throw new TypeError(\n baseUrl === undefined\n ? `${label} must be an absolute HTTP(S) URL.`\n : `${label} is not a valid URL.`,\n { cause: error },\n );\n }\n if (!SUPPORTED_WEB_PROTOCOLS.has(resolved.protocol)) {\n throw new TypeError(\n `${label} does not support the ${resolved.protocol} protocol.`,\n );\n }\n return resolved.toString();\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","SUPPORTED_WEB_PROTOCOLS","Set","throwIfAborted","signal","operation","Error","resolveWebUrl","target","baseUrl","label","trimmed","TypeError","resolved","undefined","URL","error"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;ACNA,MAAMI,0BAA0B,IAAIC,IAAI;IAAC;IAAS;CAAS;AAEpD,MAAMC,iBAAiB,CAACC,QAAqBC;IAClD,IAAID,OAAO,OAAO,EAChB,MAAMA,OAAO,MAAM,IAAI,IAAIE,MAAM,GAAGD,UAAU,SAAS,CAAC;AAE5D;AAEO,MAAME,gBAAgB,CAC3BC,QACAC,SACAC;IAEA,MAAMC,UAAUH,OAAO,IAAI;IAC3B,IAAI,CAACG,SAAS,MAAM,IAAIC,UAAU,GAAGF,MAAM,mBAAmB,CAAC;IAE/D,IAAIG;IACJ,IAAI;QACFA,WACEJ,AAAYK,WAAZL,UAAwB,IAAIM,IAAIJ,WAAW,IAAII,IAAIJ,SAASF;IAChE,EAAE,OAAOO,OAAO;QACd,MAAM,IAAIJ,UACRH,AAAYK,WAAZL,UACI,GAAGC,MAAM,iCAAiC,CAAC,GAC3C,GAAGA,MAAM,oBAAoB,CAAC,EAClC;YAAE,OAAOM;QAAM;IAEnB;IACA,IAAI,CAACf,wBAAwB,GAAG,CAACY,SAAS,QAAQ,GAChD,MAAM,IAAID,UACR,GAAGF,MAAM,sBAAsB,EAAEG,SAAS,QAAQ,CAAC,UAAU,CAAC;IAGlE,OAAOA,SAAS,QAAQ;AAC1B"}
|
|
@@ -26,16 +26,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
playwrightAgentTestRunnerNodeDefinitions: ()=>playwrightAgentTestRunnerNodeDefinitions
|
|
28
28
|
});
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const external_viewport_js_namespaceObject = require("./viewport.js");
|
|
33
|
-
const playwrightAgentTestRunnerNodeDefinitions = [
|
|
34
|
-
external_goto_url_js_namespaceObject.gotoUrlNode,
|
|
35
|
-
external_cookies_js_namespaceObject.setCookiesNode,
|
|
36
|
-
external_clear_cookies_js_namespaceObject.clearCookiesNode,
|
|
37
|
-
external_viewport_js_namespaceObject.setViewportSizeNode
|
|
38
|
-
];
|
|
29
|
+
const nodes_js_namespaceObject = require("../../common/test-runner/nodes.js");
|
|
30
|
+
const external_driver_js_namespaceObject = require("./driver.js");
|
|
31
|
+
const playwrightAgentTestRunnerNodeDefinitions = (0, nodes_js_namespaceObject.createWebTestRunnerNodeDefinitions)(external_driver_js_namespaceObject.playwrightTestDriverAdapter);
|
|
39
32
|
exports.playwrightAgentTestRunnerNodeDefinitions = __webpack_exports__.playwrightAgentTestRunnerNodeDefinitions;
|
|
40
33
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
41
34
|
"playwrightAgentTestRunnerNodeDefinitions"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright/test-runner/agent-nodes.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/playwright/test-runner/agent-nodes.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import
|
|
1
|
+
{"version":3,"file":"playwright/test-runner/agent-nodes.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/playwright/test-runner/agent-nodes.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { createWebTestRunnerNodeDefinitions } from '@/common/test-runner/nodes';\nimport { playwrightTestDriverAdapter } from './driver';\n\nexport const playwrightAgentTestRunnerNodeDefinitions =\n createWebTestRunnerNodeDefinitions(playwrightTestDriverAdapter);\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","playwrightAgentTestRunnerNodeDefinitions","createWebTestRunnerNodeDefinitions","playwrightTestDriverAdapter"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACHO,MAAMI,2CACXC,AAAAA,IAAAA,yBAAAA,kCAAAA,AAAAA,EAAmCC,mCAAAA,2BAA2BA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
playwrightTestDriverAdapter: ()=>playwrightTestDriverAdapter
|
|
28
|
+
});
|
|
29
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
30
|
+
const createPlaywrightDriver = (agent)=>{
|
|
31
|
+
const page = agent.interface.underlyingPage;
|
|
32
|
+
return {
|
|
33
|
+
currentUrl: ()=>page.url(),
|
|
34
|
+
baseUrl: ()=>{
|
|
35
|
+
const context = page.context();
|
|
36
|
+
return context._options?.baseURL;
|
|
37
|
+
},
|
|
38
|
+
async goto (url, options) {
|
|
39
|
+
if ('networkidle0' === options.waitUntil || 'networkidle2' === options.waitUntil) throw new TypeError(`Playwright does not support gotoUrl.waitUntil=${options.waitUntil}; use networkidle instead.`);
|
|
40
|
+
const response = await page.goto(url, {
|
|
41
|
+
waitUntil: options.waitUntil,
|
|
42
|
+
timeout: options.timeoutMs
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
status: response?.status() ?? null
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
title: ()=>page.title(),
|
|
49
|
+
setCookies: async (cookies)=>{
|
|
50
|
+
await page.context().addCookies(cookies);
|
|
51
|
+
},
|
|
52
|
+
clearCookies: async (filters)=>{
|
|
53
|
+
await page.context().clearCookies(filters);
|
|
54
|
+
},
|
|
55
|
+
setViewportSize: async (size)=>{
|
|
56
|
+
await page.setViewportSize(size);
|
|
57
|
+
const viewport = page.viewportSize();
|
|
58
|
+
if (!viewport) throw new Error('Playwright did not report an effective viewport size.');
|
|
59
|
+
return viewport;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const playwrightTestDriverAdapter = {
|
|
64
|
+
requireAgent: external_utils_js_namespaceObject.requirePlaywrightAgent,
|
|
65
|
+
createDriver: createPlaywrightDriver,
|
|
66
|
+
getOptions: (agent)=>agent.testRunner
|
|
67
|
+
};
|
|
68
|
+
exports.playwrightTestDriverAdapter = __webpack_exports__.playwrightTestDriverAdapter;
|
|
69
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
70
|
+
"playwrightTestDriverAdapter"
|
|
71
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
72
|
+
Object.defineProperty(exports, '__esModule', {
|
|
73
|
+
value: true
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=driver.js.map
|