playwright-core 1.58.0-alpha-1764708599000 → 1.58.0-alpha-2025-12-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/ThirdPartyNotices.txt +2716 -300
- package/browsers.json +1 -1
- package/lib/mcpBundle.js +84 -0
- package/lib/mcpBundleImpl/index.js +96 -0
- package/lib/protocol/validator.js +0 -2
- package/lib/remote/playwrightServer.js +1 -2
- package/lib/server/bidi/bidiBrowser.js +7 -4
- package/lib/server/bidi/bidiChromium.js +0 -2
- package/lib/server/bidi/bidiPage.js +17 -20
- package/lib/server/browserType.js +2 -3
- package/lib/server/chromium/chromium.js +1 -8
- package/lib/server/chromium/crDevTools.js +0 -2
- package/lib/utils/isomorphic/trace/snapshotServer.js +4 -1
- package/lib/utils/isomorphic/trace/snapshotStorage.js +10 -0
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/package.json +2 -1
- package/types/types.d.ts +3 -33
- package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
|
@@ -512,7 +512,6 @@ import_validatorPrimitives.scheme.BrowserTypeLaunchParams = (0, import_validator
|
|
|
512
512
|
timeout: import_validatorPrimitives.tFloat,
|
|
513
513
|
env: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("NameValue"))),
|
|
514
514
|
headless: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean),
|
|
515
|
-
devtools: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean),
|
|
516
515
|
proxy: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
517
516
|
server: import_validatorPrimitives.tString,
|
|
518
517
|
bypass: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
@@ -542,7 +541,6 @@ import_validatorPrimitives.scheme.BrowserTypeLaunchPersistentContextParams = (0,
|
|
|
542
541
|
timeout: import_validatorPrimitives.tFloat,
|
|
543
542
|
env: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("NameValue"))),
|
|
544
543
|
headless: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean),
|
|
545
|
-
devtools: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean),
|
|
546
544
|
proxy: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
547
545
|
server: import_validatorPrimitives.tString,
|
|
548
546
|
bypass: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
@@ -130,10 +130,13 @@ class BidiBrowser extends import_browser.Browser {
|
|
|
130
130
|
const page2 = this._findPageForFrame(parentFrameId);
|
|
131
131
|
if (page2) {
|
|
132
132
|
page2._session.addFrameBrowsingContext(event.context);
|
|
133
|
-
page2._page.frameManager.frameAttached(event.context, parentFrameId);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
const frame = page2._page.frameManager.frameAttached(event.context, parentFrameId);
|
|
134
|
+
frame._url = event.url;
|
|
135
|
+
page2._getFrameNode(frame).then((node) => {
|
|
136
|
+
const attributes = node?.value?.attributes;
|
|
137
|
+
frame._name = attributes?.name ?? attributes?.id ?? "";
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
137
140
|
}
|
|
138
141
|
return;
|
|
139
142
|
}
|
|
@@ -112,8 +112,6 @@ class BidiChromium extends import_browserType.BrowserType {
|
|
|
112
112
|
if (import_os.default.platform() === "darwin") {
|
|
113
113
|
chromeArguments.push("--enable-unsafe-swiftshader");
|
|
114
114
|
}
|
|
115
|
-
if (options.devtools)
|
|
116
|
-
chromeArguments.push("--auto-open-devtools-for-tabs");
|
|
117
115
|
if (options.headless) {
|
|
118
116
|
chromeArguments.push("--headless");
|
|
119
117
|
chromeArguments.push(
|
|
@@ -178,10 +178,11 @@ class BidiPage {
|
|
|
178
178
|
}
|
|
179
179
|
_onNavigationCommitted(params) {
|
|
180
180
|
const frameId = params.context;
|
|
181
|
+
const frame = this._page.frameManager.frame(frameId);
|
|
181
182
|
this._page.frameManager.frameCommittedNewDocumentNavigation(
|
|
182
183
|
frameId,
|
|
183
184
|
params.url,
|
|
184
|
-
|
|
185
|
+
frame._name,
|
|
185
186
|
params.navigation,
|
|
186
187
|
/* initial */
|
|
187
188
|
false
|
|
@@ -536,26 +537,22 @@ ${params.stackTrace?.callFrames.map((f) => {
|
|
|
536
537
|
const parent = frame.parentFrame();
|
|
537
538
|
if (!parent)
|
|
538
539
|
throw new Error("Frame has been detached.");
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
return [...document.querySelectorAll("iframe,frame")];
|
|
542
|
-
});
|
|
543
|
-
const length = await list.evaluate((list2) => list2.length);
|
|
544
|
-
let foundElement = null;
|
|
545
|
-
for (let i = 0; i < length; i++) {
|
|
546
|
-
const element = await list.evaluateHandle((list2, i2) => list2[i2], i);
|
|
547
|
-
const candidate = await element.contentFrame();
|
|
548
|
-
if (frame === candidate) {
|
|
549
|
-
foundElement = element;
|
|
550
|
-
break;
|
|
551
|
-
} else {
|
|
552
|
-
element.dispose();
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
list.dispose();
|
|
556
|
-
if (!foundElement)
|
|
540
|
+
const node = await this._getFrameNode(frame);
|
|
541
|
+
if (!node?.sharedId)
|
|
557
542
|
throw new Error("Frame has been detached.");
|
|
558
|
-
|
|
543
|
+
const parentFrameExecutionContext = await parent._mainContext();
|
|
544
|
+
return await toBidiExecutionContext(parentFrameExecutionContext).remoteObjectForNodeId(parentFrameExecutionContext, { sharedId: node.sharedId });
|
|
545
|
+
}
|
|
546
|
+
async _getFrameNode(frame) {
|
|
547
|
+
const parent = frame.parentFrame();
|
|
548
|
+
if (!parent)
|
|
549
|
+
return void 0;
|
|
550
|
+
const result = await this._session.send("browsingContext.locateNodes", {
|
|
551
|
+
context: parent._id,
|
|
552
|
+
locator: { type: "context", value: { context: frame._id } }
|
|
553
|
+
});
|
|
554
|
+
const node = result.nodes[0];
|
|
555
|
+
return node;
|
|
559
556
|
}
|
|
560
557
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
561
558
|
return true;
|
|
@@ -276,15 +276,14 @@ class BrowserType extends import_instrumentation.SdkObject {
|
|
|
276
276
|
throw new Error("Connecting to SELENIUM_REMOTE_URL is only supported by Chromium");
|
|
277
277
|
}
|
|
278
278
|
_validateLaunchOptions(options) {
|
|
279
|
-
|
|
280
|
-
let { headless = !devtools, downloadsPath, proxy } = options;
|
|
279
|
+
let { headless = true, downloadsPath, proxy } = options;
|
|
281
280
|
if ((0, import_debug.debugMode)() === "inspector")
|
|
282
281
|
headless = false;
|
|
283
282
|
if (downloadsPath && !import_path.default.isAbsolute(downloadsPath))
|
|
284
283
|
downloadsPath = import_path.default.join(process.cwd(), downloadsPath);
|
|
285
284
|
if (options.socksProxyPort)
|
|
286
285
|
proxy = { server: `socks5://127.0.0.1:${options.socksProxyPort}` };
|
|
287
|
-
return { ...options,
|
|
286
|
+
return { ...options, headless, downloadsPath, proxy };
|
|
288
287
|
}
|
|
289
288
|
_createUserDataDirArgMisuseError(userDataDirArg) {
|
|
290
289
|
switch (this.attribution.playwright.options.sdkLanguage) {
|
|
@@ -128,13 +128,8 @@ class Chromium extends import_browserType.BrowserType {
|
|
|
128
128
|
return directory ? new import_crDevTools.CRDevTools(import_path.default.join(directory, "devtools-preferences.json")) : void 0;
|
|
129
129
|
}
|
|
130
130
|
async connectToTransport(transport, options, browserLogsCollector) {
|
|
131
|
-
let devtools = this._devtools;
|
|
132
|
-
if (options.__testHookForDevTools) {
|
|
133
|
-
devtools = this._createDevTools();
|
|
134
|
-
await options.__testHookForDevTools(devtools);
|
|
135
|
-
}
|
|
136
131
|
try {
|
|
137
|
-
return await import_crBrowser.CRBrowser.connect(this.attribution.playwright, transport, options,
|
|
132
|
+
return await import_crBrowser.CRBrowser.connect(this.attribution.playwright, transport, options, this._devtools);
|
|
138
133
|
} catch (e) {
|
|
139
134
|
if (browserLogsCollector.recentLogs().some((log) => log.includes("Failed to create a ProcessSingleton for your profile directory."))) {
|
|
140
135
|
throw new Error(
|
|
@@ -287,8 +282,6 @@ class Chromium extends import_browserType.BrowserType {
|
|
|
287
282
|
if (import_os.default.platform() === "darwin") {
|
|
288
283
|
chromeArguments.push("--enable-unsafe-swiftshader");
|
|
289
284
|
}
|
|
290
|
-
if (options.devtools)
|
|
291
|
-
chromeArguments.push("--auto-open-devtools-for-tabs");
|
|
292
285
|
if (options.headless) {
|
|
293
286
|
chromeArguments.push("--headless");
|
|
294
287
|
chromeArguments.push(
|
|
@@ -92,7 +92,10 @@ class SnapshotServer {
|
|
|
92
92
|
headers.set("Access-Control-Allow-Origin", "*");
|
|
93
93
|
headers.delete("Content-Length");
|
|
94
94
|
headers.set("Content-Length", String(content.size));
|
|
95
|
-
|
|
95
|
+
if (this._snapshotStorage.hasResourceOverride(resource.request.url))
|
|
96
|
+
headers.set("Cache-Control", "no-store, no-cache, max-age=0");
|
|
97
|
+
else
|
|
98
|
+
headers.set("Cache-Control", "public, max-age=31536000");
|
|
96
99
|
const { status } = resource.response;
|
|
97
100
|
const isNullBodyStatus = status === 101 || status === 204 || status === 205 || status === 304;
|
|
98
101
|
return new Response(isNullBodyStatus ? null : content, {
|
|
@@ -29,6 +29,7 @@ class SnapshotStorage {
|
|
|
29
29
|
this._cache = new import_lruCache.LRUCache(1e8);
|
|
30
30
|
// 100MB per each trace
|
|
31
31
|
this._contextToResources = /* @__PURE__ */ new Map();
|
|
32
|
+
this._resourceUrlsWithOverrides = /* @__PURE__ */ new Set();
|
|
32
33
|
}
|
|
33
34
|
addResource(contextId, resource) {
|
|
34
35
|
resource.request.url = (0, import_snapshotRenderer.rewriteURLForCustomProtocol)(resource.request.url);
|
|
@@ -63,6 +64,15 @@ class SnapshotStorage {
|
|
|
63
64
|
finalize() {
|
|
64
65
|
for (const resources of this._contextToResources.values())
|
|
65
66
|
resources.sort((a, b) => (a._monotonicTime || 0) - (b._monotonicTime || 0));
|
|
67
|
+
for (const frameSnapshots of this._frameSnapshots.values()) {
|
|
68
|
+
for (const snapshot of frameSnapshots.raw) {
|
|
69
|
+
for (const override of snapshot.resourceOverrides)
|
|
70
|
+
this._resourceUrlsWithOverrides.add(override.url);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
hasResourceOverride(url) {
|
|
75
|
+
return this._resourceUrlsWithOverrides.has(url);
|
|
66
76
|
}
|
|
67
77
|
_ensureResourcesForContext(contextId) {
|
|
68
78
|
let resources = this._contextToResources.get(contextId);
|