playwright-core 1.56.0-alpha-2025-10-01 → 1.56.0-beta-1759412259000

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/browsers.json CHANGED
@@ -27,13 +27,13 @@
27
27
  },
28
28
  {
29
29
  "name": "firefox",
30
- "revision": "1492",
30
+ "revision": "1495",
31
31
  "installByDefault": true,
32
32
  "browserVersion": "142.0.1"
33
33
  },
34
34
  {
35
35
  "name": "firefox-beta",
36
- "revision": "1487",
36
+ "revision": "1490",
37
37
  "installByDefault": false,
38
38
  "browserVersion": "143.0b10"
39
39
  },
@@ -49,8 +49,8 @@ class BrowserServerLauncherImpl {
49
49
  const playwright = (0, import_playwright.createPlaywright)({ sdkLanguage: "javascript", isServer: true });
50
50
  const metadata = { id: "", startTime: 0, endTime: 0, type: "Internal", method: "", params: {}, log: [], internal: true };
51
51
  const validatorContext = {
52
- tChannelImpl: (names, arg, path) => {
53
- throw new validatorPrimitives.ValidationError(`${path}: channels are not expected in launchServer`);
52
+ tChannelImpl: (names, arg, path2) => {
53
+ throw new validatorPrimitives.ValidationError(`${path2}: channels are not expected in launchServer`);
54
54
  },
55
55
  binary: "buffer",
56
56
  isUnderTest: import_debug.isUnderTest
@@ -82,11 +82,8 @@ class BrowserServerLauncherImpl {
82
82
  (0, import_stackTrace.rewriteErrorMessage)(e, `${e.message} Failed to launch browser.${log}`);
83
83
  throw e;
84
84
  }
85
- return this.launchServerOnExistingBrowser(browser, options);
86
- }
87
- async launchServerOnExistingBrowser(browser, options) {
88
85
  const path = options.wsPath ? options.wsPath.startsWith("/") ? options.wsPath : `/${options.wsPath}` : `/${(0, import_crypto.createGuid)()}`;
89
- const server = new import_playwrightServer.PlaywrightServer({ mode: options._sharedBrowser ? "launchServerShared" : "launchServer", path, maxConnections: Infinity, preLaunchedBrowser: browser, debugController: options._debugController });
86
+ const server = new import_playwrightServer.PlaywrightServer({ mode: options._sharedBrowser ? "launchServerShared" : "launchServer", path, maxConnections: Infinity, preLaunchedBrowser: browser });
90
87
  const wsEndpoint = await server.listen(options.port, options.host);
91
88
  const browserServer = new import_utilsBundle.ws.EventEmitter();
92
89
  browserServer.process = () => browser.options.browserProcess.process;
@@ -120,16 +120,6 @@ class Browser extends import_channelOwner.ChannelOwner {
120
120
  async newBrowserCDPSession() {
121
121
  return import_cdpSession.CDPSession.from((await this._channel.newBrowserCDPSession()).session);
122
122
  }
123
- async _launchServer(options = {}) {
124
- const serverLauncher = this._browserType._serverLauncher;
125
- const browserImpl = this._connection.toImpl?.(this);
126
- if (!serverLauncher || !browserImpl)
127
- throw new Error("Launching server is not supported");
128
- return await serverLauncher.launchServerOnExistingBrowser(browserImpl, {
129
- _sharedBrowser: true,
130
- ...options
131
- });
132
- }
133
123
  async startTracing(page, options = {}) {
134
124
  this._path = options.path;
135
125
  await this._channel.startTracing({ ...options, page: page ? page._channel : void 0 });
@@ -450,17 +450,7 @@ import_validatorPrimitives.scheme.DebugControllerSetModeRequestedEvent = (0, imp
450
450
  mode: import_validatorPrimitives.tString
451
451
  });
452
452
  import_validatorPrimitives.scheme.DebugControllerStateChangedEvent = (0, import_validatorPrimitives.tObject)({
453
- pageCount: import_validatorPrimitives.tInt,
454
- browsers: (0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tObject)({
455
- id: import_validatorPrimitives.tString,
456
- name: import_validatorPrimitives.tString,
457
- channel: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
458
- contexts: (0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tObject)({
459
- pages: (0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tObject)({
460
- url: import_validatorPrimitives.tString
461
- }))
462
- }))
463
- }))
453
+ pageCount: import_validatorPrimitives.tInt
464
454
  });
465
455
  import_validatorPrimitives.scheme.DebugControllerSourceChangedEvent = (0, import_validatorPrimitives.tObject)({
466
456
  text: import_validatorPrimitives.tString,
@@ -481,7 +471,6 @@ import_validatorPrimitives.scheme.DebugControllerSetReportStateChangedParams = (
481
471
  });
482
472
  import_validatorPrimitives.scheme.DebugControllerSetReportStateChangedResult = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
483
473
  import_validatorPrimitives.scheme.DebugControllerSetRecorderModeParams = (0, import_validatorPrimitives.tObject)({
484
- browserId: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
485
474
  mode: (0, import_validatorPrimitives.tEnum)(["inspecting", "recording", "none"]),
486
475
  testIdAttributeName: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
487
476
  generateAutoExpect: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean)
@@ -496,11 +485,6 @@ import_validatorPrimitives.scheme.DebugControllerHideHighlightParams = (0, impor
496
485
  import_validatorPrimitives.scheme.DebugControllerHideHighlightResult = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
497
486
  import_validatorPrimitives.scheme.DebugControllerResumeParams = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
498
487
  import_validatorPrimitives.scheme.DebugControllerResumeResult = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
499
- import_validatorPrimitives.scheme.DebugControllerCloseBrowserParams = (0, import_validatorPrimitives.tObject)({
500
- id: import_validatorPrimitives.tString,
501
- reason: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString)
502
- });
503
- import_validatorPrimitives.scheme.DebugControllerCloseBrowserResult = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
504
488
  import_validatorPrimitives.scheme.DebugControllerKillParams = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
505
489
  import_validatorPrimitives.scheme.DebugControllerKillResult = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
506
490
  import_validatorPrimitives.scheme.SocksSupportInitializer = (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({}));
@@ -86,20 +86,6 @@ ${uaError}` };
86
86
  const isExtension = this._options.mode === "extension";
87
87
  const allowFSPaths = isExtension;
88
88
  launchOptions = filterLaunchOptions(launchOptions, allowFSPaths);
89
- if (url.searchParams.has("debug-controller")) {
90
- if (!(this._options.debugController || isExtension))
91
- throw new Error("Debug controller is not enabled");
92
- return new import_playwrightConnection.PlaywrightConnection(
93
- controllerSemaphore,
94
- ws,
95
- true,
96
- this._playwright,
97
- async () => {
98
- throw new Error("shouldnt be used");
99
- },
100
- id
101
- );
102
- }
103
89
  if (isExtension) {
104
90
  const connectFilter = url.searchParams.get("connect");
105
91
  if (connectFilter) {
@@ -114,6 +100,18 @@ ${uaError}` };
114
100
  id
115
101
  );
116
102
  }
103
+ if (url.searchParams.has("debug-controller")) {
104
+ return new import_playwrightConnection.PlaywrightConnection(
105
+ controllerSemaphore,
106
+ ws,
107
+ true,
108
+ this._playwright,
109
+ async () => {
110
+ throw new Error("shouldnt be used");
111
+ },
112
+ id
113
+ );
114
+ }
117
115
  return new import_playwrightConnection.PlaywrightConnection(
118
116
  reuseBrowserSemaphore,
119
117
  ws,
@@ -218,6 +218,7 @@ class BidiPage {
218
218
  _onDownloadWillBegin(event) {
219
219
  if (!event.navigation)
220
220
  return;
221
+ this._page.frameManager.frameAbortedNavigation(event.context, "Download is starting");
221
222
  let originPage = this._page.initializedOrUndefined();
222
223
  if (!originPage && this._opener)
223
224
  originPage = this._opener._page.initializedOrUndefined();
@@ -31,13 +31,9 @@ var import_locatorParser = require("../utils/isomorphic/locatorParser");
31
31
  var import_language = require("./codegen/language");
32
32
  var import_recorderUtils = require("./recorder/recorderUtils");
33
33
  var import_javascript = require("./codegen/javascript");
34
- var import_frames = require("./frames");
35
- var import_page = require("./page");
36
34
  class DebugController extends import_instrumentation.SdkObject {
37
35
  constructor(playwright) {
38
36
  super({ attribution: { isInternalPlaywright: true }, instrumentation: (0, import_instrumentation.createInstrumentation)() }, void 0, "DebugController");
39
- this._reportState = false;
40
- this._disposeListeners = /* @__PURE__ */ new Set();
41
37
  this._sdkLanguage = "javascript";
42
38
  this._generateAutoExpect = false;
43
39
  this._playwright = playwright;
@@ -58,38 +54,23 @@ class DebugController extends import_instrumentation.SdkObject {
58
54
  this.setReportStateChanged(false);
59
55
  }
60
56
  setReportStateChanged(enabled) {
61
- if (this._reportState === enabled)
62
- return;
63
- this._reportState = enabled;
64
- if (enabled) {
65
- const listener = {
66
- onPageOpen: (page) => {
67
- this._emitSnapshot(false);
68
- const handleNavigation = () => this._emitSnapshot(false);
69
- page.mainFrame().on(import_frames.Frame.Events.InternalNavigation, handleNavigation);
70
- const dispose = () => page.mainFrame().off(import_frames.Frame.Events.InternalNavigation, handleNavigation);
71
- this._disposeListeners.add(dispose);
72
- page.on(import_page.Page.Events.Close, () => this._disposeListeners.delete(dispose));
73
- },
74
- onPageClose: () => this._emitSnapshot(false),
75
- onBrowserClose: () => {
76
- this._emitSnapshot(false);
77
- }
57
+ if (enabled && !this._trackHierarchyListener) {
58
+ this._trackHierarchyListener = {
59
+ onPageOpen: () => this._emitSnapshot(false),
60
+ onPageClose: () => this._emitSnapshot(false)
78
61
  };
79
- this._playwright.instrumentation.addListener(listener, null);
80
- this._disposeListeners.add(() => this._playwright.instrumentation.removeListener(listener));
62
+ this._playwright.instrumentation.addListener(this._trackHierarchyListener, null);
81
63
  this._emitSnapshot(true);
82
- } else {
83
- for (const dispose of this._disposeListeners)
84
- dispose();
85
- this._disposeListeners.clear();
64
+ } else if (!enabled && this._trackHierarchyListener) {
65
+ this._playwright.instrumentation.removeListener(this._trackHierarchyListener);
66
+ this._trackHierarchyListener = void 0;
86
67
  }
87
68
  }
88
69
  async setRecorderMode(progress, params) {
89
70
  await progress.race(this._closeBrowsersWithoutPages());
90
71
  this._generateAutoExpect = !!params.generateAutoExpect;
91
72
  if (params.mode === "none") {
92
- for (const recorder of await progress.race(this._allRecorders(params.browserId))) {
73
+ for (const recorder of await progress.race(this._allRecorders())) {
93
74
  recorder.hideHighlightedSelector();
94
75
  recorder.setMode("none");
95
76
  }
@@ -104,13 +85,10 @@ class DebugController extends import_instrumentation.SdkObject {
104
85
  await context.newPage(progress);
105
86
  }
106
87
  if (params.testIdAttributeName) {
107
- for (const page of this._playwright.allPages()) {
108
- if (params.browserId && page.browserContext._browser.guid !== params.browserId)
109
- continue;
88
+ for (const page of this._playwright.allPages())
110
89
  page.browserContext.selectors().setTestIdAttributeName(params.testIdAttributeName);
111
- }
112
90
  }
113
- for (const recorder of await progress.race(this._allRecorders(params.browserId))) {
91
+ for (const recorder of await progress.race(this._allRecorders())) {
114
92
  recorder.hideHighlightedSelector();
115
93
  recorder.setMode(params.mode);
116
94
  }
@@ -136,12 +114,6 @@ class DebugController extends import_instrumentation.SdkObject {
136
114
  for (const recorder of await progress.race(this._allRecorders()))
137
115
  recorder.resume();
138
116
  }
139
- async closeBrowser(progress, id, reason) {
140
- const browser = this._playwright.allBrowsers().find((b) => b.guid === id);
141
- if (!browser)
142
- return;
143
- await progress.race(browser.close({ reason }));
144
- }
145
117
  kill() {
146
118
  (0, import_processLauncher.gracefullyProcessExitDoNotHang)(0);
147
119
  }
@@ -149,27 +121,12 @@ class DebugController extends import_instrumentation.SdkObject {
149
121
  const pageCount = this._playwright.allPages().length;
150
122
  if (initial && !pageCount)
151
123
  return;
152
- this.emit(DebugController.Events.StateChanged, {
153
- pageCount,
154
- browsers: this._playwright.allBrowsers().map((browser) => ({
155
- id: browser.guid,
156
- name: browser.options.name,
157
- channel: browser.options.channel,
158
- contexts: browser.contexts().map((context) => ({
159
- pages: context.pages().map((page) => ({
160
- url: page.mainFrame().url()
161
- }))
162
- }))
163
- }))
164
- });
124
+ this.emit(DebugController.Events.StateChanged, { pageCount });
165
125
  }
166
- async _allRecorders(browserId) {
126
+ async _allRecorders() {
167
127
  const contexts = /* @__PURE__ */ new Set();
168
- for (const page of this._playwright.allPages()) {
169
- if (browserId && page.browserContext._browser.guid !== browserId)
170
- continue;
128
+ for (const page of this._playwright.allPages())
171
129
  contexts.add(page.browserContext);
172
- }
173
130
  const recorders = await Promise.all([...contexts].map((c) => import_recorder.Recorder.forContext(c, { omitCallTracking: true })));
174
131
  const nonNullRecorders = recorders.filter(Boolean);
175
132
  for (const recorder of recorders)
@@ -67,9 +67,6 @@ class DebugControllerDispatcher extends import_dispatcher.Dispatcher {
67
67
  async kill(params, progress) {
68
68
  this._object.kill();
69
69
  }
70
- async closeBrowser(params, progress) {
71
- await this._object.closeBrowser(progress, params.id, params.reason);
72
- }
73
70
  _onDispose() {
74
71
  import_utils.eventsHelper.removeEventListeners(this._listeners);
75
72
  this._object.dispose();
@@ -85,13 +85,8 @@ class WSServer {
85
85
  const url = new URL("http://localhost" + (request.url || ""));
86
86
  const id = String(++lastConnectionId);
87
87
  import_debugLogger.debugLogger.log("server", `[${id}] serving connection: ${request.url}`);
88
- try {
89
- const connection = this._delegate.onConnection(request, url, ws, id);
90
- ws[kConnectionSymbol] = connection;
91
- } catch (error) {
92
- import_debugLogger.debugLogger.log("server", `[${id}] connection error: ${error}`);
93
- ws.close(1011, String(error));
94
- }
88
+ const connection = this._delegate.onConnection(request, url, ws, id);
89
+ ws[kConnectionSymbol] = connection;
95
90
  });
96
91
  return wsEndpoint;
97
92
  }
@@ -343,7 +343,6 @@ class WKPage {
343
343
  import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameDetached", (event) => this._onFrameDetached(event.frameId)),
344
344
  import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.willCheckNavigationPolicy", (event) => this._onWillCheckNavigationPolicy(event.frameId)),
345
345
  import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.didCheckNavigationPolicy", (event) => this._onDidCheckNavigationPolicy(event.frameId, event.cancel)),
346
- import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameScheduledNavigation", (event) => this._onFrameScheduledNavigation(event.frameId, event.delay, event.targetIsCurrentFrame)),
347
346
  import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.loadEventFired", (event) => this._page.frameManager.frameLifecycleEvent(event.frameId, "load")),
348
347
  import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.domContentEventFired", (event) => this._page.frameManager.frameLifecycleEvent(event.frameId, "domcontentloaded")),
349
348
  import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextCreated", (event) => this._onExecutionContextCreated(event.context)),
@@ -390,10 +389,6 @@ class WKPage {
390
389
  return;
391
390
  this._page.frameManager.frameAbortedNavigation(frameId, "Navigation canceled by policy check");
392
391
  }
393
- _onFrameScheduledNavigation(frameId, delay, targetIsCurrentFrame) {
394
- if (targetIsCurrentFrame)
395
- this._page.frameManager.frameRequestedNavigation(frameId);
396
- }
397
392
  _handleFrameTree(frameTree) {
398
393
  this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null);
399
394
  this._onFrameNavigated(frameTree.frame, true);
@@ -46,7 +46,6 @@ const methodMetainfo = /* @__PURE__ */ new Map([
46
46
  ["DebugController.highlight", { internal: true }],
47
47
  ["DebugController.hideHighlight", { internal: true }],
48
48
  ["DebugController.resume", { internal: true }],
49
- ["DebugController.closeBrowser", { internal: true }],
50
49
  ["DebugController.kill", { internal: true }],
51
50
  ["SocksSupport.socksConnected", { internal: true }],
52
51
  ["SocksSupport.socksFailed", { internal: true }],