patchright-core 1.52.5 → 1.55.1
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 +65 -123
- package/bin/reinstall_chrome_beta_mac.sh +1 -1
- package/bin/reinstall_chrome_stable_mac.sh +1 -1
- package/bin/reinstall_msedge_beta_mac.sh +1 -1
- package/bin/reinstall_msedge_dev_mac.sh +1 -1
- package/bin/reinstall_msedge_stable_mac.sh +1 -1
- package/browsers.json +14 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +4 -2
- package/lib/browserServerImpl.js +47 -12
- package/lib/cli/program.js +116 -50
- package/lib/cli/programWithTestStub.js +1 -1
- package/lib/client/android.js +30 -34
- package/lib/client/browser.js +54 -17
- package/lib/client/browserContext.js +67 -71
- package/lib/client/browserType.js +25 -34
- package/lib/client/channelOwner.js +20 -24
- package/lib/client/connection.js +6 -10
- package/lib/client/electron.js +8 -3
- package/lib/client/elementHandle.js +18 -21
- package/lib/client/fetch.js +5 -3
- package/lib/client/frame.js +54 -32
- package/lib/client/input.js +3 -1
- package/lib/client/jsHandle.js +4 -0
- package/lib/client/localUtils.js +0 -1
- package/lib/client/locator.js +30 -26
- package/lib/client/network.js +5 -12
- package/lib/client/page.js +32 -32
- package/lib/client/playwright.js +6 -16
- package/lib/client/selectors.js +18 -38
- package/lib/client/timeoutSettings.js +12 -8
- package/lib/client/tracing.js +24 -20
- package/lib/client/waiter.js +2 -2
- package/lib/client/webSocket.js +4 -22
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/generated/webSocketMockSource.js +12 -50
- package/lib/inProcessFactory.js +9 -6
- package/lib/outofprocess.js +0 -2
- package/lib/protocol/validator.js +421 -345
- package/lib/protocol/validatorPrimitives.js +18 -4
- package/lib/remote/playwrightConnection.js +29 -166
- package/lib/remote/playwrightServer.js +233 -35
- package/lib/server/android/android.js +97 -83
- package/lib/server/android/backendAdb.js +0 -2
- package/lib/server/bidi/bidiBrowser.js +139 -73
- package/lib/server/bidi/bidiChromium.js +23 -22
- package/lib/server/bidi/bidiExecutionContext.js +2 -1
- package/lib/server/bidi/bidiFirefox.js +17 -14
- package/lib/server/bidi/bidiInput.js +22 -22
- package/lib/server/bidi/bidiNetworkManager.js +8 -11
- package/lib/server/bidi/bidiPage.js +42 -86
- package/lib/server/bidi/third_party/bidiProtocol.js +5 -133
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/{dispatchers/selectorsDispatcher.js → bidi/third_party/bidiProtocolPermissions.js} +20 -18
- package/lib/server/browser.js +30 -21
- package/lib/server/browserContext.js +203 -165
- package/lib/server/browserType.js +109 -107
- package/lib/server/chromium/chromium.js +84 -69
- package/lib/server/chromium/chromiumSwitches.js +13 -20
- package/lib/server/chromium/crBrowser.js +74 -40
- package/lib/server/chromium/crConnection.js +8 -9
- package/lib/server/chromium/crCoverage.js +11 -8
- package/lib/server/chromium/crDragDrop.js +25 -20
- package/lib/server/chromium/crExecutionContext.js +2 -1
- package/lib/server/chromium/crInput.js +32 -29
- package/lib/server/chromium/crNetworkManager.js +43 -31
- package/lib/server/chromium/crPage.js +98 -72
- package/lib/server/chromium/crServiceWorker.js +13 -18
- package/lib/server/chromium/videoRecorder.js +10 -18
- package/lib/server/clock.js +51 -39
- package/lib/server/codegen/csharp.js +10 -5
- package/lib/server/codegen/java.js +1 -1
- package/lib/server/codegen/javascript.js +1 -1
- package/lib/server/codegen/jsonl.js +2 -1
- package/lib/server/codegen/language.js +22 -1
- package/lib/server/codegen/languages.js +4 -4
- package/lib/server/codegen/python.js +1 -1
- package/lib/server/cookieStore.js +3 -1
- package/lib/server/debugController.js +105 -71
- package/lib/server/debugger.js +6 -23
- package/lib/server/deviceDescriptorsSource.json +237 -127
- package/lib/server/dialog.js +50 -6
- package/lib/server/dispatchers/androidDispatcher.js +77 -62
- package/lib/server/dispatchers/artifactDispatcher.js +18 -18
- package/lib/server/dispatchers/browserContextDispatcher.js +141 -91
- package/lib/server/dispatchers/browserDispatcher.js +55 -88
- package/lib/server/dispatchers/browserTypeDispatcher.js +18 -9
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -4
- package/lib/server/dispatchers/debugControllerDispatcher.js +12 -21
- package/lib/server/dispatchers/dialogDispatcher.js +4 -4
- package/lib/server/dispatchers/dispatcher.js +78 -53
- package/lib/server/dispatchers/electronDispatcher.js +19 -20
- package/lib/server/dispatchers/elementHandlerDispatcher.js +83 -93
- package/lib/server/dispatchers/frameDispatcher.js +98 -101
- package/lib/server/dispatchers/jsHandleDispatcher.js +21 -16
- package/lib/server/dispatchers/jsonPipeDispatcher.js +4 -4
- package/lib/server/dispatchers/localUtilsDispatcher.js +53 -59
- package/lib/server/dispatchers/networkDispatchers.js +41 -35
- package/lib/server/dispatchers/pageDispatcher.js +156 -107
- package/lib/server/dispatchers/playwrightDispatcher.js +37 -25
- package/lib/server/dispatchers/streamDispatcher.js +15 -8
- package/lib/server/dispatchers/tracingDispatcher.js +22 -13
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +46 -35
- package/lib/server/dispatchers/writableStreamDispatcher.js +16 -10
- package/lib/server/dom.js +198 -266
- package/lib/server/download.js +3 -3
- package/lib/server/electron/electron.js +96 -103
- package/lib/server/electron/loader.js +1 -1
- package/lib/server/fetch.js +22 -41
- package/lib/server/fileUploadUtils.js +1 -1
- package/lib/server/firefox/ffBrowser.js +79 -55
- package/lib/server/firefox/ffExecutionContext.js +2 -1
- package/lib/server/firefox/ffInput.js +23 -23
- package/lib/server/firefox/ffNetworkManager.js +8 -6
- package/lib/server/firefox/ffPage.js +39 -36
- package/lib/server/firefox/firefox.js +9 -10
- package/lib/server/frameSelectors.js +63 -20
- package/lib/server/frames.js +495 -555
- package/lib/server/har/harRecorder.js +1 -1
- package/lib/server/har/harTracer.js +4 -2
- package/lib/server/helper.js +3 -7
- package/lib/server/index.js +0 -3
- package/lib/server/input.js +47 -54
- package/lib/server/instrumentation.js +8 -14
- package/lib/server/javascript.js +8 -16
- package/lib/server/launchApp.js +48 -30
- package/lib/server/localUtils.js +45 -38
- package/lib/server/network.js +44 -10
- package/lib/server/page.js +232 -177
- package/lib/server/pageBinding.js +6 -7
- package/lib/server/playwright.js +4 -14
- package/lib/server/progress.js +57 -49
- package/lib/server/recorder/recorderApp.js +298 -95
- package/lib/server/recorder/recorderRunner.js +23 -24
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +67 -10
- package/lib/server/recorder.js +284 -146
- package/lib/server/registry/index.js +83 -48
- package/lib/server/registry/nativeDeps.js +175 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +1 -1
- package/lib/server/screenshotter.js +84 -83
- package/lib/server/selectors.js +12 -12
- package/lib/server/socksClientCertificatesInterceptor.js +198 -136
- package/lib/server/trace/recorder/snapshotter.js +12 -19
- package/lib/server/trace/recorder/tracing.js +36 -27
- package/lib/server/trace/viewer/traceViewer.js +11 -20
- package/lib/server/transport.js +20 -22
- package/lib/server/utils/comparators.js +2 -2
- package/lib/server/utils/debug.js +3 -8
- package/lib/server/utils/debugLogger.js +8 -0
- package/lib/server/utils/hostPlatform.js +3 -1
- package/lib/server/utils/network.js +35 -25
- package/lib/server/utils/nodePlatform.js +1 -1
- package/lib/server/utils/processLauncher.js +4 -1
- package/lib/server/utils/wsServer.js +11 -17
- package/lib/server/webkit/webkit.js +5 -2
- package/lib/server/webkit/wkBrowser.js +51 -28
- package/lib/server/webkit/wkExecutionContext.js +2 -1
- package/lib/server/webkit/wkInput.js +25 -25
- package/lib/server/webkit/wkInterceptableRequest.js +1 -1
- package/lib/server/webkit/wkPage.js +80 -59
- package/lib/server/webkit/wkProvisionalPage.js +1 -1
- package/lib/server/webkit/wkWorkers.js +7 -7
- package/lib/utils/isomorphic/ariaSnapshot.js +13 -7
- package/lib/utils/isomorphic/cssParser.js +1 -2
- package/lib/utils/isomorphic/locatorGenerators.js +18 -0
- package/lib/utils/isomorphic/manualPromise.js +1 -2
- package/lib/utils/isomorphic/mimeType.js +1 -2
- package/lib/utils/isomorphic/multimap.js +1 -2
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +248 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +318 -0
- package/lib/utils/isomorphic/selectorParser.js +3 -4
- package/lib/utils/isomorphic/stringUtils.js +3 -24
- package/lib/utils/isomorphic/time.js +9 -4
- package/lib/utils/isomorphic/timeoutRunner.js +3 -4
- package/lib/utils/isomorphic/traceUtils.js +2 -3
- package/lib/utils/isomorphic/urlMatch.js +21 -7
- package/lib/utils/isomorphic/utilityScriptSerializers.js +208 -205
- package/lib/utils.js +8 -2
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/vite/htmlReport/index.html +17 -17
- package/lib/vite/recorder/assets/{codeMirrorModule-CXVeovup.js → codeMirrorModule-DzQ0k89p.js} +1 -1
- package/lib/vite/recorder/assets/{index-eHBmevrY.css → index-CI4HQ-Zb.css} +1 -1
- package/lib/vite/recorder/assets/index-D7C7daHH.js +184 -0
- package/lib/vite/recorder/index.html +3 -3
- package/lib/vite/traceViewer/assets/{codeMirrorModule-_GLjJL-7.js → codeMirrorModule-Di48jgWx.js} +1 -1
- package/lib/vite/traceViewer/assets/defaultSettingsView-szBn8781.js +256 -0
- package/lib/vite/traceViewer/defaultSettingsView.DVJHpiGt.css +1 -0
- package/lib/vite/traceViewer/index.BFsek2M6.css +1 -0
- package/lib/vite/traceViewer/index.DQvXoPLL.js +2 -0
- package/lib/vite/traceViewer/index.html +6 -6
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.dBV3oN9h.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -4
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +712 -107
- package/types/types.d.ts +128 -17
- package/lib/generated/consoleApiSource.js +0 -28
- package/lib/protocol/debug.js +0 -211
- package/lib/server/recorder/contextRecorder.js +0 -286
- package/lib/server/recorder/recorderCollection.js +0 -116
- package/lib/server/recorder/recorderFrontend.js +0 -16
- package/lib/server/storageScript.js +0 -154
- package/lib/server/timeoutSettings.js +0 -89
- package/lib/utils/isomorphic/builtins.js +0 -86
- package/lib/vite/recorder/assets/index-BsWQsSGl.js +0 -184
- package/lib/vite/traceViewer/assets/defaultSettingsView-DtCQiGHe.js +0 -265
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.cFZzK9RN.js +0 -2
- package/lib/vite/traceViewer/uiMode.XVPIqBeS.js +0 -5
|
@@ -65,7 +65,7 @@ class RawKeyboardImpl {
|
|
|
65
65
|
setSession(session) {
|
|
66
66
|
this._session = session;
|
|
67
67
|
}
|
|
68
|
-
async keydown(modifiers, keyName, description, autoRepeat) {
|
|
68
|
+
async keydown(progress, modifiers, keyName, description, autoRepeat) {
|
|
69
69
|
const parts = [];
|
|
70
70
|
for (const modifier of ["Shift", "Control", "Alt", "Meta"]) {
|
|
71
71
|
if (modifiers.has(modifier))
|
|
@@ -77,7 +77,7 @@ class RawKeyboardImpl {
|
|
|
77
77
|
let commands = import_macEditingCommands.macEditingCommands[shortcut];
|
|
78
78
|
if ((0, import_utils.isString)(commands))
|
|
79
79
|
commands = [commands];
|
|
80
|
-
await this._pageProxySession.send("Input.dispatchKeyEvent", {
|
|
80
|
+
await progress.race(this._pageProxySession.send("Input.dispatchKeyEvent", {
|
|
81
81
|
type: "keyDown",
|
|
82
82
|
modifiers: toModifiersMask(modifiers),
|
|
83
83
|
windowsVirtualKeyCode: keyCode,
|
|
@@ -88,21 +88,21 @@ class RawKeyboardImpl {
|
|
|
88
88
|
autoRepeat,
|
|
89
89
|
macCommands: commands,
|
|
90
90
|
isKeypad: description.location === input.keypadLocation
|
|
91
|
-
});
|
|
91
|
+
}));
|
|
92
92
|
}
|
|
93
|
-
async keyup(modifiers, keyName, description) {
|
|
93
|
+
async keyup(progress, modifiers, keyName, description) {
|
|
94
94
|
const { code, key } = description;
|
|
95
|
-
await this._pageProxySession.send("Input.dispatchKeyEvent", {
|
|
95
|
+
await progress.race(this._pageProxySession.send("Input.dispatchKeyEvent", {
|
|
96
96
|
type: "keyUp",
|
|
97
97
|
modifiers: toModifiersMask(modifiers),
|
|
98
98
|
key,
|
|
99
99
|
windowsVirtualKeyCode: description.keyCode,
|
|
100
100
|
code,
|
|
101
101
|
isKeypad: description.location === input.keypadLocation
|
|
102
|
-
});
|
|
102
|
+
}));
|
|
103
103
|
}
|
|
104
|
-
async sendText(text) {
|
|
105
|
-
await this._session.send("Page.insertText", { text });
|
|
104
|
+
async sendText(progress, text) {
|
|
105
|
+
await progress.race(this._session.send("Page.insertText", { text }));
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
class RawMouseImpl {
|
|
@@ -112,18 +112,18 @@ class RawMouseImpl {
|
|
|
112
112
|
setSession(session) {
|
|
113
113
|
this._session = session;
|
|
114
114
|
}
|
|
115
|
-
async move(x, y, button, buttons, modifiers, forClick) {
|
|
116
|
-
await this._pageProxySession.send("Input.dispatchMouseEvent", {
|
|
115
|
+
async move(progress, x, y, button, buttons, modifiers, forClick) {
|
|
116
|
+
await progress.race(this._pageProxySession.send("Input.dispatchMouseEvent", {
|
|
117
117
|
type: "move",
|
|
118
118
|
button,
|
|
119
119
|
buttons: toButtonsMask(buttons),
|
|
120
120
|
x,
|
|
121
121
|
y,
|
|
122
122
|
modifiers: toModifiersMask(modifiers)
|
|
123
|
-
});
|
|
123
|
+
}));
|
|
124
124
|
}
|
|
125
|
-
async down(x, y, button, buttons, modifiers, clickCount) {
|
|
126
|
-
await this._pageProxySession.send("Input.dispatchMouseEvent", {
|
|
125
|
+
async down(progress, x, y, button, buttons, modifiers, clickCount) {
|
|
126
|
+
await progress.race(this._pageProxySession.send("Input.dispatchMouseEvent", {
|
|
127
127
|
type: "down",
|
|
128
128
|
button,
|
|
129
129
|
buttons: toButtonsMask(buttons),
|
|
@@ -131,10 +131,10 @@ class RawMouseImpl {
|
|
|
131
131
|
y,
|
|
132
132
|
modifiers: toModifiersMask(modifiers),
|
|
133
133
|
clickCount
|
|
134
|
-
});
|
|
134
|
+
}));
|
|
135
135
|
}
|
|
136
|
-
async up(x, y, button, buttons, modifiers, clickCount) {
|
|
137
|
-
await this._pageProxySession.send("Input.dispatchMouseEvent", {
|
|
136
|
+
async up(progress, x, y, button, buttons, modifiers, clickCount) {
|
|
137
|
+
await progress.race(this._pageProxySession.send("Input.dispatchMouseEvent", {
|
|
138
138
|
type: "up",
|
|
139
139
|
button,
|
|
140
140
|
buttons: toButtonsMask(buttons),
|
|
@@ -142,20 +142,20 @@ class RawMouseImpl {
|
|
|
142
142
|
y,
|
|
143
143
|
modifiers: toModifiersMask(modifiers),
|
|
144
144
|
clickCount
|
|
145
|
-
});
|
|
145
|
+
}));
|
|
146
146
|
}
|
|
147
|
-
async wheel(x, y, buttons, modifiers, deltaX, deltaY) {
|
|
148
|
-
if (this._page?.
|
|
147
|
+
async wheel(progress, x, y, buttons, modifiers, deltaX, deltaY) {
|
|
148
|
+
if (this._page?.browserContext._options.isMobile)
|
|
149
149
|
throw new Error("Mouse wheel is not supported in mobile WebKit");
|
|
150
150
|
await this._session.send("Page.updateScrollingState");
|
|
151
|
-
await this._page.mainFrame().evaluateExpression(`new Promise(requestAnimationFrame)`, { world: "utility" });
|
|
152
|
-
await this._pageProxySession.send("Input.dispatchWheelEvent", {
|
|
151
|
+
await progress.race(this._page.mainFrame().evaluateExpression(`new Promise(requestAnimationFrame)`, { world: "utility" }));
|
|
152
|
+
await progress.race(this._pageProxySession.send("Input.dispatchWheelEvent", {
|
|
153
153
|
x,
|
|
154
154
|
y,
|
|
155
155
|
deltaX,
|
|
156
156
|
deltaY,
|
|
157
157
|
modifiers: toModifiersMask(modifiers)
|
|
158
|
-
});
|
|
158
|
+
}));
|
|
159
159
|
}
|
|
160
160
|
setPage(page) {
|
|
161
161
|
this._page = page;
|
|
@@ -165,12 +165,12 @@ class RawTouchscreenImpl {
|
|
|
165
165
|
constructor(session) {
|
|
166
166
|
this._pageProxySession = session;
|
|
167
167
|
}
|
|
168
|
-
async tap(x, y, modifiers) {
|
|
169
|
-
await this._pageProxySession.send("Input.dispatchTapEvent", {
|
|
168
|
+
async tap(progress, x, y, modifiers) {
|
|
169
|
+
await progress.race(this._pageProxySession.send("Input.dispatchTapEvent", {
|
|
170
170
|
x,
|
|
171
171
|
y,
|
|
172
172
|
modifiers: toModifiersMask(modifiers)
|
|
173
|
-
});
|
|
173
|
+
}));
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -61,7 +61,7 @@ class WKInterceptableRequest {
|
|
|
61
61
|
if (event.request.postData)
|
|
62
62
|
postDataBuffer = Buffer.from(event.request.postData, "base64");
|
|
63
63
|
this.request = new network.Request(
|
|
64
|
-
frame._page.
|
|
64
|
+
frame._page.browserContext,
|
|
65
65
|
frame,
|
|
66
66
|
null,
|
|
67
67
|
redirectedFrom?.request || null,
|
|
@@ -46,7 +46,6 @@ var import_errors = require("../errors");
|
|
|
46
46
|
var import_helper = require("../helper");
|
|
47
47
|
var network = __toESM(require("../network"));
|
|
48
48
|
var import_page = require("../page");
|
|
49
|
-
var import_page2 = require("../page");
|
|
50
49
|
var import_wkAccessibility = require("./wkAccessibility");
|
|
51
50
|
var import_wkConnection = require("./wkConnection");
|
|
52
51
|
var import_wkExecutionContext = require("./wkExecutionContext");
|
|
@@ -76,12 +75,12 @@ class WKPage {
|
|
|
76
75
|
this.rawMouse = new import_wkInput.RawMouseImpl(pageProxySession);
|
|
77
76
|
this.rawTouchscreen = new import_wkInput.RawTouchscreenImpl(pageProxySession);
|
|
78
77
|
this._contextIdToContext = /* @__PURE__ */ new Map();
|
|
79
|
-
this._page = new
|
|
78
|
+
this._page = new import_page.Page(this, browserContext);
|
|
80
79
|
this.rawMouse.setPage(this._page);
|
|
81
80
|
this._workers = new import_wkWorkers.WKWorkers(this._page);
|
|
82
81
|
this._session = void 0;
|
|
83
82
|
this._browserContext = browserContext;
|
|
84
|
-
this._page.on(
|
|
83
|
+
this._page.on(import_page.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame, false));
|
|
85
84
|
this._eventListeners = [
|
|
86
85
|
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Target.targetCreated", this._onTargetCreated.bind(this)),
|
|
87
86
|
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Target.targetDestroyed", this._onTargetDestroyed.bind(this)),
|
|
@@ -93,15 +92,17 @@ class WKPage {
|
|
|
93
92
|
this._firstNonInitialNavigationCommittedFulfill = f;
|
|
94
93
|
this._firstNonInitialNavigationCommittedReject = r;
|
|
95
94
|
});
|
|
95
|
+
this._firstNonInitialNavigationCommittedPromise.catch(() => {
|
|
96
|
+
});
|
|
96
97
|
if (opener && !browserContext._options.noDefaultViewport && opener._nextWindowOpenPopupFeatures) {
|
|
97
98
|
const viewportSize = import_helper.helper.getViewportSizeFromWindowFeatures(opener._nextWindowOpenPopupFeatures);
|
|
98
99
|
opener._nextWindowOpenPopupFeatures = void 0;
|
|
99
100
|
if (viewportSize)
|
|
100
|
-
this._page.
|
|
101
|
+
this._page.setEmulatedSizeFromWindowOpen({ viewport: viewportSize, screen: viewportSize });
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
async _initializePageProxySession() {
|
|
104
|
-
if (this._page.
|
|
105
|
+
if (this._page.isStorageStatePage)
|
|
105
106
|
return;
|
|
106
107
|
const promises = [
|
|
107
108
|
this._pageProxySession.send("Dialog.enable"),
|
|
@@ -156,7 +157,6 @@ class WKPage {
|
|
|
156
157
|
const promises = [
|
|
157
158
|
// Resource tree should be received before first execution context.
|
|
158
159
|
session.send("Runtime.enable"),
|
|
159
|
-
session.send("Runtime.addBinding", { name: import_page.PageBinding.kPlaywrightBinding }),
|
|
160
160
|
session.send("Page.createUserWorld", { name: UTILITY_WORLD_NAME }).catch((_) => {
|
|
161
161
|
}),
|
|
162
162
|
// Worlds are per-process
|
|
@@ -164,12 +164,14 @@ class WKPage {
|
|
|
164
164
|
session.send("Network.enable"),
|
|
165
165
|
this._workers.initializeSession(session)
|
|
166
166
|
];
|
|
167
|
+
if (this._page.browserContext.needsPlaywrightBinding())
|
|
168
|
+
promises.push(session.send("Runtime.addBinding", { name: import_page.PageBinding.kBindingName }));
|
|
167
169
|
if (this._page.needsRequestInterception()) {
|
|
168
170
|
promises.push(session.send("Network.setInterceptionEnabled", { enabled: true }));
|
|
169
171
|
promises.push(session.send("Network.setResourceCachingDisabled", { disabled: true }));
|
|
170
172
|
promises.push(session.send("Network.addInterception", { url: ".*", stage: "request", isRegex: true }));
|
|
171
173
|
}
|
|
172
|
-
if (this._page.
|
|
174
|
+
if (this._page.isStorageStatePage) {
|
|
173
175
|
await Promise.all(promises);
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
@@ -272,7 +274,7 @@ class WKPage {
|
|
|
272
274
|
let errorText = event.error;
|
|
273
275
|
if (errorText.includes("cancelled"))
|
|
274
276
|
errorText += "; maybe frame was detached?";
|
|
275
|
-
this._page.
|
|
277
|
+
this._page.frameManager.frameAbortedNavigation(this._page.mainFrame()._id, errorText, event.loaderId);
|
|
276
278
|
}
|
|
277
279
|
handleWindowOpen(event) {
|
|
278
280
|
this._nextWindowOpenPopupFeatures = event.windowFeatures;
|
|
@@ -303,17 +305,14 @@ class WKPage {
|
|
|
303
305
|
}
|
|
304
306
|
if (targetInfo.isPaused)
|
|
305
307
|
this._pageProxySession.sendMayFail("Target.resume", { targetId: targetInfo.targetId });
|
|
306
|
-
if (pageOrError instanceof
|
|
308
|
+
if (pageOrError instanceof import_page.Page && this._page.mainFrame().url() === "") {
|
|
307
309
|
try {
|
|
308
310
|
await this._firstNonInitialNavigationCommittedPromise;
|
|
309
311
|
} catch (e) {
|
|
310
312
|
pageOrError = e;
|
|
311
313
|
}
|
|
312
|
-
} else {
|
|
313
|
-
this._firstNonInitialNavigationCommittedPromise.catch(() => {
|
|
314
|
-
});
|
|
315
314
|
}
|
|
316
|
-
this._page.reportAsNew(this._opener?._page, pageOrError instanceof
|
|
315
|
+
this._page.reportAsNew(this._opener?._page, pageOrError instanceof import_page.Page ? void 0 : pageOrError);
|
|
317
316
|
} else {
|
|
318
317
|
(0, import_utils.assert)(targetInfo.isProvisional);
|
|
319
318
|
(0, import_utils.assert)(!this._provisionalPage);
|
|
@@ -343,8 +342,8 @@ class WKPage {
|
|
|
343
342
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.willCheckNavigationPolicy", (event) => this._onWillCheckNavigationPolicy(event.frameId)),
|
|
344
343
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.didCheckNavigationPolicy", (event) => this._onDidCheckNavigationPolicy(event.frameId, event.cancel)),
|
|
345
344
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameScheduledNavigation", (event) => this._onFrameScheduledNavigation(event.frameId, event.delay, event.targetIsCurrentFrame)),
|
|
346
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.loadEventFired", (event) => this._page.
|
|
347
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.domContentEventFired", (event) => this._page.
|
|
345
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.loadEventFired", (event) => this._page.frameManager.frameLifecycleEvent(event.frameId, "load")),
|
|
346
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.domContentEventFired", (event) => this._page.frameManager.frameLifecycleEvent(event.frameId, "domcontentloaded")),
|
|
348
347
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextCreated", (event) => this._onExecutionContextCreated(event.context)),
|
|
349
348
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.bindingCalled", (event) => this._onBindingCalled(event.contextId, event.argument)),
|
|
350
349
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Console.messageAdded", (event) => this._onConsoleMessage(event)),
|
|
@@ -356,13 +355,13 @@ class WKPage {
|
|
|
356
355
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.responseReceived", (e) => this._onResponseReceived(this._session, e)),
|
|
357
356
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.loadingFinished", (e) => this._onLoadingFinished(e)),
|
|
358
357
|
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.loadingFailed", (e) => this._onLoadingFailed(this._session, e)),
|
|
359
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketCreated", (e) => this._page.
|
|
360
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketWillSendHandshakeRequest", (e) => this._page.
|
|
361
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketHandshakeResponseReceived", (e) => this._page.
|
|
362
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameSent", (e) => e.response.payloadData && this._page.
|
|
363
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameReceived", (e) => e.response.payloadData && this._page.
|
|
364
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketClosed", (e) => this._page.
|
|
365
|
-
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameError", (e) => this._page.
|
|
358
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketCreated", (e) => this._page.frameManager.onWebSocketCreated(e.requestId, e.url)),
|
|
359
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketWillSendHandshakeRequest", (e) => this._page.frameManager.onWebSocketRequest(e.requestId)),
|
|
360
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketHandshakeResponseReceived", (e) => this._page.frameManager.onWebSocketResponse(e.requestId, e.response.status, e.response.statusText)),
|
|
361
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameSent", (e) => e.response.payloadData && this._page.frameManager.onWebSocketFrameSent(e.requestId, e.response.opcode, e.response.payloadData)),
|
|
362
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameReceived", (e) => e.response.payloadData && this._page.frameManager.webSocketFrameReceived(e.requestId, e.response.opcode, e.response.payloadData)),
|
|
363
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketClosed", (e) => this._page.frameManager.webSocketClosed(e.requestId)),
|
|
364
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameError", (e) => this._page.frameManager.webSocketError(e.requestId, e.errorMessage))
|
|
366
365
|
];
|
|
367
366
|
}
|
|
368
367
|
async _updateState(method, params) {
|
|
@@ -380,47 +379,47 @@ class WKPage {
|
|
|
380
379
|
_onWillCheckNavigationPolicy(frameId) {
|
|
381
380
|
if (this._provisionalPage)
|
|
382
381
|
return;
|
|
383
|
-
this._page.
|
|
382
|
+
this._page.frameManager.frameRequestedNavigation(frameId);
|
|
384
383
|
}
|
|
385
384
|
_onDidCheckNavigationPolicy(frameId, cancel) {
|
|
386
385
|
if (!cancel)
|
|
387
386
|
return;
|
|
388
387
|
if (this._provisionalPage)
|
|
389
388
|
return;
|
|
390
|
-
this._page.
|
|
389
|
+
this._page.frameManager.frameAbortedNavigation(frameId, "Navigation canceled by policy check");
|
|
391
390
|
}
|
|
392
391
|
_onFrameScheduledNavigation(frameId, delay, targetIsCurrentFrame) {
|
|
393
392
|
if (targetIsCurrentFrame)
|
|
394
|
-
this._page.
|
|
393
|
+
this._page.frameManager.frameRequestedNavigation(frameId);
|
|
395
394
|
}
|
|
396
395
|
_handleFrameTree(frameTree) {
|
|
397
396
|
this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null);
|
|
398
397
|
this._onFrameNavigated(frameTree.frame, true);
|
|
399
|
-
this._page.
|
|
400
|
-
this._page.
|
|
398
|
+
this._page.frameManager.frameLifecycleEvent(frameTree.frame.id, "domcontentloaded");
|
|
399
|
+
this._page.frameManager.frameLifecycleEvent(frameTree.frame.id, "load");
|
|
401
400
|
if (!frameTree.childFrames)
|
|
402
401
|
return;
|
|
403
402
|
for (const child of frameTree.childFrames)
|
|
404
403
|
this._handleFrameTree(child);
|
|
405
404
|
}
|
|
406
405
|
_onFrameAttached(frameId, parentFrameId) {
|
|
407
|
-
return this._page.
|
|
406
|
+
return this._page.frameManager.frameAttached(frameId, parentFrameId);
|
|
408
407
|
}
|
|
409
408
|
_onFrameNavigated(framePayload, initial) {
|
|
410
|
-
const frame = this._page.
|
|
409
|
+
const frame = this._page.frameManager.frame(framePayload.id);
|
|
411
410
|
(0, import_utils.assert)(frame);
|
|
412
411
|
this._removeContextsForFrame(frame, true);
|
|
413
412
|
if (!framePayload.parentId)
|
|
414
413
|
this._workers.clear();
|
|
415
|
-
this._page.
|
|
414
|
+
this._page.frameManager.frameCommittedNewDocumentNavigation(framePayload.id, framePayload.url, framePayload.name || "", framePayload.loaderId, initial);
|
|
416
415
|
if (!initial)
|
|
417
416
|
this._firstNonInitialNavigationCommittedFulfill();
|
|
418
417
|
}
|
|
419
418
|
_onFrameNavigatedWithinDocument(frameId, url) {
|
|
420
|
-
this._page.
|
|
419
|
+
this._page.frameManager.frameCommittedSameDocumentNavigation(frameId, url);
|
|
421
420
|
}
|
|
422
421
|
_onFrameDetached(frameId) {
|
|
423
|
-
this._page.
|
|
422
|
+
this._page.frameManager.frameDetached(frameId);
|
|
424
423
|
}
|
|
425
424
|
_removeContextsForFrame(frame, notifyFrame) {
|
|
426
425
|
for (const [contextId, context] of this._contextIdToContext) {
|
|
@@ -434,7 +433,7 @@ class WKPage {
|
|
|
434
433
|
_onExecutionContextCreated(contextPayload) {
|
|
435
434
|
if (this._contextIdToContext.has(contextPayload.id))
|
|
436
435
|
return;
|
|
437
|
-
const frame = this._page.
|
|
436
|
+
const frame = this._page.frameManager.frame(contextPayload.frameId);
|
|
438
437
|
if (!frame)
|
|
439
438
|
return;
|
|
440
439
|
const delegate = new import_wkExecutionContext.WKExecutionContext(this._session, contextPayload.id);
|
|
@@ -453,7 +452,7 @@ class WKPage {
|
|
|
453
452
|
if (!(pageOrError instanceof Error)) {
|
|
454
453
|
const context = this._contextIdToContext.get(contextId);
|
|
455
454
|
if (context)
|
|
456
|
-
await this._page.
|
|
455
|
+
await this._page.onBindingCalled(argument, context);
|
|
457
456
|
}
|
|
458
457
|
}
|
|
459
458
|
async navigateFrame(frame, url, referrer) {
|
|
@@ -523,18 +522,18 @@ class WKPage {
|
|
|
523
522
|
location
|
|
524
523
|
} = this._lastConsoleMessage;
|
|
525
524
|
for (let i = count; i < event.count; ++i)
|
|
526
|
-
this._page.
|
|
525
|
+
this._page.addConsoleMessage(derivedType, handles, location, handles.length ? void 0 : text);
|
|
527
526
|
this._lastConsoleMessage.count = event.count;
|
|
528
527
|
}
|
|
529
528
|
}
|
|
530
529
|
_onDialog(event) {
|
|
531
|
-
this._page.
|
|
530
|
+
this._page.browserContext.dialogManager.dialogDidOpen(new dialog.Dialog(
|
|
532
531
|
this._page,
|
|
533
532
|
event.type,
|
|
534
533
|
event.message,
|
|
535
534
|
async (accept, promptText) => {
|
|
536
535
|
if (event.type === "beforeunload" && !accept)
|
|
537
|
-
this._page.
|
|
536
|
+
this._page.frameManager.frameAbortedNavigation(this._page.mainFrame()._id, "navigation cancelled by beforeunload dialog");
|
|
538
537
|
await this._pageProxySession.send("Dialog.handleJavaScriptDialog", { accept, promptText });
|
|
539
538
|
},
|
|
540
539
|
event.defaultPrompt
|
|
@@ -543,7 +542,7 @@ class WKPage {
|
|
|
543
542
|
async _onFileChooserOpened(event) {
|
|
544
543
|
let handle;
|
|
545
544
|
try {
|
|
546
|
-
const context = await this._page.
|
|
545
|
+
const context = await this._page.frameManager.frame(event.frameId)._mainContext();
|
|
547
546
|
handle = (0, import_wkExecutionContext.createHandle)(context, event.element).asElement();
|
|
548
547
|
} catch (e) {
|
|
549
548
|
return;
|
|
@@ -632,7 +631,7 @@ class WKPage {
|
|
|
632
631
|
await this._forAllSessions((session) => WKPage._setEmulateMedia(session, emulatedMedia.media, colorScheme, reducedMotion, forcedColors, contrast));
|
|
633
632
|
}
|
|
634
633
|
async updateEmulatedViewportSize() {
|
|
635
|
-
this._browserContext._validateEmulatedViewport(this._page.
|
|
634
|
+
this._browserContext._validateEmulatedViewport(this._page.emulatedSize()?.viewport);
|
|
636
635
|
await this._updateViewport();
|
|
637
636
|
}
|
|
638
637
|
async updateUserAgent() {
|
|
@@ -646,11 +645,11 @@ class WKPage {
|
|
|
646
645
|
}
|
|
647
646
|
async _updateViewport() {
|
|
648
647
|
const options = this._browserContext._options;
|
|
649
|
-
const
|
|
650
|
-
if (
|
|
648
|
+
const emulatedSize = this._page.emulatedSize();
|
|
649
|
+
if (!emulatedSize)
|
|
651
650
|
return;
|
|
652
|
-
const viewportSize =
|
|
653
|
-
const screenSize =
|
|
651
|
+
const viewportSize = emulatedSize.viewport;
|
|
652
|
+
const screenSize = emulatedSize.screen;
|
|
654
653
|
const promises = [
|
|
655
654
|
this._pageProxySession.send("Emulation.setDeviceMetricsOverride", {
|
|
656
655
|
width: viewportSize.width,
|
|
@@ -668,6 +667,8 @@ class WKPage {
|
|
|
668
667
|
promises.push(this._pageProxySession.send("Emulation.setOrientationOverride", { angle }));
|
|
669
668
|
}
|
|
670
669
|
await Promise.all(promises);
|
|
670
|
+
if (!this._browserContext._browser?.options.headful && (import_hostPlatform.hostPlatform === "ubuntu22.04-x64" || import_hostPlatform.hostPlatform.startsWith("debian12")))
|
|
671
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
671
672
|
}
|
|
672
673
|
async updateRequestInterception() {
|
|
673
674
|
const enabled = this._page.needsRequestInterception();
|
|
@@ -712,21 +713,41 @@ class WKPage {
|
|
|
712
713
|
async addInitScript(initScript) {
|
|
713
714
|
await this._updateBootstrapScript();
|
|
714
715
|
}
|
|
715
|
-
async removeInitScripts() {
|
|
716
|
+
async removeInitScripts(initScripts) {
|
|
716
717
|
await this._updateBootstrapScript();
|
|
717
718
|
}
|
|
719
|
+
async exposePlaywrightBinding() {
|
|
720
|
+
await this._updateState("Runtime.addBinding", { name: import_page.PageBinding.kBindingName });
|
|
721
|
+
}
|
|
718
722
|
_calculateBootstrapScript() {
|
|
719
723
|
const scripts = [];
|
|
720
|
-
if (!this._page.
|
|
724
|
+
if (!this._page.browserContext._options.isMobile) {
|
|
721
725
|
scripts.push("delete window.orientation");
|
|
722
726
|
scripts.push("delete window.ondevicemotion");
|
|
723
727
|
scripts.push("delete window.ondeviceorientation");
|
|
724
728
|
}
|
|
725
729
|
scripts.push('if (!window.safari) window.safari = { pushNotification: { toString() { return "[object SafariRemoteNotification]"; } } };');
|
|
726
730
|
scripts.push("if (!window.GestureEvent) window.GestureEvent = function GestureEvent() {};");
|
|
731
|
+
scripts.push(this._publicKeyCredentialScript());
|
|
727
732
|
scripts.push(...this._page.allInitScripts().map((script) => script.source));
|
|
728
733
|
return scripts.join(";\n");
|
|
729
734
|
}
|
|
735
|
+
_publicKeyCredentialScript() {
|
|
736
|
+
function polyfill() {
|
|
737
|
+
window.PublicKeyCredential ??= {
|
|
738
|
+
async getClientCapabilities() {
|
|
739
|
+
return {};
|
|
740
|
+
},
|
|
741
|
+
async isConditionalMediationAvailable() {
|
|
742
|
+
return false;
|
|
743
|
+
},
|
|
744
|
+
async isUserVerifyingPlatformAuthenticatorAvailable() {
|
|
745
|
+
return false;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
return `(${polyfill.toString()})();`;
|
|
750
|
+
}
|
|
730
751
|
async _updateBootstrapScript() {
|
|
731
752
|
await this._updateState("Page.setBootstrapScript", { source: this._calculateBootstrapScript() });
|
|
732
753
|
}
|
|
@@ -741,7 +762,7 @@ class WKPage {
|
|
|
741
762
|
await this._session.send("Page.setDefaultBackgroundColorOverride", { color });
|
|
742
763
|
}
|
|
743
764
|
_toolbarHeight() {
|
|
744
|
-
if (this._page.
|
|
765
|
+
if (this._page.browserContext._browser?.options.headful)
|
|
745
766
|
return import_hostPlatform.hostPlatform === "mac10.15" ? 55 : 59;
|
|
746
767
|
return 0;
|
|
747
768
|
}
|
|
@@ -765,8 +786,8 @@ class WKPage {
|
|
|
765
786
|
validateScreenshotDimension(side, omitDeviceScaleFactor) {
|
|
766
787
|
if (process.platform === "darwin")
|
|
767
788
|
return;
|
|
768
|
-
if (!omitDeviceScaleFactor && this._page.
|
|
769
|
-
side = Math.ceil(side * this._page.
|
|
789
|
+
if (!omitDeviceScaleFactor && this._page.browserContext._options.deviceScaleFactor)
|
|
790
|
+
side = Math.ceil(side * this._page.browserContext._options.deviceScaleFactor);
|
|
770
791
|
if (side > 32767)
|
|
771
792
|
throw new Error("Cannot take screenshot larger than 32767 pixels on any dimension");
|
|
772
793
|
}
|
|
@@ -775,7 +796,7 @@ class WKPage {
|
|
|
775
796
|
const omitDeviceScaleFactor = scale === "css";
|
|
776
797
|
this.validateScreenshotDimension(rect.width, omitDeviceScaleFactor);
|
|
777
798
|
this.validateScreenshotDimension(rect.height, omitDeviceScaleFactor);
|
|
778
|
-
const result = await this._session.send("Page.snapshotRect", { ...rect, coordinateSystem: documentRect ? "Page" : "Viewport", omitDeviceScaleFactor });
|
|
799
|
+
const result = await progress.race(this._session.send("Page.snapshotRect", { ...rect, coordinateSystem: documentRect ? "Page" : "Viewport", omitDeviceScaleFactor }));
|
|
779
800
|
const prefix = "data:image/png;base64,";
|
|
780
801
|
let buffer = Buffer.from(result.dataURL.substr(prefix.length), "base64");
|
|
781
802
|
if (format === "jpeg")
|
|
@@ -788,7 +809,7 @@ class WKPage {
|
|
|
788
809
|
});
|
|
789
810
|
if (!nodeInfo.contentFrameId)
|
|
790
811
|
return null;
|
|
791
|
-
return this._page.
|
|
812
|
+
return this._page.frameManager.frame(nodeInfo.contentFrameId);
|
|
792
813
|
}
|
|
793
814
|
async getOwnerFrame(handle) {
|
|
794
815
|
if (!handle._objectId)
|
|
@@ -843,7 +864,7 @@ class WKPage {
|
|
|
843
864
|
this._pageProxySession.send("Screencast.screencastFrameAck", { generation }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
844
865
|
});
|
|
845
866
|
const buffer = Buffer.from(event.data, "base64");
|
|
846
|
-
this._page.emit(
|
|
867
|
+
this._page.emit(import_page.Page.Events.ScreencastFrame, {
|
|
847
868
|
buffer,
|
|
848
869
|
width: event.deviceWidth,
|
|
849
870
|
height: event.deviceHeight
|
|
@@ -887,7 +908,7 @@ class WKPage {
|
|
|
887
908
|
}
|
|
888
909
|
async inputActionEpilogue() {
|
|
889
910
|
}
|
|
890
|
-
async resetForReuse() {
|
|
911
|
+
async resetForReuse(progress) {
|
|
891
912
|
}
|
|
892
913
|
async getFrameElement(frame) {
|
|
893
914
|
const parent = frame.parentFrame();
|
|
@@ -945,7 +966,7 @@ class WKPage {
|
|
|
945
966
|
redirectedFrom = request2;
|
|
946
967
|
}
|
|
947
968
|
}
|
|
948
|
-
const frame = redirectedFrom ? redirectedFrom.request.frame() : this._page.
|
|
969
|
+
const frame = redirectedFrom ? redirectedFrom.request.frame() : this._page.frameManager.frame(event.frameId);
|
|
949
970
|
if (!frame)
|
|
950
971
|
return;
|
|
951
972
|
const isNavigationRequest = event.type === "Document";
|
|
@@ -957,7 +978,7 @@ class WKPage {
|
|
|
957
978
|
request.request.setRawRequestHeaders(null);
|
|
958
979
|
}
|
|
959
980
|
this._requestIdToRequest.set(event.requestId, request);
|
|
960
|
-
this._page.
|
|
981
|
+
this._page.frameManager.requestStarted(request.request, route);
|
|
961
982
|
}
|
|
962
983
|
_handleRequestRedirect(request, requestId, responsePayload, timestamp) {
|
|
963
984
|
const response = request.createResponse(responsePayload);
|
|
@@ -967,8 +988,8 @@ class WKPage {
|
|
|
967
988
|
response.setEncodedBodySize(null);
|
|
968
989
|
response._requestFinished(responsePayload.timing ? import_helper.helper.secondsToRoundishMillis(timestamp - request._timestamp) : -1);
|
|
969
990
|
this._requestIdToRequest.delete(requestId);
|
|
970
|
-
this._page.
|
|
971
|
-
this._page.
|
|
991
|
+
this._page.frameManager.requestReceivedResponse(response);
|
|
992
|
+
this._page.frameManager.reportRequestFinished(request.request, response);
|
|
972
993
|
}
|
|
973
994
|
_onRequestIntercepted(session, event) {
|
|
974
995
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
@@ -990,7 +1011,7 @@ class WKPage {
|
|
|
990
1011
|
return;
|
|
991
1012
|
this._requestIdToResponseReceivedPayloadEvent.set(event.requestId, event);
|
|
992
1013
|
const response = request.createResponse(event.response);
|
|
993
|
-
this._page.
|
|
1014
|
+
this._page.frameManager.requestReceivedResponse(response);
|
|
994
1015
|
if (response.status() === 204 && request.request.isNavigationRequest()) {
|
|
995
1016
|
this._onLoadingFailed(session, {
|
|
996
1017
|
requestId: event.requestId,
|
|
@@ -1023,7 +1044,7 @@ class WKPage {
|
|
|
1023
1044
|
}
|
|
1024
1045
|
this._requestIdToResponseReceivedPayloadEvent.delete(event.requestId);
|
|
1025
1046
|
this._requestIdToRequest.delete(event.requestId);
|
|
1026
|
-
this._page.
|
|
1047
|
+
this._page.frameManager.reportRequestFinished(request.request, response);
|
|
1027
1048
|
}
|
|
1028
1049
|
_onLoadingFailed(session, event) {
|
|
1029
1050
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
@@ -1046,7 +1067,7 @@ class WKPage {
|
|
|
1046
1067
|
}
|
|
1047
1068
|
this._requestIdToRequest.delete(event.requestId);
|
|
1048
1069
|
request.request._setFailureText(event.errorText);
|
|
1049
|
-
this._page.
|
|
1070
|
+
this._page.frameManager.requestFailed(request.request, event.errorText.includes("cancelled"));
|
|
1050
1071
|
}
|
|
1051
1072
|
async _grantPermissions(origin, permissions) {
|
|
1052
1073
|
const webPermissionToProtocol = /* @__PURE__ */ new Map([
|
|
@@ -33,7 +33,7 @@ class WKProvisionalPage {
|
|
|
33
33
|
const overrideFrameId = (handler) => {
|
|
34
34
|
return (payload) => {
|
|
35
35
|
if (payload.frameId)
|
|
36
|
-
payload.frameId = this._wkPage._page.
|
|
36
|
+
payload.frameId = this._wkPage._page.frameManager.mainFrame()._id;
|
|
37
37
|
handler(payload);
|
|
38
38
|
};
|
|
39
39
|
};
|
|
@@ -46,15 +46,15 @@ class WKWorkers {
|
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
this._workerSessions.set(event.workerId, workerSession);
|
|
49
|
-
worker.
|
|
50
|
-
this._page.
|
|
49
|
+
worker.createExecutionContext(new import_wkExecutionContext.WKExecutionContext(workerSession, void 0));
|
|
50
|
+
this._page.addWorker(event.workerId, worker);
|
|
51
51
|
workerSession.on("Console.messageAdded", (event2) => this._onConsoleMessage(worker, event2));
|
|
52
52
|
Promise.all([
|
|
53
53
|
workerSession.send("Runtime.enable"),
|
|
54
54
|
workerSession.send("Console.enable"),
|
|
55
55
|
session.send("Worker.initialized", { workerId: event.workerId })
|
|
56
56
|
]).catch((e) => {
|
|
57
|
-
this._page.
|
|
57
|
+
this._page.removeWorker(event.workerId);
|
|
58
58
|
});
|
|
59
59
|
}),
|
|
60
60
|
import_eventsHelper.eventsHelper.addEventListener(session, "Worker.dispatchMessageFromWorker", (event) => {
|
|
@@ -69,12 +69,12 @@ class WKWorkers {
|
|
|
69
69
|
return;
|
|
70
70
|
workerSession.dispose();
|
|
71
71
|
this._workerSessions.delete(event.workerId);
|
|
72
|
-
this._page.
|
|
72
|
+
this._page.removeWorker(event.workerId);
|
|
73
73
|
})
|
|
74
74
|
];
|
|
75
75
|
}
|
|
76
76
|
clear() {
|
|
77
|
-
this._page.
|
|
77
|
+
this._page.clearWorkers();
|
|
78
78
|
this._workerSessions.clear();
|
|
79
79
|
}
|
|
80
80
|
async initializeSession(session) {
|
|
@@ -88,14 +88,14 @@ class WKWorkers {
|
|
|
88
88
|
else if (type === "timing")
|
|
89
89
|
derivedType = "timeEnd";
|
|
90
90
|
const handles = (parameters || []).map((p) => {
|
|
91
|
-
return (0, import_wkExecutionContext.createHandle)(worker.
|
|
91
|
+
return (0, import_wkExecutionContext.createHandle)(worker.existingExecutionContext, p);
|
|
92
92
|
});
|
|
93
93
|
const location = {
|
|
94
94
|
url: url || "",
|
|
95
95
|
lineNumber: (lineNumber || 1) - 1,
|
|
96
96
|
columnNumber: (columnNumber || 1) - 1
|
|
97
97
|
};
|
|
98
|
-
this._page.
|
|
98
|
+
this._page.addConsoleMessage(derivedType, handles, location, handles.length ? void 0 : text);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
// Annotate the CommonJS export names for ESM import in node:
|