playwright 1.57.0-alpha-2025-10-23 → 1.57.0-alpha-2025-10-25
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.
|
@@ -183,17 +183,6 @@ class Context {
|
|
|
183
183
|
const { browserContext } = await this._ensureBrowserContext();
|
|
184
184
|
return browserContext;
|
|
185
185
|
}
|
|
186
|
-
async setExtraHTTPHeaders(headers) {
|
|
187
|
-
if (!Object.keys(headers).length)
|
|
188
|
-
throw new Error("Please provide at least one header to set.");
|
|
189
|
-
for (const name of Object.keys(headers)) {
|
|
190
|
-
if (!name.trim())
|
|
191
|
-
throw new Error("Header names must be non-empty strings.");
|
|
192
|
-
}
|
|
193
|
-
this._extraHTTPHeaders = { ...headers };
|
|
194
|
-
const { browserContext } = await this._ensureBrowserContext();
|
|
195
|
-
await browserContext.setExtraHTTPHeaders(this._extraHTTPHeaders);
|
|
196
|
-
}
|
|
197
186
|
_ensureBrowserContext() {
|
|
198
187
|
if (!this._browserContextPromise) {
|
|
199
188
|
this._browserContextPromise = this._setupBrowserContext();
|
|
@@ -211,8 +200,6 @@ class Context {
|
|
|
211
200
|
const result = await this._browserContextFactory.createContext(this._clientInfo, this._abortController.signal, this._runningToolName);
|
|
212
201
|
const { browserContext } = result;
|
|
213
202
|
await this._setupRequestInterception(browserContext);
|
|
214
|
-
if (this._extraHTTPHeaders)
|
|
215
|
-
await browserContext.setExtraHTTPHeaders(this._extraHTTPHeaders);
|
|
216
203
|
if (this.sessionLog)
|
|
217
204
|
await InputRecorder.create(this, browserContext);
|
|
218
205
|
for (const page of browserContext.pages())
|
package/lib/mcp/browser/tools.js
CHANGED
|
@@ -44,7 +44,6 @@ var import_mouse = __toESM(require("./tools/mouse"));
|
|
|
44
44
|
var import_navigate = __toESM(require("./tools/navigate"));
|
|
45
45
|
var import_network = __toESM(require("./tools/network"));
|
|
46
46
|
var import_pdf = __toESM(require("./tools/pdf"));
|
|
47
|
-
var import_headers = __toESM(require("./tools/headers"));
|
|
48
47
|
var import_snapshot = __toESM(require("./tools/snapshot"));
|
|
49
48
|
var import_screenshot = __toESM(require("./tools/screenshot"));
|
|
50
49
|
var import_tabs = __toESM(require("./tools/tabs"));
|
|
@@ -62,7 +61,6 @@ const browserTools = [
|
|
|
62
61
|
...import_keyboard.default,
|
|
63
62
|
...import_navigate.default,
|
|
64
63
|
...import_network.default,
|
|
65
|
-
...import_headers.default,
|
|
66
64
|
...import_mouse.default,
|
|
67
65
|
...import_pdf.default,
|
|
68
66
|
...import_screenshot.default,
|
package/lib/mcp/program.js
CHANGED
|
@@ -40,7 +40,7 @@ var import_proxyBackend = require("./sdk/proxyBackend");
|
|
|
40
40
|
var import_browserServerBackend = require("./browser/browserServerBackend");
|
|
41
41
|
var import_extensionContextFactory = require("./extension/extensionContextFactory");
|
|
42
42
|
function decorateCommand(command, version) {
|
|
43
|
-
command.option("--allowed-hosts <hosts...>", "comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check.", import_config.commaSeparatedList).option("--allowed-origins <origins>", "semicolon-separated list of origins to allow the browser to request. Default is to allow all.", import_config.semicolonSeparatedList).option("--blocked-origins <origins>", "semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf
|
|
43
|
+
command.option("--allowed-hosts <hosts...>", "comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check.", import_config.commaSeparatedList).option("--allowed-origins <origins>", "semicolon-separated list of origins to allow the browser to request. Default is to allow all.", import_config.semicolonSeparatedList).option("--blocked-origins <origins>", "semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf.", import_config.commaSeparatedList).option("--cdp-endpoint <endpoint>", "CDP endpoint to connect to.").option("--cdp-header <headers...>", "CDP headers to send with the connect request, multiple can be specified.", import_config.headerParser).option("--config <path>", "path to the configuration file.").option("--device <device>", 'device to emulate, for example: "iPhone 15"').option("--executable-path <path>", "path to the browser executable.").option("--extension", 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').option("--grant-permissions <permissions...>", 'List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".', import_config.commaSeparatedList).option("--headless", "run browser in headless mode, headed by default").option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.").option("--ignore-https-errors", "ignore https errors").option("--init-script <path...>", "path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times.").option("--isolated", "keep the browser profile in memory, do not save it to disk.").option("--image-responses <mode>", 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".').option("--no-sandbox", "disable the sandbox for all process types that are normally sandboxed.").option("--output-dir <path>", "path to the directory for output files.").option("--port <port>", "port to listen on for SSE transport.").option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--save-session", "Whether to save the Playwright MCP session into the output directory.").option("--save-trace", "Whether to save the Playwright Trace of the session into the output directory.").option("--save-video <size>", 'Whether to save the video of the session into the output directory. For example "--save-video=800x600"', import_config.resolutionParser.bind(null, "--save-video")).option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--shared-browser-context", "reuse the same browser context between all connected HTTP clients.").option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--test-id-attribute <attribute>", 'specify the attribute to use for test ids, defaults to "data-testid"').option("--timeout-action <timeout>", "specify action timeout in milliseconds, defaults to 5000ms", import_config.numberParser).option("--timeout-navigation <timeout>", "specify navigation timeout in milliseconds, defaults to 60000ms", import_config.numberParser).option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <path>", "path to the user data directory. If not specified, a temporary directory will be created.").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280x720"', import_config.resolutionParser.bind(null, "--viewport-size")).addOption(new import_utilsBundle.ProgramOption("--connect-tool", "Allow to switch between different browser connection methods.").hideHelp()).addOption(new import_utilsBundle.ProgramOption("--vision", "Legacy option, use --caps=vision instead").hideHelp()).action(async (options) => {
|
|
44
44
|
(0, import_watchdog.setupExitWatchdog)();
|
|
45
45
|
if (options.vision) {
|
|
46
46
|
console.error("The --vision option is deprecated, use --caps=vision instead");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.57.0-alpha-2025-10-
|
|
3
|
+
"version": "1.57.0-alpha-2025-10-25",
|
|
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.57.0-alpha-2025-10-
|
|
67
|
+
"playwright-core": "1.57.0-alpha-2025-10-25"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var headers_exports = {};
|
|
20
|
-
__export(headers_exports, {
|
|
21
|
-
default: () => headers_default
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(headers_exports);
|
|
24
|
-
var import_bundle = require("../../sdk/bundle");
|
|
25
|
-
var import_tool = require("./tool");
|
|
26
|
-
const setHeaders = (0, import_tool.defineTool)({
|
|
27
|
-
capability: "headers",
|
|
28
|
-
schema: {
|
|
29
|
-
name: "browser_set_headers",
|
|
30
|
-
title: "Set extra HTTP headers",
|
|
31
|
-
description: "Persistently set custom HTTP headers on the active browser context.",
|
|
32
|
-
inputSchema: import_bundle.z.object({
|
|
33
|
-
headers: import_bundle.z.record(import_bundle.z.string(), import_bundle.z.string()).describe("Header names mapped to the values that should be sent with every request.")
|
|
34
|
-
}),
|
|
35
|
-
type: "action"
|
|
36
|
-
},
|
|
37
|
-
handle: async (context, params, response) => {
|
|
38
|
-
try {
|
|
39
|
-
await context.setExtraHTTPHeaders(params.headers);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
response.addError(error.message);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const count = Object.keys(params.headers).length;
|
|
45
|
-
response.addResult(`Configured ${count} ${count === 1 ? "header" : "headers"} for this session.`);
|
|
46
|
-
response.addCode(`await context.setExtraHTTPHeaders(${JSON.stringify(params.headers, null, 2)});`);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
var headers_default = [
|
|
50
|
-
setHeaders
|
|
51
|
-
];
|