@checkly/playwright-core 1.42.17 → 1.47.20-alpha
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 +144 -109
- package/browsers.json +15 -25
- package/lib/androidServerImpl.js +1 -1
- package/lib/browserServerImpl.js +1 -1
- package/lib/cli/driver.js +1 -3
- package/lib/cli/program.js +5 -10
- package/lib/client/android.js +1 -1
- package/lib/client/api.js +7 -0
- package/lib/client/browserContext.js +37 -5
- package/lib/client/browserType.js +19 -11
- package/lib/client/channelOwner.js +19 -16
- package/lib/client/clientInstrumentation.js +17 -7
- package/lib/client/clock.js +68 -0
- package/lib/client/connection.js +9 -6
- package/lib/client/electron.js +7 -5
- package/lib/client/elementHandle.js +44 -14
- package/lib/client/eventEmitter.js +314 -0
- package/lib/client/fetch.js +81 -28
- package/lib/client/frame.js +2 -4
- package/lib/client/jsHandle.js +7 -1
- package/lib/client/locator.js +9 -0
- package/lib/client/network.js +12 -9
- package/lib/client/page.js +45 -23
- package/lib/client/playwright.js +3 -0
- package/lib/client/tracing.js +7 -4
- package/lib/common/socksProxy.js +2 -2
- package/lib/generated/clockSource.js +7 -0
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/recorderSource.js +1 -1
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/protocol/serializers.js +12 -11
- package/lib/protocol/validator.js +137 -55
- package/lib/server/bidi/bidiBrowser.js +296 -0
- package/lib/server/bidi/bidiConnection.js +206 -0
- package/lib/server/bidi/bidiExecutionContext.js +162 -0
- package/lib/server/bidi/bidiFirefox.js +110 -0
- package/lib/server/bidi/bidiInput.js +174 -0
- package/lib/server/bidi/bidiNetworkManager.js +304 -0
- package/lib/server/bidi/bidiPage.js +456 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +93 -0
- package/lib/server/bidi/third_party/bidiKeyboard.js +238 -0
- package/lib/server/bidi/third_party/bidiProtocol.js +139 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +144 -0
- package/lib/server/browser.js +9 -1
- package/lib/server/browserContext.js +97 -22
- package/lib/server/browserType.js +27 -20
- package/lib/server/chromium/chromium.js +30 -15
- package/lib/server/chromium/chromiumSwitches.js +6 -3
- package/lib/server/chromium/crBrowser.js +11 -17
- package/lib/server/chromium/crConnection.js +2 -2
- package/lib/server/chromium/crDragDrop.js +28 -29
- package/lib/server/chromium/crNetworkManager.js +130 -84
- package/lib/server/chromium/crPage.js +34 -79
- package/lib/server/chromium/crProtocolHelper.js +3 -1
- package/lib/server/chromium/crServiceWorker.js +20 -23
- package/lib/server/chromium/videoRecorder.js +1 -1
- package/lib/server/clock.js +125 -0
- package/lib/server/codegen/csharp.js +299 -0
- package/lib/server/codegen/java.js +235 -0
- package/lib/server/codegen/javascript.js +223 -0
- package/lib/server/codegen/jsonl.js +47 -0
- package/lib/server/codegen/language.js +76 -0
- package/lib/server/codegen/languages.js +30 -0
- package/lib/server/codegen/python.js +265 -0
- package/lib/server/codegen/types.js +5 -0
- package/lib/server/debugController.js +3 -5
- package/lib/server/deviceDescriptors.js +9 -4
- package/lib/server/deviceDescriptorsSource.json +239 -119
- package/lib/server/dispatchers/androidDispatcher.js +1 -1
- package/lib/server/dispatchers/browserContextDispatcher.js +51 -7
- package/lib/server/dispatchers/dispatcher.js +36 -40
- package/lib/server/dispatchers/frameDispatcher.js +1 -2
- package/lib/server/dispatchers/jsHandleDispatcher.js +1 -1
- package/lib/server/dispatchers/jsonPipeDispatcher.js +4 -6
- package/lib/server/dispatchers/localUtilsDispatcher.js +19 -5
- package/lib/server/dispatchers/networkDispatchers.js +2 -2
- package/lib/server/dispatchers/pageDispatcher.js +5 -2
- package/lib/server/dispatchers/playwrightDispatcher.js +1 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +8 -5
- package/lib/server/dom.js +90 -53
- package/lib/server/electron/electron.js +21 -4
- package/lib/server/fetch.js +74 -25
- package/lib/server/fileUploadUtils.js +7 -3
- package/lib/server/firefox/ffBrowser.js +36 -25
- package/lib/server/firefox/ffConnection.js +2 -2
- package/lib/server/firefox/ffNetworkManager.js +6 -4
- package/lib/server/firefox/ffPage.js +22 -24
- package/lib/server/firefox/firefox.js +25 -6
- package/lib/server/frameSelectors.js +2 -2
- package/lib/server/frames.js +205 -159
- package/lib/server/har/harTracer.js +4 -12
- package/lib/server/helper.js +3 -3
- package/lib/server/index.js +18 -0
- package/lib/server/input.js +18 -8
- package/lib/server/instrumentation.js +0 -4
- package/lib/server/isomorphic/utilityScriptSerializers.js +19 -5
- package/lib/server/javascript.js +3 -2
- package/lib/server/launchApp.js +3 -2
- package/lib/server/network.js +14 -4
- package/lib/server/page.js +75 -46
- package/lib/server/playwright.js +5 -2
- package/lib/server/recorder/codeGenerator.js +2 -1
- package/lib/server/recorder/contextRecorder.js +316 -0
- package/lib/server/recorder/csharp.js +2 -1
- package/lib/server/recorder/java.js +2 -1
- package/lib/server/recorder/javascript.js +2 -1
- package/lib/server/recorder/jsonl.js +2 -1
- package/lib/server/recorder/language.js +2 -1
- package/lib/server/recorder/python.js +2 -1
- package/lib/server/recorder/recorderApp.js +14 -5
- package/lib/server/recorder/recorderCollection.js +127 -0
- package/lib/server/recorder/recorderRunner.js +177 -0
- package/lib/server/recorder/recorderUtils.js +23 -0
- package/lib/server/recorder/throttledFile.js +46 -0
- package/lib/server/recorder/utils.js +2 -1
- package/lib/server/recorder.js +42 -418
- package/lib/server/registry/index.js +99 -100
- package/lib/server/registry/nativeDeps.js +107 -0
- package/lib/server/screenshotter.js +6 -12
- package/lib/server/socksClientCertificatesInterceptor.js +328 -0
- package/lib/server/trace/recorder/snapshotter.js +4 -1
- package/lib/server/trace/recorder/tracing.js +27 -96
- package/lib/server/trace/viewer/traceViewer.js +54 -67
- package/lib/server/transport.js +1 -1
- package/lib/server/webkit/webkit.js +5 -5
- package/lib/server/webkit/wkBrowser.js +14 -14
- package/lib/server/webkit/wkConnection.js +3 -3
- package/lib/server/webkit/wkInterceptableRequest.js +8 -4
- package/lib/server/webkit/wkPage.js +52 -34
- package/lib/server/webkit/wkProvisionalPage.js +36 -1
- package/lib/utils/crypto.js +141 -0
- package/lib/utils/debugLogger.js +2 -0
- package/lib/utils/env.js +4 -2
- package/lib/utils/expectUtils.js +33 -0
- package/lib/utils/fileUtils.js +140 -1
- package/lib/utils/glob.js +2 -1
- package/lib/utils/happy-eyeballs.js +29 -2
- package/lib/utils/hostPlatform.js +13 -4
- package/lib/utils/httpServer.js +54 -13
- package/lib/utils/index.js +53 -31
- package/lib/utils/isomorphic/cssTokenizer.js +1 -1
- package/lib/utils/isomorphic/locatorParser.js +1 -1
- package/lib/utils/isomorphic/mimeType.js +29 -0
- package/lib/utils/isomorphic/stringUtils.js +28 -1
- package/lib/utils/isomorphic/urlMatch.js +120 -0
- package/lib/utils/mimeType.js +2 -1
- package/lib/utils/network.js +7 -35
- package/lib/utils/stackTrace.js +2 -4
- package/lib/utils/timeoutRunner.js +11 -76
- package/lib/utils/zones.js +23 -60
- package/lib/utilsBundle.js +2 -1
- package/lib/utilsBundleImpl/index.js +33 -31
- package/lib/vite/htmlReport/index.html +12 -12
- package/lib/vite/recorder/assets/codeMirrorModule-C-fQ5QZD.js +24 -0
- package/lib/vite/recorder/assets/{codicon-zGuYmc9o.ttf → codicon-DCmgc-ay.ttf} +0 -0
- package/lib/vite/recorder/assets/index-B-MT5gKo.css +1 -0
- package/lib/vite/recorder/assets/index-D-5S5PPN.js +47 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-5yiV-3wl.js +16831 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-B7Z3vq11.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-C6p3E9Zg.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-CqYUz5ms.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-Dx6AXgMV.js +16838 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-T_sdMrbM.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-V7N6ppkd.js +15585 -0
- package/lib/vite/traceViewer/assets/testServerConnection-D-tXL3sj.js +224 -0
- package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +1 -0
- package/lib/vite/traceViewer/assets/workbench-Bjkiwcr1.js +19119 -0
- package/lib/vite/traceViewer/assets/workbench-C43LWZEX.js +72 -0
- package/lib/vite/traceViewer/assets/workbench-C5OQh9VX.js +19119 -0
- package/lib/vite/traceViewer/assets/workbench-DrQjKdyE.js +72 -0
- package/lib/vite/traceViewer/assets/workbench-caTaZnzx.js +72 -0
- package/lib/vite/traceViewer/assets/workbench-u2lRPMOT.js +72 -0
- package/lib/vite/traceViewer/assets/wsPort-EUvw-dwH.js +18540 -0
- package/lib/vite/traceViewer/assets/xtermModule-CZ7sDYXB.js +6529 -0
- package/lib/vite/traceViewer/assets/xtermModule-_6TC5FYT.js +6529 -0
- package/lib/vite/traceViewer/codeMirrorModule.Cy8X9Wtw.css +344 -0
- package/lib/vite/traceViewer/codeMirrorModule.svF_VrcJ.css +344 -0
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/embedded.BQq6Psnz.js +104 -0
- package/lib/vite/traceViewer/embedded.BVDVQOzc.js +2 -0
- package/lib/vite/traceViewer/embedded.Bn8Ptzv6.js +2 -0
- package/lib/vite/traceViewer/embedded.CvhnUgIi.js +2 -0
- package/lib/vite/traceViewer/embedded.D27cnKiB.js +104 -0
- package/lib/vite/traceViewer/embedded.DPqrDeET.js +2 -0
- package/lib/vite/traceViewer/embedded.DjZq4InJ.css +68 -0
- package/lib/vite/traceViewer/embedded.html +16 -0
- package/lib/vite/traceViewer/embedded.w7WN2u1R.css +1 -0
- package/lib/vite/traceViewer/index.5mge2rY_.css +124 -0
- package/lib/vite/traceViewer/index.6KJ-JQ0L.js +180 -0
- package/lib/vite/traceViewer/index.B8dgQwuN.js +2 -0
- package/lib/vite/traceViewer/index.BGj8jY3H.js +2 -0
- package/lib/vite/traceViewer/index.C0EgJ4oW.js +195 -0
- package/lib/vite/traceViewer/index.CUpI-BFe.js +195 -0
- package/lib/vite/traceViewer/{index.-g_5lMbJ.css → index.CrbWWHbf.css} +1 -1
- package/lib/vite/traceViewer/index.QanXxRUb.css +131 -0
- package/lib/vite/traceViewer/index._cX8k4co.js +2 -0
- package/lib/vite/traceViewer/index.html +5 -4
- package/lib/vite/traceViewer/index.pMAN88y-.js +2 -0
- package/lib/vite/traceViewer/snapshot.html +1 -1
- package/lib/vite/traceViewer/sw.bundle.js +3 -4
- package/lib/vite/traceViewer/uiMode.D-tg1Oci.js +1730 -0
- package/lib/vite/traceViewer/uiMode.D3cNFP6u.css +1 -0
- package/lib/vite/traceViewer/uiMode.DKjMBMlc.js +1730 -0
- package/lib/vite/traceViewer/uiMode.DVWUEIHq.css +1424 -0
- package/lib/vite/traceViewer/uiMode.DVrL7a1K.js +10 -0
- package/lib/vite/traceViewer/uiMode.Dg9oJCQU.js +10 -0
- package/lib/vite/traceViewer/uiMode.DwZAzstF.js +10 -0
- package/lib/vite/traceViewer/uiMode.html +5 -4
- package/lib/vite/traceViewer/uiMode.iq7CyYy7.js +1490 -0
- package/lib/vite/traceViewer/uiMode.jY2s-9ps.js +10 -0
- package/lib/vite/traceViewer/uiMode.xvJHbkzl.css +1324 -0
- package/lib/vite/traceViewer/workbench.B3X2QtYa.css +3702 -0
- package/lib/vite/traceViewer/workbench.DyTpxWVb.css +1 -0
- package/lib/vite/traceViewer/wsPort.p5jUwABW.css +3450 -0
- package/lib/vite/traceViewer/xtermModule.4oRVGWQ-.css +209 -0
- package/lib/vite/traceViewer/xtermModule.OKEVRlkP.css +209 -0
- package/package.json +2 -2
- package/types/protocol.d.ts +960 -78
- package/types/structs.d.ts +1 -1
- package/types/types.d.ts +3083 -2448
- package/lib/vite/recorder/assets/codeMirrorModule-I9ks4y7D.js +0 -24
- package/lib/vite/recorder/assets/index-ljsTwXtJ.css +0 -1
- package/lib/vite/recorder/assets/index-yg8ypzl6.js +0 -47
- package/lib/vite/traceViewer/assets/codeMirrorModule-0bpaqixv.js +0 -24
- package/lib/vite/traceViewer/assets/wsPort-_JBDEilC.js +0 -69
- package/lib/vite/traceViewer/index.u51inEcm.js +0 -2
- package/lib/vite/traceViewer/uiMode.Fb0bNA4H.js +0 -10
- package/lib/vite/traceViewer/uiMode.pWy0Re7G.css +0 -1
- package/lib/vite/traceViewer/wsPort.zR1WIy9-.css +0 -1
- /package/lib/vite/recorder/assets/{codeMirrorModule-Hs9-1ZG4.css → codeMirrorModule-ez37Vkbh.css} +0 -0
- /package/lib/vite/traceViewer/assets/{xtermModule-Yt6xwiJ_.js → xtermModule-BeNbaIVa.js} +0 -0
- /package/lib/vite/traceViewer/{codeMirrorModule.Hs9-1ZG4.css → codeMirrorModule.ez37Vkbh.css} +0 -0
- /package/lib/vite/traceViewer/{xtermModule.0lwXJFHT.css → xtermModule.DSXBckUd.css} +0 -0
package/lib/client/page.js
CHANGED
|
@@ -7,10 +7,8 @@ exports.Page = exports.BindingCall = void 0;
|
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _errors = require("./errors");
|
|
10
|
-
var _network = require("../utils/network");
|
|
11
10
|
var _timeoutSettings = require("../common/timeoutSettings");
|
|
12
11
|
var _utils = require("../utils");
|
|
13
|
-
var _fileUtils = require("../utils/fileUtils");
|
|
14
12
|
var _accessibility = require("./accessibility");
|
|
15
13
|
var _artifact = require("./artifact");
|
|
16
14
|
var _channelOwner = require("./channelOwner");
|
|
@@ -23,8 +21,7 @@ var _fileChooser = require("./fileChooser");
|
|
|
23
21
|
var _frame = require("./frame");
|
|
24
22
|
var _input = require("./input");
|
|
25
23
|
var _jsHandle = require("./jsHandle");
|
|
26
|
-
var
|
|
27
|
-
var _network2 = require("./network");
|
|
24
|
+
var _network = require("./network");
|
|
28
25
|
var _video = require("./video");
|
|
29
26
|
var _waiter = require("./waiter");
|
|
30
27
|
var _worker = require("./worker");
|
|
@@ -72,6 +69,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
72
69
|
this.mouse = void 0;
|
|
73
70
|
this.request = void 0;
|
|
74
71
|
this.touchscreen = void 0;
|
|
72
|
+
this.clock = void 0;
|
|
75
73
|
this._bindings = new Map();
|
|
76
74
|
this._timeoutSettings = void 0;
|
|
77
75
|
this._video = null;
|
|
@@ -87,6 +85,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
87
85
|
this.mouse = new _input.Mouse(this);
|
|
88
86
|
this.request = this._browserContext.request;
|
|
89
87
|
this.touchscreen = new _input.Touchscreen(this);
|
|
88
|
+
this.clock = this._browserContext.clock;
|
|
90
89
|
this._mainFrame = _frame.Frame.from(initializer.mainFrame);
|
|
91
90
|
this._mainFrame._page = this;
|
|
92
91
|
this._frames.add(this._mainFrame);
|
|
@@ -121,7 +120,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
121
120
|
}) => this._onLocatorHandlerTriggered(uid));
|
|
122
121
|
this._channel.on('route', ({
|
|
123
122
|
route
|
|
124
|
-
}) => this._onRoute(
|
|
123
|
+
}) => this._onRoute(_network.Route.from(route)));
|
|
125
124
|
this._channel.on('video', ({
|
|
126
125
|
artifact
|
|
127
126
|
}) => {
|
|
@@ -130,7 +129,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
130
129
|
});
|
|
131
130
|
this._channel.on('webSocket', ({
|
|
132
131
|
webSocket
|
|
133
|
-
}) => this.emit(_events.Events.Page.WebSocket,
|
|
132
|
+
}) => this.emit(_events.Events.Page.WebSocket, _network.WebSocket.from(webSocket)));
|
|
134
133
|
this._channel.on('worker', ({
|
|
135
134
|
worker
|
|
136
135
|
}) => this._onWorker(_worker.Worker.from(worker)));
|
|
@@ -206,7 +205,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
206
205
|
(0, _utils.assert)(name || url, 'Either name or url matcher should be specified');
|
|
207
206
|
return this.frames().find(f => {
|
|
208
207
|
if (name) return f.name() === name;
|
|
209
|
-
return (0,
|
|
208
|
+
return (0, _utils.urlMatches)(this._browserContext._options.baseURL, f.url(), url);
|
|
210
209
|
}) || null;
|
|
211
210
|
}
|
|
212
211
|
frames() {
|
|
@@ -284,7 +283,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
284
283
|
this._bindings.set(name, callback);
|
|
285
284
|
}
|
|
286
285
|
async setExtraHTTPHeaders(headers) {
|
|
287
|
-
(0,
|
|
286
|
+
(0, _network.validateHeaders)(headers);
|
|
288
287
|
await this._channel.setExtraHTTPHeaders({
|
|
289
288
|
headers: (0, _utils.headersObjectToArray)(headers)
|
|
290
289
|
});
|
|
@@ -303,30 +302,53 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
303
302
|
}
|
|
304
303
|
async reload(options = {}) {
|
|
305
304
|
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
|
|
306
|
-
return
|
|
305
|
+
return _network.Response.fromNullable((await this._channel.reload({
|
|
307
306
|
...options,
|
|
308
307
|
waitUntil
|
|
309
308
|
})).response);
|
|
310
309
|
}
|
|
311
|
-
async addLocatorHandler(locator, handler) {
|
|
310
|
+
async addLocatorHandler(locator, handler, options = {}) {
|
|
312
311
|
if (locator._frame !== this._mainFrame) throw new Error(`Locator must belong to the main frame of this page`);
|
|
312
|
+
if (options.times === 0) return;
|
|
313
313
|
const {
|
|
314
314
|
uid
|
|
315
315
|
} = await this._channel.registerLocatorHandler({
|
|
316
|
-
selector: locator._selector
|
|
316
|
+
selector: locator._selector,
|
|
317
|
+
noWaitAfter: options.noWaitAfter
|
|
318
|
+
});
|
|
319
|
+
this._locatorHandlers.set(uid, {
|
|
320
|
+
locator,
|
|
321
|
+
handler,
|
|
322
|
+
times: options.times
|
|
317
323
|
});
|
|
318
|
-
this._locatorHandlers.set(uid, handler);
|
|
319
324
|
}
|
|
320
325
|
async _onLocatorHandlerTriggered(uid) {
|
|
326
|
+
let remove = false;
|
|
321
327
|
try {
|
|
322
328
|
const handler = this._locatorHandlers.get(uid);
|
|
323
|
-
|
|
329
|
+
if (handler && handler.times !== 0) {
|
|
330
|
+
if (handler.times !== undefined) handler.times--;
|
|
331
|
+
await handler.handler(handler.locator);
|
|
332
|
+
}
|
|
333
|
+
remove = (handler === null || handler === void 0 ? void 0 : handler.times) === 0;
|
|
324
334
|
} finally {
|
|
335
|
+
if (remove) this._locatorHandlers.delete(uid);
|
|
325
336
|
this._wrapApiCall(() => this._channel.resolveLocatorHandlerNoReply({
|
|
326
|
-
uid
|
|
337
|
+
uid,
|
|
338
|
+
remove
|
|
327
339
|
}), true).catch(() => {});
|
|
328
340
|
}
|
|
329
341
|
}
|
|
342
|
+
async removeLocatorHandler(locator) {
|
|
343
|
+
for (const [uid, data] of this._locatorHandlers) {
|
|
344
|
+
if (data.locator._equals(locator)) {
|
|
345
|
+
this._locatorHandlers.delete(uid);
|
|
346
|
+
await this._channel.unregisterLocatorHandler({
|
|
347
|
+
uid
|
|
348
|
+
}).catch(() => {});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
330
352
|
async waitForLoadState(state, options) {
|
|
331
353
|
return await this._mainFrame.waitForLoadState(state, options);
|
|
332
354
|
}
|
|
@@ -338,7 +360,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
338
360
|
}
|
|
339
361
|
async waitForRequest(urlOrPredicate, options = {}) {
|
|
340
362
|
const predicate = async request => {
|
|
341
|
-
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0,
|
|
363
|
+
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _utils.urlMatches)(this._browserContext._options.baseURL, request.url(), urlOrPredicate);
|
|
342
364
|
return await urlOrPredicate(request);
|
|
343
365
|
};
|
|
344
366
|
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
@@ -350,7 +372,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
350
372
|
}
|
|
351
373
|
async waitForResponse(urlOrPredicate, options = {}) {
|
|
352
374
|
const predicate = async response => {
|
|
353
|
-
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0,
|
|
375
|
+
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _utils.urlMatches)(this._browserContext._options.baseURL, response.url(), urlOrPredicate);
|
|
354
376
|
return await urlOrPredicate(response);
|
|
355
377
|
};
|
|
356
378
|
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
@@ -382,14 +404,14 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
382
404
|
}
|
|
383
405
|
async goBack(options = {}) {
|
|
384
406
|
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
|
|
385
|
-
return
|
|
407
|
+
return _network.Response.fromNullable((await this._channel.goBack({
|
|
386
408
|
...options,
|
|
387
409
|
waitUntil
|
|
388
410
|
})).response);
|
|
389
411
|
}
|
|
390
412
|
async goForward(options = {}) {
|
|
391
413
|
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
|
|
392
|
-
return
|
|
414
|
+
return _network.Response.fromNullable((await this._channel.goForward({
|
|
393
415
|
...options,
|
|
394
416
|
waitUntil
|
|
395
417
|
})).response);
|
|
@@ -422,7 +444,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
422
444
|
});
|
|
423
445
|
}
|
|
424
446
|
async route(url, handler, options = {}) {
|
|
425
|
-
this._routes.unshift(new
|
|
447
|
+
this._routes.unshift(new _network.RouteHandler(this._browserContext._options.baseURL, url, handler, options.times));
|
|
426
448
|
await this._updateInterceptionPatterns();
|
|
427
449
|
}
|
|
428
450
|
async routeFromHAR(har, options = {}) {
|
|
@@ -460,7 +482,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
460
482
|
await Promise.all(promises);
|
|
461
483
|
}
|
|
462
484
|
async _updateInterceptionPatterns() {
|
|
463
|
-
const patterns =
|
|
485
|
+
const patterns = _network.RouteHandler.prepareInterceptionPatterns(this._routes);
|
|
464
486
|
await this._channel.setNetworkInterceptionPatterns({
|
|
465
487
|
patterns
|
|
466
488
|
});
|
|
@@ -479,7 +501,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
479
501
|
}
|
|
480
502
|
const result = await this._channel.screenshot(copy);
|
|
481
503
|
if (options.path) {
|
|
482
|
-
await (0,
|
|
504
|
+
await (0, _utils.mkdirIfNeeded)(options.path);
|
|
483
505
|
await _fs.default.promises.writeFile(options.path, result.binary);
|
|
484
506
|
}
|
|
485
507
|
return result.binary;
|
|
@@ -698,6 +720,6 @@ class BindingCall extends _channelOwner.ChannelOwner {
|
|
|
698
720
|
}
|
|
699
721
|
exports.BindingCall = BindingCall;
|
|
700
722
|
function trimUrl(param) {
|
|
701
|
-
if ((0, _utils.isRegExp)(param)) return `/${(0,
|
|
702
|
-
if ((0, _utils.isString)(param)) return `"${(0,
|
|
723
|
+
if ((0, _utils.isRegExp)(param)) return `/${(0, _utils.trimStringWithEllipsis)(param.source, 50)}/${param.flags}`;
|
|
724
|
+
if ((0, _utils.isString)(param)) return `"${(0, _utils.trimStringWithEllipsis)(param, 50)}"`;
|
|
703
725
|
}
|
package/lib/client/playwright.js
CHANGED
|
@@ -33,6 +33,7 @@ class Playwright extends _channelOwner.ChannelOwner {
|
|
|
33
33
|
super(parent, type, guid, initializer);
|
|
34
34
|
this._android = void 0;
|
|
35
35
|
this._electron = void 0;
|
|
36
|
+
this._experimentalBidi = void 0;
|
|
36
37
|
this.chromium = void 0;
|
|
37
38
|
this.firefox = void 0;
|
|
38
39
|
this.webkit = void 0;
|
|
@@ -49,6 +50,8 @@ class Playwright extends _channelOwner.ChannelOwner {
|
|
|
49
50
|
this.webkit._playwright = this;
|
|
50
51
|
this._android = _android.Android.from(initializer.android);
|
|
51
52
|
this._electron = _electron.Electron.from(initializer.electron);
|
|
53
|
+
this._experimentalBidi = _browserType.BrowserType.from(initializer.bidi);
|
|
54
|
+
this._experimentalBidi._playwright = this;
|
|
52
55
|
this.devices = (_this$_connection$loc = (_this$_connection$loc2 = this._connection.localUtils()) === null || _this$_connection$loc2 === void 0 ? void 0 : _this$_connection$loc2.devices) !== null && _this$_connection$loc !== void 0 ? _this$_connection$loc : {};
|
|
53
56
|
this.selectors = new _selectors.Selectors();
|
|
54
57
|
this.errors = {
|
package/lib/client/tracing.js
CHANGED
|
@@ -79,10 +79,7 @@ class Tracing extends _channelOwner.ChannelOwner {
|
|
|
79
79
|
}, true);
|
|
80
80
|
}
|
|
81
81
|
async _doStopChunk(filePath) {
|
|
82
|
-
|
|
83
|
-
this._isTracing = false;
|
|
84
|
-
this._connection.setIsTracing(false);
|
|
85
|
-
}
|
|
82
|
+
this._resetStackCounter();
|
|
86
83
|
if (!filePath) {
|
|
87
84
|
// Not interested in artifacts.
|
|
88
85
|
await this._channel.tracingStopChunk({
|
|
@@ -131,5 +128,11 @@ class Tracing extends _channelOwner.ChannelOwner {
|
|
|
131
128
|
includeSources: this._includeSources
|
|
132
129
|
});
|
|
133
130
|
}
|
|
131
|
+
_resetStackCounter() {
|
|
132
|
+
if (this._isTracing) {
|
|
133
|
+
this._isTracing = false;
|
|
134
|
+
this._connection.setIsTracing(false);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
134
137
|
}
|
|
135
138
|
exports.Tracing = Tracing;
|
package/lib/common/socksProxy.js
CHANGED
|
@@ -385,9 +385,9 @@ class SocksProxy extends _events.default {
|
|
|
385
385
|
port() {
|
|
386
386
|
return this._port;
|
|
387
387
|
}
|
|
388
|
-
async listen(port) {
|
|
388
|
+
async listen(port, hostname) {
|
|
389
389
|
return new Promise(f => {
|
|
390
|
-
this._server.listen(port, () => {
|
|
390
|
+
this._server.listen(port, hostname, () => {
|
|
391
391
|
const port = this._server.address().port;
|
|
392
392
|
this._port = port;
|
|
393
393
|
f(port);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.source = void 0;
|
|
7
|
+
const source = exports.source = "\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/playwright-core/src/server/injected/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar ClockController = class {\n constructor(embedder) {\n this._duringTick = false;\n this._timers = /* @__PURE__ */ new Map();\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n this._log = [];\n this._now = { time: asWallTime(0), isFixedTime: false, ticks: 0, origin: asWallTime(-1) };\n this._embedder = embedder;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n this._replayLogOnce();\n return this._now.time;\n }\n install(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setSystemTime(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setFixedTime(time) {\n this._replayLogOnce();\n this._innerSetFixedTime(asWallTime(time));\n }\n performanceNow() {\n this._replayLogOnce();\n return this._now.ticks;\n }\n _innerSetTime(time) {\n this._now.time = time;\n this._now.isFixedTime = false;\n if (this._now.origin < 0)\n this._now.origin = this._now.time;\n }\n _innerSetFixedTime(time) {\n this._innerSetTime(time);\n this._now.isFixedTime = true;\n }\n _advanceNow(to) {\n if (!this._now.isFixedTime)\n this._now.time = asWallTime(this._now.time + to - this._now.ticks);\n this._now.ticks = to;\n }\n async log(type, time, param) {\n this._log.push({ type, time, param });\n }\n async runFor(ticks) {\n this._replayLogOnce();\n if (ticks < 0)\n throw new TypeError(\"Negative ticks are not supported\");\n await this._runTo(shiftTicks(this._now.ticks, ticks));\n }\n async _runTo(to) {\n to = Math.ceil(to);\n if (this._now.ticks > to)\n return;\n let firstException;\n while (true) {\n const result = await this._callFirstTimer(to);\n if (!result.timerFound)\n break;\n firstException = firstException || result.error;\n }\n this._advanceNow(to);\n if (firstException)\n throw firstException;\n }\n async pauseAt(time) {\n this._replayLogOnce();\n this._innerPause();\n const toConsume = time - this._now.time;\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, toConsume));\n return toConsume;\n }\n _innerPause() {\n this._realTime = void 0;\n this._updateRealTimeTimer();\n }\n resume() {\n this._replayLogOnce();\n this._innerResume();\n }\n _innerResume() {\n const now = this._embedder.performanceNow();\n this._realTime = { startTicks: now, lastSyncTicks: now };\n this._updateRealTimeTimer();\n }\n _updateRealTimeTimer() {\n var _a;\n if (!this._realTime) {\n (_a = this._currentRealTimeTimer) == null ? void 0 : _a.dispose();\n this._currentRealTimeTimer = void 0;\n return;\n }\n const firstTimer = this._firstTimer();\n const callAt = Math.min(firstTimer ? firstTimer.callAt : this._now.ticks + maxTimeout, this._now.ticks + 100);\n if (this._currentRealTimeTimer && this._currentRealTimeTimer.callAt < callAt)\n return;\n if (this._currentRealTimeTimer) {\n this._currentRealTimeTimer.dispose();\n this._currentRealTimeTimer = void 0;\n }\n this._currentRealTimeTimer = {\n callAt,\n dispose: this._embedder.setTimeout(() => {\n const now = this._embedder.performanceNow();\n this._currentRealTimeTimer = void 0;\n const sinceLastSync = now - this._realTime.lastSyncTicks;\n this._realTime.lastSyncTicks = now;\n void this._runTo(shiftTicks(this._now.ticks, sinceLastSync)).catch((e) => console.error(e)).then(() => this._updateRealTimeTimer());\n }, callAt - this._now.ticks)\n };\n }\n async fastForward(ticks) {\n this._replayLogOnce();\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, ticks | 0));\n }\n async _innerFastForwardTo(to) {\n if (to < this._now.ticks)\n throw new Error(\"Cannot fast-forward to the past\");\n for (const timer of this._timers.values()) {\n if (to > timer.callAt)\n timer.callAt = to;\n }\n await this._runTo(to);\n }\n addTimer(options) {\n this._replayLogOnce();\n if (options.type === \"AnimationFrame\" /* AnimationFrame */ && !options.func)\n throw new Error(\"Callback must be provided to requestAnimationFrame calls\");\n if (options.type === \"IdleCallback\" /* IdleCallback */ && !options.func)\n throw new Error(\"Callback must be provided to requestIdleCallback calls\");\n if ([\"Timeout\" /* Timeout */, \"Interval\" /* Interval */].includes(options.type) && !options.func && options.delay === void 0)\n throw new Error(\"Callback must be provided to timer calls\");\n let delay = options.delay ? +options.delay : 0;\n if (!Number.isFinite(delay))\n delay = 0;\n delay = delay > maxTimeout ? 1 : delay;\n delay = Math.max(0, delay);\n const timer = {\n type: options.type,\n func: options.func,\n args: options.args || [],\n delay,\n callAt: shiftTicks(this._now.ticks, delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now.ticks,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n if (this._realTime)\n this._updateRealTimeTimer();\n return timer.id;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer(beforeTick) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = beforeTick === void 0 || timer.callAt <= beforeTick;\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n _takeFirstTimer(beforeTick) {\n const timer = this._firstTimer(beforeTick);\n if (!timer)\n return null;\n this._advanceNow(timer.callAt);\n if (timer.type === \"Interval\" /* Interval */)\n timer.callAt = shiftTicks(timer.callAt, timer.delay);\n else\n this._timers.delete(timer.id);\n return timer;\n }\n async _callFirstTimer(beforeTick) {\n const timer = this._takeFirstTimer(beforeTick);\n if (!timer)\n return { timerFound: false };\n this._duringTick = true;\n try {\n if (typeof timer.func !== \"function\") {\n let error2;\n try {\n (() => {\n globalThis.eval(timer.func);\n })();\n } catch (e) {\n error2 = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error: error2 };\n }\n let args = timer.args;\n if (timer.type === \"AnimationFrame\" /* AnimationFrame */)\n args = [this._now.ticks];\n else if (timer.type === \"IdleCallback\" /* IdleCallback */)\n args = [{ didTimeout: false, timeRemaining: () => 0 }];\n let error;\n try {\n timer.func.apply(null, args);\n } catch (e) {\n error = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error };\n } finally {\n this._duringTick = false;\n }\n }\n getTimeToNextFrame() {\n return 16 - this._now.ticks % 16;\n }\n clearTimer(timerId, type) {\n this._replayLogOnce();\n if (!timerId) {\n return;\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(type);\n new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);\n }\n const timer = this._timers.get(id);\n if (timer) {\n if (timer.type === type || timer.type === \"Timeout\" && type === \"Interval\" || timer.type === \"Interval\" && type === \"Timeout\") {\n this._timers.delete(id);\n } else {\n const clear = getClearHandler(type);\n const schedule = getScheduleHandler(timer.type);\n throw new Error(\n `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`\n );\n }\n }\n }\n _replayLogOnce() {\n if (!this._log.length)\n return;\n let lastLogTime = -1;\n let isPaused = false;\n for (const { type, time, param } of this._log) {\n if (!isPaused && lastLogTime !== -1)\n this._advanceNow(shiftTicks(this._now.ticks, time - lastLogTime));\n lastLogTime = time;\n if (type === \"install\") {\n this._innerSetTime(asWallTime(param));\n } else if (type === \"fastForward\" || type === \"runFor\") {\n this._advanceNow(shiftTicks(this._now.ticks, param));\n } else if (type === \"pauseAt\") {\n isPaused = true;\n this._innerPause();\n this._innerSetTime(asWallTime(param));\n } else if (type === \"resume\") {\n this._innerResume();\n isPaused = false;\n } else if (type === \"setFixedTime\") {\n this._innerSetFixedTime(asWallTime(param));\n } else if (type === \"setSystemTime\") {\n this._innerSetTime(asWallTime(param));\n }\n }\n if (!isPaused && lastLogTime > 0)\n this._advanceNow(shiftTicks(this._now.ticks, this._embedder.dateNow() - lastLogTime));\n this._log.length = 0;\n }\n};\nfunction mirrorDateProperties(target, source) {\n for (const prop in source) {\n if (source.hasOwnProperty(prop))\n target[prop] = source[prop];\n }\n target.toString = () => source.toString();\n target.prototype = source.prototype;\n target.parse = source.parse;\n target.UTC = source.UTC;\n target.prototype.toUTCString = source.prototype.toUTCString;\n target.isFake = true;\n return target;\n}\nfunction createDate(clock, NativeDate) {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate))\n return new NativeDate(clock.now()).toString();\n switch (arguments.length) {\n case 0:\n return new NativeDate(clock.now());\n case 1:\n return new NativeDate(year);\n case 2:\n return new NativeDate(year, month);\n case 3:\n return new NativeDate(year, month, date);\n case 4:\n return new NativeDate(year, month, date, hour);\n case 5:\n return new NativeDate(year, month, date, hour, minute);\n case 6:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second\n );\n default:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second,\n ms\n );\n }\n }\n ClockDate.now = () => clock.now();\n return mirrorDateProperties(ClockDate, NativeDate);\n}\nfunction createIntl(clock, NativeIntl) {\n const ClockIntl = {};\n for (const key of Object.getOwnPropertyNames(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args);\n const formatter = {\n formatRange: realFormatter.formatRange.bind(realFormatter),\n formatRangeToParts: realFormatter.formatRangeToParts.bind(realFormatter),\n resolvedOptions: realFormatter.resolvedOptions.bind(realFormatter),\n format: (date) => realFormatter.format(date || clock.now()),\n formatToParts: (date) => realFormatter.formatToParts(date || clock.now())\n };\n return formatter;\n };\n ClockIntl.DateTimeFormat.prototype = Object.create(\n NativeIntl.DateTimeFormat.prototype\n );\n ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;\n return ClockIntl;\n}\nfunction compareTimers(a, b) {\n if (a.callAt < b.callAt)\n return -1;\n if (a.callAt > b.callAt)\n return 1;\n if (a.type === \"Immediate\" /* Immediate */ && b.type !== \"Immediate\" /* Immediate */)\n return -1;\n if (a.type !== \"Immediate\" /* Immediate */ && b.type === \"Immediate\" /* Immediate */)\n return 1;\n if (a.createdAt < b.createdAt)\n return -1;\n if (a.createdAt > b.createdAt)\n return 1;\n if (a.id < b.id)\n return -1;\n if (a.id > b.id)\n return 1;\n}\nvar maxTimeout = Math.pow(2, 31) - 1;\nvar idCounterStart = 1e12;\nfunction platformOriginals(globalObject) {\n const raw = {\n setTimeout: globalObject.setTimeout,\n clearTimeout: globalObject.clearTimeout,\n setInterval: globalObject.setInterval,\n clearInterval: globalObject.clearInterval,\n requestAnimationFrame: globalObject.requestAnimationFrame ? globalObject.requestAnimationFrame : void 0,\n cancelAnimationFrame: globalObject.cancelAnimationFrame ? globalObject.cancelAnimationFrame : void 0,\n requestIdleCallback: globalObject.requestIdleCallback ? globalObject.requestIdleCallback : void 0,\n cancelIdleCallback: globalObject.cancelIdleCallback ? globalObject.cancelIdleCallback : void 0,\n Date: globalObject.Date,\n performance: globalObject.performance,\n Intl: globalObject.Intl\n };\n const bound = { ...raw };\n for (const key of Object.keys(bound)) {\n if (key !== \"Date\" && typeof bound[key] === \"function\")\n bound[key] = bound[key].bind(globalObject);\n }\n return { raw, bound };\n}\nfunction getScheduleHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `request${type}`;\n return `set${type}`;\n}\nfunction createApi(clock, originals) {\n return {\n setTimeout: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Timeout\" /* Timeout */,\n func,\n args,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, \"Timeout\" /* Timeout */);\n },\n setInterval: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Interval\" /* Interval */,\n func,\n args,\n delay\n });\n },\n clearInterval: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"Interval\" /* Interval */);\n },\n requestAnimationFrame: (callback) => {\n return clock.addTimer({\n type: \"AnimationFrame\" /* AnimationFrame */,\n func: callback,\n delay: clock.getTimeToNextFrame()\n });\n },\n cancelAnimationFrame: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"AnimationFrame\" /* AnimationFrame */);\n },\n requestIdleCallback: (callback, options) => {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0)\n timeToNextIdlePeriod = 50;\n return clock.addTimer({\n type: \"IdleCallback\" /* IdleCallback */,\n func: callback,\n delay: (options == null ? void 0 : options.timeout) ? Math.min(options == null ? void 0 : options.timeout, timeToNextIdlePeriod) : timeToNextIdlePeriod\n });\n },\n cancelIdleCallback: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"IdleCallback\" /* IdleCallback */);\n },\n Intl: originals.Intl ? createIntl(clock, originals.Intl) : void 0,\n Date: createDate(clock, originals.Date),\n performance: originals.performance ? fakePerformance(clock, originals.performance) : void 0\n };\n}\nfunction getClearHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `cancel${type}`;\n return `clear${type}`;\n}\nfunction fakePerformance(clock, performance) {\n const result = {\n now: () => clock.performanceNow()\n };\n result.__defineGetter__(\"timeOrigin\", () => clock._now.origin || 0);\n for (const key of Object.keys(performance.__proto__)) {\n if (key === \"now\" || key === \"timeOrigin\")\n continue;\n if (key === \"getEntries\" || key === \"getEntriesByName\" || key === \"getEntriesByType\")\n result[key] = () => [];\n else\n result[key] = () => {\n };\n }\n return result;\n}\nfunction createClock(globalObject) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n dateNow: () => originals.raw.Date.now(),\n performanceNow: () => Math.ceil(originals.raw.performance.now()),\n setTimeout: (task, timeout) => {\n const timerId = originals.bound.setTimeout(task, timeout);\n return () => originals.bound.clearTimeout(timerId);\n },\n setInterval: (task, delay) => {\n const intervalId = originals.bound.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder);\n const api = createApi(clock, originals.bound);\n return { clock, api, originals: originals.raw };\n}\nfunction install(globalObject, config = {}) {\n var _a, _b;\n if ((_a = globalObject.Date) == null ? void 0 : _a.isFake) {\n throw new TypeError(`Can't install fake timers twice on the same global object.`);\n }\n const { clock, api, originals } = createClock(globalObject);\n const toFake = ((_b = config.toFake) == null ? void 0 : _b.length) ? config.toFake : Object.keys(originals);\n for (const method of toFake) {\n if (method === \"Date\") {\n globalObject.Date = mirrorDateProperties(api.Date, globalObject.Date);\n } else if (method === \"Intl\") {\n globalObject.Intl = api[method];\n } else if (method === \"performance\") {\n globalObject.performance = api[method];\n const kEventTimeStamp = Symbol(\"playwrightEventTimeStamp\");\n Object.defineProperty(Event.prototype, \"timeStamp\", {\n get() {\n var _a2;\n if (!this[kEventTimeStamp])\n this[kEventTimeStamp] = (_a2 = api.performance) == null ? void 0 : _a2.now();\n return this[kEventTimeStamp];\n }\n });\n } else {\n globalObject[method] = (...args) => {\n return api[method].apply(api, args);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n const builtin = platformOriginals(globalObject).bound;\n const { clock: controller } = install(globalObject);\n controller.resume();\n return {\n controller,\n builtin\n };\n}\nfunction asWallTime(n) {\n return n;\n}\nfunction shiftTicks(ticks, ms) {\n return ticks + ms;\n}\n";
|