playwright 1.56.0-beta-1759527268000 → 1.57.0-alpha-2025-10-04
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/lib/index.js +2 -2
- package/lib/mcp/sdk/http.js +9 -2
- package/lib/mcp/sdk/mdb.js +2 -4
- package/lib/mcp/sdk/server.js +1 -2
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -89,8 +89,8 @@ const playwrightFixtures = {
|
|
|
89
89
|
await use(options);
|
|
90
90
|
playwright._defaultLaunchOptions = void 0;
|
|
91
91
|
}, { scope: "worker", auto: true, box: true }],
|
|
92
|
-
browser: [async ({ playwright, browserName, _browserOptions, connectOptions }, use
|
|
93
|
-
if (!["chromium", "firefox", "webkit"
|
|
92
|
+
browser: [async ({ playwright, browserName, _browserOptions, connectOptions }, use) => {
|
|
93
|
+
if (!["chromium", "firefox", "webkit"].includes(browserName))
|
|
94
94
|
throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);
|
|
95
95
|
if (connectOptions) {
|
|
96
96
|
const browser2 = await playwright[browserName].connect({
|
package/lib/mcp/sdk/http.js
CHANGED
|
@@ -67,11 +67,12 @@ function httpAddressToString(address) {
|
|
|
67
67
|
resolvedHost = "localhost";
|
|
68
68
|
return `http://${resolvedHost}:${resolvedPort}`;
|
|
69
69
|
}
|
|
70
|
-
async function installHttpTransport(httpServer, serverBackendFactory, allowedHosts) {
|
|
70
|
+
async function installHttpTransport(httpServer, serverBackendFactory, unguessableUrl, allowedHosts) {
|
|
71
71
|
const url = httpAddressToString(httpServer.address());
|
|
72
72
|
const host = new URL(url).host;
|
|
73
73
|
allowedHosts = (allowedHosts || [host]).map((h) => h.toLowerCase());
|
|
74
74
|
const allowAnyHost = allowedHosts.includes("*");
|
|
75
|
+
const pathPrefix = unguessableUrl ? `/${import_crypto.default.randomUUID()}` : "";
|
|
75
76
|
const sseSessions = /* @__PURE__ */ new Map();
|
|
76
77
|
const streamableSessions = /* @__PURE__ */ new Map();
|
|
77
78
|
httpServer.on("request", async (req, res) => {
|
|
@@ -86,7 +87,12 @@ async function installHttpTransport(httpServer, serverBackendFactory, allowedHos
|
|
|
86
87
|
return res.end("Access is only allowed at " + allowedHosts.join(", "));
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
if (!req.url?.startsWith(pathPrefix)) {
|
|
91
|
+
res.statusCode = 404;
|
|
92
|
+
return res.end("Not found");
|
|
93
|
+
}
|
|
94
|
+
const path = req.url?.slice(pathPrefix.length);
|
|
95
|
+
const url2 = new URL(`http://localhost${path}`);
|
|
90
96
|
if (url2.pathname === "/killkillkill" && req.method === "GET") {
|
|
91
97
|
res.statusCode = 200;
|
|
92
98
|
res.end("Killing process");
|
|
@@ -98,6 +104,7 @@ async function installHttpTransport(httpServer, serverBackendFactory, allowedHos
|
|
|
98
104
|
else
|
|
99
105
|
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
|
|
100
106
|
});
|
|
107
|
+
return `${url}${pathPrefix}`;
|
|
101
108
|
}
|
|
102
109
|
async function handleSSE(serverBackendFactory, req, res, url, sessions) {
|
|
103
110
|
if (req.method === "POST") {
|
package/lib/mcp/sdk/mdb.js
CHANGED
|
@@ -153,8 +153,7 @@ async function runOnPauseBackendLoop(backend, introMessage) {
|
|
|
153
153
|
create: () => wrappedBackend
|
|
154
154
|
};
|
|
155
155
|
const httpServer = await mcpHttp.startHttpServer({ port: 0 });
|
|
156
|
-
await mcpHttp.installHttpTransport(httpServer, factory);
|
|
157
|
-
const url = mcpHttp.httpAddressToString(httpServer.address());
|
|
156
|
+
const url = await mcpHttp.installHttpTransport(httpServer, factory, true);
|
|
158
157
|
const client = new mcpBundle.Client({ name: "Pushing client", version: "0.0.0" });
|
|
159
158
|
client.setRequestHandler(mcpBundle.PingRequestSchema, () => ({}));
|
|
160
159
|
const transport = new mcpBundle.StreamableHTTPClientTransport(new URL(process.env.PLAYWRIGHT_DEBUGGER_MCP));
|
|
@@ -175,8 +174,7 @@ async function runOnPauseBackendLoop(backend, introMessage) {
|
|
|
175
174
|
}
|
|
176
175
|
async function startAsHttp(backendFactory, options) {
|
|
177
176
|
const httpServer = await mcpHttp.startHttpServer(options);
|
|
178
|
-
await mcpHttp.installHttpTransport(httpServer, backendFactory);
|
|
179
|
-
return mcpHttp.httpAddressToString(httpServer.address());
|
|
177
|
+
return await mcpHttp.installHttpTransport(httpServer, backendFactory, true);
|
|
180
178
|
}
|
|
181
179
|
class ServerBackendWithCloseListener {
|
|
182
180
|
constructor(backend) {
|
package/lib/mcp/sdk/server.js
CHANGED
|
@@ -138,8 +138,7 @@ async function start(serverBackendFactory, options) {
|
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
const httpServer = await (0, import_http.startHttpServer)(options);
|
|
141
|
-
const url = (0, import_http.
|
|
142
|
-
await (0, import_http.installHttpTransport)(httpServer, serverBackendFactory, options.allowedHosts);
|
|
141
|
+
const url = await (0, import_http.installHttpTransport)(httpServer, serverBackendFactory, false, options.allowedHosts);
|
|
143
142
|
const mcpConfig = { mcpServers: {} };
|
|
144
143
|
mcpConfig.mcpServers[serverBackendFactory.nameInConfig] = {
|
|
145
144
|
url: `${url}/mcp`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0-alpha-2025-10-04",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"license": "Apache-2.0",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"playwright-core": "1.
|
|
67
|
+
"playwright-core": "1.57.0-alpha-2025-10-04"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|