brave-real-playwright-core 1.56.1 → 1.57.0-patch.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/README.md +5 -5
- package/advanced-stealth.js +1 -1
- package/lib/cli/program.js +14 -57
- package/lib/client/api.js +0 -3
- package/lib/client/browserContext.js +22 -4
- package/lib/client/consoleMessage.js +5 -1
- package/lib/client/electron.js +1 -1
- package/lib/client/events.js +2 -1
- package/lib/client/locator.js +4 -1
- package/lib/client/page.js +2 -5
- package/lib/client/playwright.js +1 -5
- package/lib/client/tracing.js +6 -4
- package/lib/client/worker.js +22 -0
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/inProcessFactory.js +0 -2
- package/lib/protocol/validator.js +24 -46
- package/lib/server/android/android.js +1 -1
- package/lib/server/bidi/bidiBrowser.js +26 -11
- package/lib/server/bidi/bidiChromium.js +1 -1
- package/lib/server/bidi/bidiFirefox.js +1 -1
- package/lib/server/bidi/bidiPage.js +25 -5
- package/lib/server/browserContext.js +9 -10
- package/lib/server/chromium/chromium.js +12 -1
- package/lib/server/chromium/chromiumSwitches.js +11 -2
- package/lib/server/chromium/crBrowser.js +8 -0
- package/lib/server/chromium/crPage.js +7 -7
- package/lib/server/chromium/crServiceWorker.js +16 -5
- package/lib/server/chromium/videoRecorder.js +14 -12
- package/lib/server/console.js +5 -1
- package/lib/server/deviceDescriptorsSource.json +56 -56
- package/lib/server/dispatchers/browserContextDispatcher.js +23 -6
- package/lib/server/dispatchers/pageDispatcher.js +10 -22
- package/lib/server/dispatchers/playwrightDispatcher.js +0 -4
- package/lib/server/electron/electron.js +1 -1
- package/lib/server/firefox/ffPage.js +3 -6
- package/lib/server/firefox/firefox.js +12 -1
- package/lib/server/frameSelectors.js +2 -4
- package/lib/server/frames.js +10 -3
- package/lib/server/input.js +7 -3
- package/lib/server/localUtils.js +4 -8
- package/lib/server/page.js +54 -40
- package/lib/server/playwright.js +2 -4
- package/lib/server/recorder/recorderApp.js +1 -1
- package/lib/server/recorder.js +3 -2
- package/lib/server/registry/index.js +113 -47
- package/lib/server/registry/oopDownloadBrowserMain.js +6 -2
- package/lib/server/socksClientCertificatesInterceptor.js +1 -1
- package/lib/server/trace/recorder/tracing.js +2 -0
- package/lib/server/trace/viewer/traceViewer.js +37 -36
- package/lib/server/utils/comparators.js +3 -25
- package/lib/server/utils/hostPlatform.js +15 -3
- package/lib/server/utils/imageUtils.js +141 -0
- package/lib/server/utils/network.js +22 -16
- package/lib/server/webkit/webkit.js +1 -10
- package/lib/server/webkit/wkPage.js +1 -5
- package/lib/server/webkit/wkWorkers.js +2 -1
- package/lib/utils/isomorphic/ariaSnapshot.js +5 -0
- package/lib/utils/isomorphic/locatorGenerators.js +24 -8
- package/lib/utils/isomorphic/mimeType.js +1 -1
- package/lib/utils/isomorphic/protocolFormatter.js +3 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +2 -1
- package/lib/utils/isomorphic/urlMatch.js +19 -5
- package/lib/utils.js +2 -0
- package/lib/utilsBundle.js +6 -3
- package/lib/utilsBundleImpl/index.js +171 -171
- package/lib/vite/htmlReport/index.html +18 -18
- package/lib/vite/recorder/assets/codeMirrorModule-BoWUGj0J.js +25 -0
- package/lib/vite/recorder/assets/{index-Y-X2TGJv.js → index-DJqDAOZp.js} +32 -32
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bucv2d7q.js +25 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-BEpdCv1S.js +266 -0
- package/lib/vite/traceViewer/defaultSettingsView.ConWv5KN.css +1 -0
- package/lib/vite/traceViewer/index.BxQ34UMZ.js +2 -0
- package/lib/vite/traceViewer/index.C4Y3Aw8n.css +1 -0
- package/lib/vite/traceViewer/index.html +6 -6
- package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/lib/vite/traceViewer/snapshot.html +3 -3
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/{uiMode.DRQ310U5.js → uiMode.BWTwXl41.js} +3 -3
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/package.json +9 -9
- package/lib/client/accessibility.js +0 -49
- package/lib/server/accessibility.js +0 -69
- package/lib/server/chromium/crAccessibility.js +0 -263
- package/lib/server/firefox/ffAccessibility.js +0 -238
- package/lib/server/webkit/wkAccessibility.js +0 -237
- package/lib/server/webkit/wsl/webkit-wsl-transport-client.js +0 -74
- package/lib/server/webkit/wsl/webkit-wsl-transport-server.js +0 -113
- package/lib/vite/recorder/assets/codeMirrorModule-RJCXzfmE.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-eyVcHN77.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-w0zYjHsW.js +0 -265
- package/lib/vite/traceViewer/defaultSettingsView.TQ8_7ybu.css +0 -1
- package/lib/vite/traceViewer/index.Bx16ehp1.js +0 -2
- package/lib/vite/traceViewer/index.I8N9v4jT.css +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# 🦁 brave-real-playwright-core v1.
|
|
1
|
+
# 🦁 brave-real-playwright-core v1.57.0-patch.1
|
|
2
2
|
|
|
3
|
-
**Based on Playwright Core v1.
|
|
3
|
+
**Based on Playwright Core v1.57.0**
|
|
4
4
|
|
|
5
5
|
**Brave Real-World Optimized Playwright Core with comprehensive stealth patches**
|
|
6
6
|
|
|
7
|
-
This is a pre-patched version of **Playwright Core v1.
|
|
7
|
+
This is a pre-patched version of **Playwright Core v1.57.0** optimized for maximum stealth when using Brave browser.
|
|
8
8
|
|
|
9
9
|
## ✨ Features
|
|
10
10
|
|
|
@@ -46,9 +46,9 @@ await page.goto('https://bot-detector.rebrowser.net/');
|
|
|
46
46
|
|
|
47
47
|
## 📦 Based On
|
|
48
48
|
|
|
49
|
-
- **playwright-core**: v1.
|
|
49
|
+
- **playwright-core**: v1.57.0
|
|
50
50
|
- **rebrowser-patches**: Latest stealth optimizations
|
|
51
|
-
- **Brave optimization**: v1.
|
|
51
|
+
- **Brave optimization**: v1.57.0-patch.1
|
|
52
52
|
|
|
53
53
|
## 🔗 Links
|
|
54
54
|
|
package/advanced-stealth.js
CHANGED
package/lib/cli/program.js
CHANGED
|
@@ -72,47 +72,6 @@ Examples:
|
|
|
72
72
|
$ codegen
|
|
73
73
|
$ codegen --target=python
|
|
74
74
|
$ codegen -b webkit https://example.com`);
|
|
75
|
-
function suggestedBrowsersToInstall() {
|
|
76
|
-
return import_server.registry.executables().filter((e) => e.installType !== "none" && e.type !== "tool").map((e) => e.name).join(", ");
|
|
77
|
-
}
|
|
78
|
-
function defaultBrowsersToInstall(options) {
|
|
79
|
-
let executables = import_server.registry.defaultExecutables();
|
|
80
|
-
if (options.noShell)
|
|
81
|
-
executables = executables.filter((e) => e.name !== "chromium-headless-shell");
|
|
82
|
-
if (options.onlyShell)
|
|
83
|
-
executables = executables.filter((e) => e.name !== "chromium");
|
|
84
|
-
return executables;
|
|
85
|
-
}
|
|
86
|
-
function checkBrowsersToInstall(args, options) {
|
|
87
|
-
if (options.noShell && options.onlyShell)
|
|
88
|
-
throw new Error(`Only one of --no-shell and --only-shell can be specified`);
|
|
89
|
-
const faultyArguments = [];
|
|
90
|
-
const executables = [];
|
|
91
|
-
const handleArgument = (arg) => {
|
|
92
|
-
const executable = import_server.registry.findExecutable(arg);
|
|
93
|
-
if (!executable || executable.installType === "none")
|
|
94
|
-
faultyArguments.push(arg);
|
|
95
|
-
else
|
|
96
|
-
executables.push(executable);
|
|
97
|
-
if (executable?.browserName === "chromium")
|
|
98
|
-
executables.push(import_server.registry.findExecutable("ffmpeg"));
|
|
99
|
-
};
|
|
100
|
-
for (const arg of args) {
|
|
101
|
-
if (arg === "chromium") {
|
|
102
|
-
if (!options.onlyShell)
|
|
103
|
-
handleArgument("chromium");
|
|
104
|
-
if (!options.noShell)
|
|
105
|
-
handleArgument("chromium-headless-shell");
|
|
106
|
-
} else {
|
|
107
|
-
handleArgument(arg);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (process.platform === "win32")
|
|
111
|
-
executables.push(import_server.registry.findExecutable("winldd"));
|
|
112
|
-
if (faultyArguments.length)
|
|
113
|
-
throw new Error(`Invalid installation targets: ${faultyArguments.map((name) => `'${name}'`).join(", ")}. Expecting one of: ${suggestedBrowsersToInstall()}`);
|
|
114
|
-
return executables;
|
|
115
|
-
}
|
|
116
75
|
function printInstalledBrowsers(browsers2) {
|
|
117
76
|
const browserPaths = /* @__PURE__ */ new Set();
|
|
118
77
|
for (const browser of browsers2)
|
|
@@ -166,8 +125,6 @@ Playwright version: ${version}`);
|
|
|
166
125
|
}
|
|
167
126
|
}
|
|
168
127
|
import_utilsBundle.program.command("install [browser...]").description("ensure browsers necessary for this version of Playwright are installed").option("--with-deps", "install system dependencies for browsers").option("--dry-run", "do not execute installation, only print information").option("--list", "prints list of browsers from all playwright installations").option("--force", "force reinstall of stable browser channels").option("--only-shell", "only install headless shell when installing chromium").option("--no-shell", "do not install chromium headless shell").action(async function(args, options) {
|
|
169
|
-
if (options.shell === false)
|
|
170
|
-
options.noShell = true;
|
|
171
128
|
if ((0, import_utils.isLikelyNpxGlobal)()) {
|
|
172
129
|
console.error((0, import_ascii.wrapInASCIIBox)([
|
|
173
130
|
`WARNING: It looks like you are running 'npx playwright install' without first`,
|
|
@@ -189,8 +146,10 @@ import_utilsBundle.program.command("install [browser...]").description("ensure b
|
|
|
189
146
|
].join("\n"), 1));
|
|
190
147
|
}
|
|
191
148
|
try {
|
|
192
|
-
|
|
193
|
-
|
|
149
|
+
if (options.shell === false && options.onlyShell)
|
|
150
|
+
throw new Error(`Only one of --no-shell and --only-shell can be specified`);
|
|
151
|
+
const shell = options.shell === false ? "no" : options.onlyShell ? "only" : void 0;
|
|
152
|
+
const executables = import_server.registry.resolveBrowsers(args, { shell });
|
|
194
153
|
if (options.withDeps)
|
|
195
154
|
await import_server.registry.installDeps(executables, !!options.dryRun);
|
|
196
155
|
if (options.dryRun && options.list)
|
|
@@ -212,8 +171,8 @@ import_utilsBundle.program.command("install [browser...]").description("ensure b
|
|
|
212
171
|
const browsers2 = await import_server.registry.listInstalledBrowsers();
|
|
213
172
|
printGroupedByPlaywrightVersion(browsers2);
|
|
214
173
|
} else {
|
|
215
|
-
const
|
|
216
|
-
await import_server.registry.install(executables,
|
|
174
|
+
const force = args.length === 0 ? false : !!options.force;
|
|
175
|
+
await import_server.registry.install(executables, { force });
|
|
217
176
|
await import_server.registry.validateHostRequirementsForExecutablesIfNeeded(executables, process.env.PW_LANG_NAME || "javascript").catch((e) => {
|
|
218
177
|
e.name = "Playwright Host validation warning";
|
|
219
178
|
console.error(e);
|
|
@@ -231,7 +190,7 @@ Examples:
|
|
|
231
190
|
Install default browsers.
|
|
232
191
|
|
|
233
192
|
- $ install chrome firefox
|
|
234
|
-
Install custom browsers, supports ${suggestedBrowsersToInstall()}.`);
|
|
193
|
+
Install custom browsers, supports ${import_server.registry.suggestedBrowsersToInstall()}.`);
|
|
235
194
|
import_utilsBundle.program.command("uninstall").description("Removes browsers used by this installation of Playwright from the system (chromium, firefox, webkit, ffmpeg). This does not include branded channels.").option("--all", "Removes all browsers used by any Playwright installation from the system.").action(async (options) => {
|
|
236
195
|
delete process.env.PLAYWRIGHT_SKIP_BROWSER_GC;
|
|
237
196
|
await import_server.registry.uninstall(!!options.all).then(({ numberOfBrowsersLeft }) => {
|
|
@@ -244,10 +203,7 @@ To uninstall Playwright browsers for all installations, re-run with --all flag.`
|
|
|
244
203
|
});
|
|
245
204
|
import_utilsBundle.program.command("install-deps [browser...]").description("install dependencies necessary to run browsers (will ask for sudo permissions)").option("--dry-run", "Do not execute installation commands, only print them").action(async function(args, options) {
|
|
246
205
|
try {
|
|
247
|
-
|
|
248
|
-
await import_server.registry.installDeps(defaultBrowsersToInstall({}), !!options.dryRun);
|
|
249
|
-
else
|
|
250
|
-
await import_server.registry.installDeps(checkBrowsersToInstall(args, {}), !!options.dryRun);
|
|
206
|
+
await import_server.registry.installDeps(import_server.registry.resolveBrowsers(args, {}), !!options.dryRun);
|
|
251
207
|
} catch (e) {
|
|
252
208
|
console.log(`Failed to install browser dependencies
|
|
253
209
|
${e}`);
|
|
@@ -259,7 +215,7 @@ Examples:
|
|
|
259
215
|
Install dependencies for default browsers.
|
|
260
216
|
|
|
261
217
|
- $ install-deps chrome firefox
|
|
262
|
-
Install dependencies for specific browsers, supports ${suggestedBrowsersToInstall()}.`);
|
|
218
|
+
Install dependencies for specific browsers, supports ${import_server.registry.suggestedBrowsersToInstall()}.`);
|
|
263
219
|
const browsers = [
|
|
264
220
|
{ alias: "cr", name: "Chromium", type: "chromium" },
|
|
265
221
|
{ alias: "ff", name: "Firefox", type: "firefox" },
|
|
@@ -304,7 +260,7 @@ Examples:
|
|
|
304
260
|
import_utilsBundle.program.command("run-driver", { hidden: true }).action(function(options) {
|
|
305
261
|
(0, import_driver.runDriver)();
|
|
306
262
|
});
|
|
307
|
-
import_utilsBundle.program.command("run-server").option("--port <port>", "Server port").option("--host <host>", "Server host").option("--path <path>", "Endpoint Path", "/").option("--max-clients <maxClients>", "Maximum clients").option("--mode <mode>", 'Server mode, either "default" or "extension"').action(function(options) {
|
|
263
|
+
import_utilsBundle.program.command("run-server", { hidden: true }).option("--port <port>", "Server port").option("--host <host>", "Server host").option("--path <path>", "Endpoint Path", "/").option("--max-clients <maxClients>", "Maximum clients").option("--mode <mode>", 'Server mode, either "default" or "extension"').action(function(options) {
|
|
308
264
|
(0, import_driver.runServer)({
|
|
309
265
|
port: options.port ? +options.port : void 0,
|
|
310
266
|
host: options.host,
|
|
@@ -319,7 +275,7 @@ import_utilsBundle.program.command("print-api-json", { hidden: true }).action(fu
|
|
|
319
275
|
import_utilsBundle.program.command("launch-server", { hidden: true }).requiredOption("--browser <browserName>", 'Browser name, one of "chromium", "firefox" or "webkit"').option("--config <path-to-config-file>", "JSON file with launchServer options").action(function(options) {
|
|
320
276
|
(0, import_driver.launchBrowserServer)(options.browser, options.config);
|
|
321
277
|
});
|
|
322
|
-
import_utilsBundle.program.command("show-trace [trace
|
|
278
|
+
import_utilsBundle.program.command("show-trace [trace]").option("-b, --browser <browserType>", "browser to use, one of cr, chromium, ff, firefox, wk, webkit", "chromium").option("-h, --host <host>", "Host to serve trace on; specifying this option opens trace in a browser tab").option("-p, --port <port>", "Port to serve trace on, 0 for any free port; specifying this option opens trace in a browser tab").option("--stdin", "Accept trace URLs over stdin to update the viewer").description("show trace viewer").action(function(trace, options) {
|
|
323
279
|
if (options.browser === "cr")
|
|
324
280
|
options.browser = "chromium";
|
|
325
281
|
if (options.browser === "ff")
|
|
@@ -332,12 +288,13 @@ import_utilsBundle.program.command("show-trace [trace...]").option("-b, --browse
|
|
|
332
288
|
isServer: !!options.stdin
|
|
333
289
|
};
|
|
334
290
|
if (options.port !== void 0 || options.host !== void 0)
|
|
335
|
-
(0, import_traceViewer.runTraceInBrowser)(
|
|
291
|
+
(0, import_traceViewer.runTraceInBrowser)(trace, openOptions).catch(logErrorAndExit);
|
|
336
292
|
else
|
|
337
|
-
(0, import_traceViewer.runTraceViewerApp)(
|
|
293
|
+
(0, import_traceViewer.runTraceViewerApp)(trace, options.browser, openOptions, true).catch(logErrorAndExit);
|
|
338
294
|
}).addHelpText("afterAll", `
|
|
339
295
|
Examples:
|
|
340
296
|
|
|
297
|
+
$ show-trace
|
|
341
298
|
$ show-trace https://example.com/trace.zip`);
|
|
342
299
|
async function launchContext(options, extraOptions) {
|
|
343
300
|
validateOptions(options);
|
package/lib/client/api.js
CHANGED
|
@@ -21,7 +21,6 @@ __export(api_exports, {
|
|
|
21
21
|
APIRequest: () => import_fetch.APIRequest,
|
|
22
22
|
APIRequestContext: () => import_fetch.APIRequestContext,
|
|
23
23
|
APIResponse: () => import_fetch.APIResponse,
|
|
24
|
-
Accessibility: () => import_accessibility.Accessibility,
|
|
25
24
|
Android: () => import_android.Android,
|
|
26
25
|
AndroidDevice: () => import_android.AndroidDevice,
|
|
27
26
|
AndroidInput: () => import_android.AndroidInput,
|
|
@@ -62,7 +61,6 @@ __export(api_exports, {
|
|
|
62
61
|
Worker: () => import_worker.Worker
|
|
63
62
|
});
|
|
64
63
|
module.exports = __toCommonJS(api_exports);
|
|
65
|
-
var import_accessibility = require("./accessibility");
|
|
66
64
|
var import_android = require("./android");
|
|
67
65
|
var import_browser = require("./browser");
|
|
68
66
|
var import_browserContext = require("./browserContext");
|
|
@@ -95,7 +93,6 @@ var import_webError = require("./webError");
|
|
|
95
93
|
APIRequest,
|
|
96
94
|
APIRequestContext,
|
|
97
95
|
APIResponse,
|
|
98
|
-
Accessibility,
|
|
99
96
|
Android,
|
|
100
97
|
AndroidDevice,
|
|
101
98
|
AndroidInput,
|
|
@@ -89,11 +89,19 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
|
|
|
89
89
|
this.emit(import_events.Events.BrowserContext.ServiceWorker, serviceWorker);
|
|
90
90
|
});
|
|
91
91
|
this._channel.on("console", (event) => {
|
|
92
|
-
const
|
|
92
|
+
const worker = import_worker.Worker.fromNullable(event.worker);
|
|
93
|
+
const page = import_page.Page.fromNullable(event.page);
|
|
94
|
+
const consoleMessage = new import_consoleMessage.ConsoleMessage(this._platform, event, page, worker);
|
|
95
|
+
worker?.emit(import_events.Events.Worker.Console, consoleMessage);
|
|
96
|
+
page?.emit(import_events.Events.Page.Console, consoleMessage);
|
|
97
|
+
if (worker && this._serviceWorkers.has(worker)) {
|
|
98
|
+
const scope = this._serviceWorkerScope(worker);
|
|
99
|
+
for (const page2 of this._pages) {
|
|
100
|
+
if (scope && page2.url().startsWith(scope))
|
|
101
|
+
page2.emit(import_events.Events.Page.Console, consoleMessage);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
93
104
|
this.emit(import_events.Events.BrowserContext.Console, consoleMessage);
|
|
94
|
-
const page = consoleMessage.page();
|
|
95
|
-
if (page)
|
|
96
|
-
page.emit(import_events.Events.Page.Console, consoleMessage);
|
|
97
105
|
});
|
|
98
106
|
this._channel.on("pageError", ({ error, page }) => {
|
|
99
107
|
const pageObject = import_page.Page.from(page);
|
|
@@ -230,6 +238,16 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
|
|
|
230
238
|
return;
|
|
231
239
|
await bindingCall.call(func);
|
|
232
240
|
}
|
|
241
|
+
_serviceWorkerScope(serviceWorker) {
|
|
242
|
+
try {
|
|
243
|
+
let url = new URL(".", serviceWorker.url()).href;
|
|
244
|
+
if (!url.endsWith("/"))
|
|
245
|
+
url += "/";
|
|
246
|
+
return url;
|
|
247
|
+
} catch {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
233
251
|
setDefaultNavigationTimeout(timeout) {
|
|
234
252
|
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
235
253
|
}
|
|
@@ -23,12 +23,16 @@ __export(consoleMessage_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(consoleMessage_exports);
|
|
24
24
|
var import_jsHandle = require("./jsHandle");
|
|
25
25
|
class ConsoleMessage {
|
|
26
|
-
constructor(platform, event, page) {
|
|
26
|
+
constructor(platform, event, page, worker) {
|
|
27
27
|
this._page = page;
|
|
28
|
+
this._worker = worker;
|
|
28
29
|
this._event = event;
|
|
29
30
|
if (platform.inspectCustom)
|
|
30
31
|
this[platform.inspectCustom] = () => this._inspect();
|
|
31
32
|
}
|
|
33
|
+
worker() {
|
|
34
|
+
return this._worker;
|
|
35
|
+
}
|
|
32
36
|
page() {
|
|
33
37
|
return this._page;
|
|
34
38
|
}
|
package/lib/client/electron.js
CHANGED
|
@@ -66,7 +66,7 @@ class ElectronApplication extends import_channelOwner.ChannelOwner {
|
|
|
66
66
|
this._channel.on("close", () => {
|
|
67
67
|
this.emit(import_events.Events.ElectronApplication.Close);
|
|
68
68
|
});
|
|
69
|
-
this._channel.on("console", (event) => this.emit(import_events.Events.ElectronApplication.Console, new import_consoleMessage.ConsoleMessage(this._platform, event, null)));
|
|
69
|
+
this._channel.on("console", (event) => this.emit(import_events.Events.ElectronApplication.Console, new import_consoleMessage.ConsoleMessage(this._platform, event, null, null)));
|
|
70
70
|
this._setEventToSubscriptionMapping(/* @__PURE__ */ new Map([
|
|
71
71
|
[import_events.Events.ElectronApplication.Console, "console"]
|
|
72
72
|
]));
|
package/lib/client/events.js
CHANGED
package/lib/client/locator.js
CHANGED
|
@@ -167,6 +167,9 @@ class Locator {
|
|
|
167
167
|
describe(description) {
|
|
168
168
|
return new Locator(this._frame, this._selector + " >> internal:describe=" + JSON.stringify(description));
|
|
169
169
|
}
|
|
170
|
+
description() {
|
|
171
|
+
return (0, import_locatorGenerators.locatorCustomDescription)(this._selector) || null;
|
|
172
|
+
}
|
|
170
173
|
first() {
|
|
171
174
|
return new Locator(this._frame, this._selector + " >> nth=0");
|
|
172
175
|
}
|
|
@@ -298,7 +301,7 @@ class Locator {
|
|
|
298
301
|
return this.toString();
|
|
299
302
|
}
|
|
300
303
|
toString() {
|
|
301
|
-
return (0, import_locatorGenerators.
|
|
304
|
+
return (0, import_locatorGenerators.asLocatorDescription)("javascript", this._selector);
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
class FrameLocator {
|
package/lib/client/page.js
CHANGED
|
@@ -22,7 +22,6 @@ __export(page_exports, {
|
|
|
22
22
|
Page: () => Page
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(page_exports);
|
|
25
|
-
var import_accessibility = require("./accessibility");
|
|
26
25
|
var import_artifact = require("./artifact");
|
|
27
26
|
var import_channelOwner = require("./channelOwner");
|
|
28
27
|
var import_clientHelper = require("./clientHelper");
|
|
@@ -65,7 +64,6 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
65
64
|
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
66
65
|
this._browserContext = parent;
|
|
67
66
|
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(this._platform, this._browserContext._timeoutSettings);
|
|
68
|
-
this.accessibility = new import_accessibility.Accessibility(this._channel);
|
|
69
67
|
this.keyboard = new import_input.Keyboard(this);
|
|
70
68
|
this.mouse = new import_input.Mouse(this);
|
|
71
69
|
this.request = this._browserContext.request;
|
|
@@ -536,7 +534,7 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
536
534
|
}
|
|
537
535
|
async consoleMessages() {
|
|
538
536
|
const { messages } = await this._channel.consoleMessages();
|
|
539
|
-
return messages.map((message) => new import_consoleMessage.ConsoleMessage(this._platform, message, this));
|
|
537
|
+
return messages.map((message) => new import_consoleMessage.ConsoleMessage(this._platform, message, this, null));
|
|
540
538
|
}
|
|
541
539
|
async pageErrors() {
|
|
542
540
|
const { errors } = await this._channel.pageErrors();
|
|
@@ -676,8 +674,7 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
676
674
|
return result.pdf;
|
|
677
675
|
}
|
|
678
676
|
async _snapshotForAI(options = {}) {
|
|
679
|
-
|
|
680
|
-
return result.snapshot;
|
|
677
|
+
return await this._channel.snapshotForAI({ timeout: this._timeoutSettings.timeout(options), track: options.track });
|
|
681
678
|
}
|
|
682
679
|
}
|
|
683
680
|
class BindingCall extends import_channelOwner.ChannelOwner {
|
package/lib/client/playwright.js
CHANGED
|
@@ -43,10 +43,6 @@ class Playwright extends import_channelOwner.ChannelOwner {
|
|
|
43
43
|
this._android._playwright = this;
|
|
44
44
|
this._electron = import_electron.Electron.from(initializer.electron);
|
|
45
45
|
this._electron._playwright = this;
|
|
46
|
-
this._bidiChromium = import_browserType.BrowserType.from(initializer._bidiChromium);
|
|
47
|
-
this._bidiChromium._playwright = this;
|
|
48
|
-
this._bidiFirefox = import_browserType.BrowserType.from(initializer._bidiFirefox);
|
|
49
|
-
this._bidiFirefox._playwright = this;
|
|
50
46
|
this.devices = this._connection.localUtils()?.devices ?? {};
|
|
51
47
|
this.selectors = new import_selectors.Selectors(this._connection._platform);
|
|
52
48
|
this.errors = { TimeoutError: import_errors.TimeoutError };
|
|
@@ -55,7 +51,7 @@ class Playwright extends import_channelOwner.ChannelOwner {
|
|
|
55
51
|
return channel._object;
|
|
56
52
|
}
|
|
57
53
|
_browserTypes() {
|
|
58
|
-
return [this.chromium, this.firefox, this.webkit
|
|
54
|
+
return [this.chromium, this.firefox, this.webkit];
|
|
59
55
|
}
|
|
60
56
|
_preLaunchedBrowser() {
|
|
61
57
|
const browser = import_browser.Browser.from(this._initializer.preLaunchedBrowser);
|
package/lib/client/tracing.js
CHANGED
|
@@ -27,6 +27,7 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
27
27
|
constructor(parent, type, guid, initializer) {
|
|
28
28
|
super(parent, type, guid, initializer);
|
|
29
29
|
this._includeSources = false;
|
|
30
|
+
this._isLive = false;
|
|
30
31
|
this._isTracing = false;
|
|
31
32
|
}
|
|
32
33
|
static from(channel) {
|
|
@@ -35,6 +36,7 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
35
36
|
async start(options = {}) {
|
|
36
37
|
await this._wrapApiCall(async () => {
|
|
37
38
|
this._includeSources = !!options.sources;
|
|
39
|
+
this._isLive = !!options._live;
|
|
38
40
|
await this._channel.tracingStart({
|
|
39
41
|
name: options.name,
|
|
40
42
|
snapshots: options.snapshots,
|
|
@@ -42,13 +44,13 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
42
44
|
live: options._live
|
|
43
45
|
});
|
|
44
46
|
const { traceName } = await this._channel.tracingStartChunk({ name: options.name, title: options.title });
|
|
45
|
-
await this._startCollectingStacks(traceName);
|
|
47
|
+
await this._startCollectingStacks(traceName, this._isLive);
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
50
|
async startChunk(options = {}) {
|
|
49
51
|
await this._wrapApiCall(async () => {
|
|
50
52
|
const { traceName } = await this._channel.tracingStartChunk(options);
|
|
51
|
-
await this._startCollectingStacks(traceName);
|
|
53
|
+
await this._startCollectingStacks(traceName, this._isLive);
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
async group(name, options = {}) {
|
|
@@ -57,12 +59,12 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
57
59
|
async groupEnd() {
|
|
58
60
|
await this._channel.tracingGroupEnd();
|
|
59
61
|
}
|
|
60
|
-
async _startCollectingStacks(traceName) {
|
|
62
|
+
async _startCollectingStacks(traceName, live) {
|
|
61
63
|
if (!this._isTracing) {
|
|
62
64
|
this._isTracing = true;
|
|
63
65
|
this._connection.setIsTracing(true);
|
|
64
66
|
}
|
|
65
|
-
const result = await this._connection.localUtils()?.tracingStarted({ tracesDir: this._tracesDir, traceName });
|
|
67
|
+
const result = await this._connection.localUtils()?.tracingStarted({ tracesDir: this._tracesDir, traceName, live });
|
|
66
68
|
this._stacksId = result?.stacksId;
|
|
67
69
|
}
|
|
68
70
|
async stopChunk(options = {}) {
|
package/lib/client/worker.js
CHANGED
|
@@ -26,11 +26,16 @@ var import_errors = require("./errors");
|
|
|
26
26
|
var import_events = require("./events");
|
|
27
27
|
var import_jsHandle = require("./jsHandle");
|
|
28
28
|
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
29
|
+
var import_timeoutSettings = require("./timeoutSettings");
|
|
30
|
+
var import_waiter = require("./waiter");
|
|
29
31
|
class Worker extends import_channelOwner.ChannelOwner {
|
|
30
32
|
constructor(parent, type, guid, initializer) {
|
|
31
33
|
super(parent, type, guid, initializer);
|
|
32
34
|
// Set for service workers.
|
|
33
35
|
this._closedScope = new import_manualPromise.LongStandingScope();
|
|
36
|
+
this._setEventToSubscriptionMapping(/* @__PURE__ */ new Map([
|
|
37
|
+
[import_events.Events.Worker.Console, "console"]
|
|
38
|
+
]));
|
|
34
39
|
this._channel.on("close", () => {
|
|
35
40
|
if (this._page)
|
|
36
41
|
this._page._workers.delete(this);
|
|
@@ -40,6 +45,9 @@ class Worker extends import_channelOwner.ChannelOwner {
|
|
|
40
45
|
});
|
|
41
46
|
this.once(import_events.Events.Worker.Close, () => this._closedScope.close(this._page?._closeErrorWithReason() || new import_errors.TargetClosedError()));
|
|
42
47
|
}
|
|
48
|
+
static fromNullable(worker) {
|
|
49
|
+
return worker ? Worker.from(worker) : null;
|
|
50
|
+
}
|
|
43
51
|
static from(worker) {
|
|
44
52
|
return worker._object;
|
|
45
53
|
}
|
|
@@ -56,6 +64,20 @@ class Worker extends import_channelOwner.ChannelOwner {
|
|
|
56
64
|
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
|
|
57
65
|
return import_jsHandle.JSHandle.from(result.handle);
|
|
58
66
|
}
|
|
67
|
+
async waitForEvent(event, optionsOrPredicate = {}) {
|
|
68
|
+
return await this._wrapApiCall(async () => {
|
|
69
|
+
const timeoutSettings = this._page?._timeoutSettings ?? this._context?._timeoutSettings ?? new import_timeoutSettings.TimeoutSettings(this._platform);
|
|
70
|
+
const timeout = timeoutSettings.timeout(typeof optionsOrPredicate === "function" ? {} : optionsOrPredicate);
|
|
71
|
+
const predicate = typeof optionsOrPredicate === "function" ? optionsOrPredicate : optionsOrPredicate.predicate;
|
|
72
|
+
const waiter = import_waiter.Waiter.createForEvent(this, event);
|
|
73
|
+
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
|
74
|
+
if (event !== import_events.Events.Worker.Close)
|
|
75
|
+
waiter.rejectOnEvent(this, import_events.Events.Worker.Close, () => new import_errors.TargetClosedError());
|
|
76
|
+
const result = await waiter.waitForEvent(this, event, predicate);
|
|
77
|
+
waiter.dispose();
|
|
78
|
+
return result;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
59
81
|
}
|
|
60
82
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
83
|
0 && (module.exports = {
|
|
@@ -21,7 +21,7 @@ __export(clockSource_exports, {
|
|
|
21
21
|
source: () => source
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(clockSource_exports);
|
|
24
|
-
const 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/injected/src/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._uniqueTimerId = idCounterStart;\n this.disposables = [];\n this._log = [];\n this._timers = /* @__PURE__ */ new Map();\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 this._syncRealTime();\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 this._syncRealTime();\n return this._now.ticks;\n }\n _syncRealTime() {\n if (!this._realTime)\n return;\n const now = this._embedder.performanceNow();\n const sinceLastSync = now - this._realTime.lastSyncTicks;\n if (sinceLastSync > 0) {\n this._advanceNow(shiftTicks(this._now.ticks, sinceLastSync));\n this._realTime.lastSyncTicks = now;\n }\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 this._currentRealTimeTimer = void 0;\n this._syncRealTime();\n void this._runTo(this._now.ticks).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 builtins = platformOriginals(globalObject).bound;\n const { clock: controller } = install(globalObject);\n controller.resume();\n return {\n controller,\n builtins\n };\n}\nfunction asWallTime(n) {\n return n;\n}\nfunction shiftTicks(ticks, ms) {\n return ticks + ms;\n}\n';
|
|
24
|
+
const 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/injected/src/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._uniqueTimerId = idCounterStart;\n this.disposables = [];\n this._log = [];\n this._timers = /* @__PURE__ */ new Map();\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 this._syncRealTime();\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 this._syncRealTime();\n return this._now.ticks;\n }\n _syncRealTime() {\n if (!this._realTime)\n return;\n const now = this._embedder.performanceNow();\n const sinceLastSync = now - this._realTime.lastSyncTicks;\n if (sinceLastSync > 0) {\n this._advanceNow(shiftTicks(this._now.ticks, sinceLastSync));\n this._realTime.lastSyncTicks = now;\n }\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.ticks > to) {\n return;\n }\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._runWithDisabledRealTimeSync(async () => {\n await this._runTo(shiftTicks(this._now.ticks, ticks));\n });\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 await this._innerPause();\n const toConsume = time - this._now.time;\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, toConsume));\n return toConsume;\n }\n async _innerPause() {\n var _a;\n this._realTime = void 0;\n await ((_a = this._currentRealTimeTimer) == null ? void 0 : _a.dispose());\n this._currentRealTimeTimer = void 0;\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 ((_a = this._currentRealTimeTimer) == null ? void 0 : _a.promise) {\n return;\n }\n const firstTimer = this._firstTimer();\n const nextTick = Math.min(firstTimer ? firstTimer.callAt : this._now.ticks + maxTimeout, this._now.ticks + 100);\n const callAt = this._currentRealTimeTimer ? Math.min(this._currentRealTimeTimer.callAt, nextTick) : nextTick;\n if (this._currentRealTimeTimer) {\n this._currentRealTimeTimer.cancel();\n this._currentRealTimeTimer = void 0;\n }\n const realTimeTimer = {\n callAt,\n promise: void 0,\n cancel: this._embedder.setTimeout(() => {\n this._syncRealTime();\n realTimeTimer.promise = this._runTo(this._now.ticks).catch((e) => console.error(e));\n void realTimeTimer.promise.then(() => {\n this._currentRealTimeTimer = void 0;\n if (this._realTime)\n this._updateRealTimeTimer();\n });\n }, callAt - this._now.ticks),\n dispose: async () => {\n realTimeTimer.cancel();\n await realTimeTimer.promise;\n }\n };\n this._currentRealTimeTimer = realTimeTimer;\n }\n async _runWithDisabledRealTimeSync(fn) {\n if (!this._realTime) {\n await fn();\n return;\n }\n await this._innerPause();\n try {\n await fn();\n } finally {\n this._innerResume();\n }\n }\n async fastForward(ticks) {\n this._replayLogOnce();\n await this._runWithDisabledRealTimeSync(async () => {\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, ticks | 0));\n });\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 this._replayLogOnce();\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._innerSetTime(asWallTime(param));\n } else if (type === "resume") {\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) {\n if (lastLogTime > 0)\n this._advanceNow(shiftTicks(this._now.ticks, this._embedder.dateNow() - lastLogTime));\n this._innerResume();\n } else {\n this._realTime = void 0;\n }\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 builtins = platformOriginals(globalObject).bound;\n const { clock: controller } = install(globalObject);\n controller.resume();\n return {\n controller,\n builtins\n };\n}\nfunction asWallTime(n) {\n return n;\n}\nfunction shiftTicks(ticks, ms) {\n return ticks + ms;\n}\n';
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
source
|