Socket
Socket
Sign inDemoInstall

playwright-core

Package Overview
Dependencies
Maintainers
4
Versions
4543
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

playwright-core - npm Package Compare versions

Comparing version 1.45.0-alpha-2024-06-04 to 1.45.0-alpha-2024-06-05

lib/vite/recorder/assets/codeMirrorModule-70vzzmLw.js

2

lib/client/browser.js

@@ -87,3 +87,3 @@ "use strict";

if (!forReuse && !!process.env.PW_FREEZE_TIME) await this._wrapApiCall(async () => {
await context.clock.install();
await context.clock.installFakeTimers(new Date(0));
}, true);

@@ -90,0 +90,0 @@ return context;

@@ -28,29 +28,36 @@ "use strict";

}
async install(options) {
const now = options && options.now ? options.now instanceof Date ? options.now.getTime() : options.now : undefined;
await this._browserContext._channel.clockInstall({
...options,
now
async installFakeTimers(time, options = {}) {
const timeMs = time instanceof Date ? time.getTime() : time;
await this._browserContext._channel.clockInstallFakeTimers({
time: timeMs,
loopLimit: options.loopLimit
});
}
async jump(time) {
await this._browserContext._channel.clockJump({
async runAllTimers() {
const result = await this._browserContext._channel.clockRunAllTimers();
return result.fakeTime;
}
async runFor(time) {
const result = await this._browserContext._channel.clockRunFor({
timeNumber: typeof time === 'number' ? time : undefined,
timeString: typeof time === 'string' ? time : undefined
});
}
async next() {
const result = await this._browserContext._channel.clockNext();
return result.fakeTime;
}
async runAll() {
const result = await this._browserContext._channel.clockRunAll();
async runToLastTimer() {
const result = await this._browserContext._channel.clockRunToLastTimer();
return result.fakeTime;
}
async runToLast() {
const result = await this._browserContext._channel.clockRunToLast();
async runToNextTimer() {
const result = await this._browserContext._channel.clockRunToNextTimer();
return result.fakeTime;
}
async tick(time) {
const result = await this._browserContext._channel.clockTick({
async setTime(time) {
const timeMs = time instanceof Date ? time.getTime() : time;
await this._browserContext._channel.clockSetTime({
time: timeMs
});
}
async skipTime(time) {
const result = await this._browserContext._channel.clockSkipTime({
timeNumber: typeof time === 'number' ? time : undefined,

@@ -57,0 +64,0 @@ timeString: typeof time === 'string' ? time : undefined

@@ -7,2 +7,2 @@ "use strict";

exports.source = void 0;
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/third_party/fake-timers-src.js\nvar require_fake_timers_src = __commonJS({\n \"packages/playwright-core/src/third_party/fake-timers-src.js\"(exports) {\n \"use strict\";\n function withGlobal(_global) {\n const maxTimeout = Math.pow(2, 31) - 1;\n const idCounterStart = 1e12;\n const NOOP = function() {\n return void 0;\n };\n const NOOP_ARRAY = function() {\n return [];\n };\n const timeoutResult = _global.setTimeout(NOOP, 0);\n const addTimerReturnsObject = typeof timeoutResult === \"object\";\n const performancePresent = _global.performance && typeof _global.performance.now === \"function\";\n const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);\n const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;\n const queueMicrotaskPresent = _global.hasOwnProperty(\"queueMicrotask\");\n const requestAnimationFramePresent = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === \"function\";\n const cancelAnimationFramePresent = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === \"function\";\n const requestIdleCallbackPresent = _global.requestIdleCallback && typeof _global.requestIdleCallback === \"function\";\n const cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === \"function\";\n const setImmediatePresent = _global.setImmediate && typeof _global.setImmediate === \"function\";\n const intlPresent = _global.Intl && typeof _global.Intl === \"object\";\n _global.clearTimeout(timeoutResult);\n const NativeDate = _global.Date;\n const NativeIntl = _global.Intl;\n let uniqueTimerId = idCounterStart;\n function isNumberFinite(num) {\n if (Number.isFinite) {\n return Number.isFinite(num);\n }\n return isFinite(num);\n }\n let isNearInfiniteLimit = false;\n function checkIsNearInfiniteLimit(clock, i) {\n if (clock.loopLimit && i === clock.loopLimit - 1) {\n isNearInfiniteLimit = true;\n }\n }\n function resetIsNearInfiniteLimit() {\n isNearInfiniteLimit = false;\n }\n function parseTime(str) {\n if (!str) {\n return 0;\n }\n const strings = str.split(\":\");\n const l = strings.length;\n let i = l;\n let ms = 0;\n let parsed;\n if (l > 3 || !/^(\\d\\d:){0,2}\\d\\d?$/.test(str)) {\n throw new Error(\n \"tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits\"\n );\n }\n while (i--) {\n parsed = parseInt(strings[i], 10);\n if (parsed >= 60) {\n throw new Error(`Invalid time ${str}`);\n }\n ms += parsed * Math.pow(60, l - i - 1);\n }\n return ms * 1e3;\n }\n function nanoRemainder(msFloat) {\n const modulo = 1e6;\n const remainder = msFloat * 1e6 % modulo;\n const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;\n return Math.floor(positiveRemainder);\n }\n function getEpoch(epoch) {\n if (!epoch) {\n return 0;\n }\n if (typeof epoch.getTime === \"function\") {\n return epoch.getTime();\n }\n if (typeof epoch === \"number\") {\n return epoch;\n }\n throw new TypeError(\"now should be milliseconds since UNIX epoch\");\n }\n function inRange(from, to, timer) {\n return timer && timer.callAt >= from && timer.callAt <= to;\n }\n function getInfiniteLoopError(clock, job) {\n const infiniteLoopError = new Error(\n `Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`\n );\n if (!job.error) {\n return infiniteLoopError;\n }\n const computedTargetPattern = /target\\.*[<|(|[].*?[>|\\]|)]\\s*/;\n let clockMethodPattern = new RegExp(\n String(Object.keys(clock).join(\"|\"))\n );\n if (addTimerReturnsObject) {\n clockMethodPattern = new RegExp(\n `\\\\s+at (Object\\\\.)?(?:${Object.keys(clock).join(\"|\")})\\\\s+`\n );\n }\n let matchedLineIndex = -1;\n job.error.stack.split(\"\\n\").some(function(line, i) {\n const matchedComputedTarget = line.match(computedTargetPattern);\n if (matchedComputedTarget) {\n matchedLineIndex = i;\n return true;\n }\n const matchedClockMethod = line.match(clockMethodPattern);\n if (matchedClockMethod) {\n matchedLineIndex = i;\n return false;\n }\n return matchedLineIndex >= 0;\n });\n const stack = `${infiniteLoopError}\n${job.type || \"Microtask\"} - ${job.func.name || \"anonymous\"}\n${job.error.stack.split(\"\\n\").slice(matchedLineIndex + 1).join(\"\\n\")}`;\n try {\n Object.defineProperty(infiniteLoopError, \"stack\", {\n value: stack\n });\n } catch (e) {\n }\n return infiniteLoopError;\n }\n function mirrorDateProperties(target, source) {\n let prop;\n for (prop in source) {\n if (source.hasOwnProperty(prop)) {\n target[prop] = source[prop];\n }\n }\n if (source.now) {\n target.now = function now() {\n return target.clock.now;\n };\n } else {\n delete target.now;\n }\n if (source.toSource) {\n target.toSource = function toSource() {\n return source.toSource();\n };\n } else {\n delete target.toSource;\n }\n target.toString = function toString() {\n return source.toString();\n };\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 }\n function createDate() {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate)) {\n return new NativeDate(ClockDate.clock.now).toString();\n }\n switch (arguments.length) {\n case 0:\n return new NativeDate(ClockDate.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 return mirrorDateProperties(ClockDate, NativeDate);\n }\n function createIntl() {\n const ClockIntl = {};\n Object.getOwnPropertyNames(NativeIntl).forEach(\n (property) => ClockIntl[property] = NativeIntl[property]\n );\n ClockIntl.DateTimeFormat = function(...args) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args);\n const formatter = {};\n [\"formatRange\", \"formatRangeToParts\", \"resolvedOptions\"].forEach(\n (method) => {\n formatter[method] = realFormatter[method].bind(realFormatter);\n }\n );\n [\"format\", \"formatToParts\"].forEach((method) => {\n formatter[method] = function(date) {\n return realFormatter[method](date || ClockIntl.clock.now);\n };\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 }\n function enqueueJob(clock, job) {\n if (!clock.jobs) {\n clock.jobs = [];\n }\n clock.jobs.push(job);\n }\n function runJobs(clock) {\n if (!clock.jobs) {\n return;\n }\n for (let i = 0; i < clock.jobs.length; i++) {\n const job = clock.jobs[i];\n job.func.apply(null, job.args);\n checkIsNearInfiniteLimit(clock, i);\n if (clock.loopLimit && i > clock.loopLimit) {\n throw getInfiniteLoopError(clock, job);\n }\n }\n resetIsNearInfiniteLimit();\n clock.jobs = [];\n }\n function addTimer(clock, timer) {\n if (timer.func === void 0) {\n throw new Error(\"Callback must be provided to timer calls\");\n }\n if (addTimerReturnsObject) {\n if (typeof timer.func !== \"function\") {\n throw new TypeError(\n `[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`\n );\n }\n }\n if (isNearInfiniteLimit) {\n timer.error = new Error();\n }\n timer.type = timer.immediate ? \"Immediate\" : \"Timeout\";\n if (timer.hasOwnProperty(\"delay\")) {\n if (typeof timer.delay !== \"number\") {\n timer.delay = parseInt(timer.delay, 10);\n }\n if (!isNumberFinite(timer.delay)) {\n timer.delay = 0;\n }\n timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;\n timer.delay = Math.max(0, timer.delay);\n }\n if (timer.hasOwnProperty(\"interval\")) {\n timer.type = \"Interval\";\n timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;\n }\n if (timer.hasOwnProperty(\"animation\")) {\n timer.type = \"AnimationFrame\";\n timer.animation = true;\n }\n if (timer.hasOwnProperty(\"idleCallback\")) {\n timer.type = \"IdleCallback\";\n timer.idleCallback = true;\n }\n if (!clock.timers) {\n clock.timers = {};\n }\n timer.id = uniqueTimerId++;\n timer.createdAt = clock.now;\n timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));\n clock.timers[timer.id] = timer;\n if (addTimerReturnsObject) {\n const res = {\n refed: true,\n ref: function() {\n this.refed = true;\n return res;\n },\n unref: function() {\n this.refed = false;\n return res;\n },\n hasRef: function() {\n return this.refed;\n },\n refresh: function() {\n timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));\n clock.timers[timer.id] = timer;\n return res;\n },\n [Symbol.toPrimitive]: function() {\n return timer.id;\n }\n };\n return res;\n }\n return timer.id;\n }\n function compareTimers(a, b) {\n if (a.callAt < b.callAt) {\n return -1;\n }\n if (a.callAt > b.callAt) {\n return 1;\n }\n if (a.immediate && !b.immediate) {\n return -1;\n }\n if (!a.immediate && b.immediate) {\n return 1;\n }\n if (a.createdAt < b.createdAt) {\n return -1;\n }\n if (a.createdAt > b.createdAt) {\n return 1;\n }\n if (a.id < b.id) {\n return -1;\n }\n if (a.id > b.id) {\n return 1;\n }\n }\n function firstTimerInRange(clock, from, to) {\n const timers2 = clock.timers;\n let timer = null;\n let id, isInRange;\n for (id in timers2) {\n if (timers2.hasOwnProperty(id)) {\n isInRange = inRange(from, to, timers2[id]);\n if (isInRange && (!timer || compareTimers(timer, timers2[id]) === 1)) {\n timer = timers2[id];\n }\n }\n }\n return timer;\n }\n function firstTimer(clock) {\n const timers2 = clock.timers;\n let timer = null;\n let id;\n for (id in timers2) {\n if (timers2.hasOwnProperty(id)) {\n if (!timer || compareTimers(timer, timers2[id]) === 1) {\n timer = timers2[id];\n }\n }\n }\n return timer;\n }\n function lastTimer(clock) {\n const timers2 = clock.timers;\n let timer = null;\n let id;\n for (id in timers2) {\n if (timers2.hasOwnProperty(id)) {\n if (!timer || compareTimers(timer, timers2[id]) === -1) {\n timer = timers2[id];\n }\n }\n }\n return timer;\n }\n function callTimer(clock, timer) {\n if (typeof timer.interval === \"number\") {\n clock.timers[timer.id].callAt += timer.interval;\n } else {\n delete clock.timers[timer.id];\n }\n if (typeof timer.func === \"function\") {\n timer.func.apply(null, timer.args);\n } else {\n const eval2 = eval;\n (function() {\n eval2(timer.func);\n })();\n }\n }\n function getClearHandler(ttype) {\n if (ttype === \"IdleCallback\" || ttype === \"AnimationFrame\") {\n return `cancel${ttype}`;\n }\n return `clear${ttype}`;\n }\n function getScheduleHandler(ttype) {\n if (ttype === \"IdleCallback\" || ttype === \"AnimationFrame\") {\n return `request${ttype}`;\n }\n return `set${ttype}`;\n }\n function createWarnOnce() {\n let calls = 0;\n return function(msg) {\n !calls++ && console.warn(msg);\n };\n }\n const warnOnce = createWarnOnce();\n function clearTimer(clock, timerId, ttype) {\n if (!timerId) {\n return;\n }\n if (!clock.timers) {\n clock.timers = {};\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(ttype);\n if (clock.shouldClearNativeTimers === true) {\n const nativeHandler = clock[`_${handlerName}`];\n return typeof nativeHandler === \"function\" ? nativeHandler(timerId) : void 0;\n }\n warnOnce(\n `FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.\nTo automatically clean-up native timers, use \\`shouldClearNativeTimers\\`.`\n );\n }\n if (clock.timers.hasOwnProperty(id)) {\n const timer = clock.timers[id];\n if (timer.type === ttype || timer.type === \"Timeout\" && ttype === \"Interval\" || timer.type === \"Interval\" && ttype === \"Timeout\") {\n delete clock.timers[id];\n } else {\n const clear = getClearHandler(ttype);\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 function uninstall(clock, config) {\n let method, i, l;\n const installedHrTime = \"_hrtime\";\n const installedNextTick = \"_nextTick\";\n for (i = 0, l = clock.methods.length; i < l; i++) {\n method = clock.methods[i];\n if (method === \"performance\") {\n const originalPerfDescriptor = Object.getOwnPropertyDescriptor(\n clock,\n `_${method}`\n );\n if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {\n Object.defineProperty(\n _global,\n method,\n originalPerfDescriptor\n );\n } else if (originalPerfDescriptor.configurable) {\n _global[method] = clock[`_${method}`];\n }\n } else {\n if (_global[method] && _global[method].hadOwnProperty) {\n _global[method] = clock[`_${method}`];\n } else {\n try {\n delete _global[method];\n } catch (ignore) {\n }\n }\n }\n }\n if (config.shouldAdvanceTime === true) {\n _global.clearInterval(clock.attachedInterval);\n }\n clock.methods = [];\n if (!clock.timers) {\n return [];\n }\n return Object.keys(clock.timers).map(function mapper(key) {\n return clock.timers[key];\n });\n }\n function hijackMethod(target, method, clock) {\n clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(\n target,\n method\n );\n clock[`_${method}`] = target[method];\n if (method === \"Date\") {\n const date = mirrorDateProperties(clock[method], target[method]);\n target[method] = date;\n } else if (method === \"Intl\") {\n target[method] = clock[method];\n } else if (method === \"performance\") {\n const originalPerfDescriptor = Object.getOwnPropertyDescriptor(\n target,\n method\n );\n if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {\n Object.defineProperty(\n clock,\n `_${method}`,\n originalPerfDescriptor\n );\n const perfDescriptor = Object.getOwnPropertyDescriptor(\n clock,\n method\n );\n Object.defineProperty(target, method, perfDescriptor);\n } else {\n target[method] = clock[method];\n }\n } else {\n target[method] = function() {\n return clock[method].apply(clock, arguments);\n };\n Object.defineProperties(\n target[method],\n Object.getOwnPropertyDescriptors(clock[method])\n );\n }\n target[method].clock = clock;\n }\n function doIntervalTick(clock, advanceTimeDelta) {\n clock.tick(advanceTimeDelta);\n }\n const timers = {\n setTimeout: _global.setTimeout,\n clearTimeout: _global.clearTimeout,\n setInterval: _global.setInterval,\n clearInterval: _global.clearInterval,\n Date: _global.Date\n };\n if (setImmediatePresent) {\n timers.setImmediate = _global.setImmediate;\n timers.clearImmediate = _global.clearImmediate;\n }\n if (performancePresent) {\n timers.performance = _global.performance;\n }\n if (requestAnimationFramePresent) {\n timers.requestAnimationFrame = _global.requestAnimationFrame;\n }\n if (queueMicrotaskPresent) {\n timers.queueMicrotask = true;\n }\n if (cancelAnimationFramePresent) {\n timers.cancelAnimationFrame = _global.cancelAnimationFrame;\n }\n if (requestIdleCallbackPresent) {\n timers.requestIdleCallback = _global.requestIdleCallback;\n }\n if (cancelIdleCallbackPresent) {\n timers.cancelIdleCallback = _global.cancelIdleCallback;\n }\n if (intlPresent) {\n timers.Intl = _global.Intl;\n }\n const originalSetTimeout = _global.setImmediate || _global.setTimeout;\n function createClock(start, loopLimit) {\n start = Math.floor(getEpoch(start));\n loopLimit = loopLimit || 1e3;\n let nanos = 0;\n const adjustedSystemTime = [0, 0];\n if (NativeDate === void 0) {\n throw new Error(\n \"The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)\"\n );\n }\n const clock = {\n now: start,\n Date: createDate(),\n loopLimit\n };\n clock.Date.clock = clock;\n function getTimeToNextFrame() {\n return 16 - (clock.now - start) % 16;\n }\n function hrtime(prev) {\n const millisSinceStart = clock.now - adjustedSystemTime[0] - start;\n const secsSinceStart = Math.floor(millisSinceStart / 1e3);\n const remainderInNanos = (millisSinceStart - secsSinceStart * 1e3) * 1e6 + nanos - adjustedSystemTime[1];\n if (Array.isArray(prev)) {\n if (prev[1] > 1e9) {\n throw new TypeError(\n \"Number of nanoseconds can't exceed a billion\"\n );\n }\n const oldSecs = prev[0];\n let nanoDiff = remainderInNanos - prev[1];\n let secDiff = secsSinceStart - oldSecs;\n if (nanoDiff < 0) {\n nanoDiff += 1e9;\n secDiff -= 1;\n }\n return [secDiff, nanoDiff];\n }\n return [secsSinceStart, remainderInNanos];\n }\n function fakePerformanceNow() {\n const hrt = hrtime();\n const millis = hrt[0] * 1e3 + hrt[1] / 1e6;\n return millis;\n }\n if (intlPresent) {\n clock.Intl = createIntl();\n clock.Intl.clock = clock;\n }\n clock.requestIdleCallback = function requestIdleCallback(func, timeout) {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0) {\n timeToNextIdlePeriod = 50;\n }\n const result = addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 2),\n delay: typeof timeout === \"undefined\" ? timeToNextIdlePeriod : Math.min(timeout, timeToNextIdlePeriod),\n idleCallback: true\n });\n return Number(result);\n };\n clock.cancelIdleCallback = function cancelIdleCallback(timerId) {\n return clearTimer(clock, timerId, \"IdleCallback\");\n };\n clock.setTimeout = function setTimeout(func, timeout) {\n return addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 2),\n delay: timeout\n });\n };\n clock.clearTimeout = function clearTimeout(timerId) {\n return clearTimer(clock, timerId, \"Timeout\");\n };\n clock.nextTick = function nextTick(func) {\n return enqueueJob(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 1),\n error: isNearInfiniteLimit ? new Error() : null\n });\n };\n clock.queueMicrotask = function queueMicrotask(func) {\n return clock.nextTick(func);\n };\n clock.setInterval = function setInterval(func, timeout) {\n timeout = parseInt(timeout, 10);\n return addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 2),\n delay: timeout,\n interval: timeout\n });\n };\n clock.clearInterval = function clearInterval(timerId) {\n return clearTimer(clock, timerId, \"Interval\");\n };\n if (setImmediatePresent) {\n clock.setImmediate = function setImmediate(func) {\n return addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 1),\n immediate: true\n });\n };\n clock.clearImmediate = function clearImmediate(timerId) {\n return clearTimer(clock, timerId, \"Immediate\");\n };\n }\n clock.countTimers = function countTimers() {\n return Object.keys(clock.timers || {}).length + (clock.jobs || []).length;\n };\n clock.requestAnimationFrame = function requestAnimationFrame(func) {\n const result = addTimer(clock, {\n func,\n delay: getTimeToNextFrame(),\n get args() {\n return [fakePerformanceNow()];\n },\n animation: true\n });\n return Number(result);\n };\n clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) {\n return clearTimer(clock, timerId, \"AnimationFrame\");\n };\n clock.runMicrotasks = function runMicrotasks() {\n runJobs(clock);\n };\n function doTick(tickValue, isAsync, resolve, reject) {\n const msFloat = typeof tickValue === \"number\" ? tickValue : parseTime(tickValue);\n const ms = Math.floor(msFloat);\n const remainder = nanoRemainder(msFloat);\n let nanosTotal = nanos + remainder;\n let tickTo = clock.now + ms;\n if (msFloat < 0) {\n throw new TypeError(\"Negative ticks are not supported\");\n }\n if (nanosTotal >= 1e6) {\n tickTo += 1;\n nanosTotal -= 1e6;\n }\n nanos = nanosTotal;\n let tickFrom = clock.now;\n let previous = clock.now;\n let timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;\n clock.duringTick = true;\n oldNow = clock.now;\n runJobs(clock);\n if (oldNow !== clock.now) {\n tickFrom += clock.now - oldNow;\n tickTo += clock.now - oldNow;\n }\n function doTickInner() {\n timer = firstTimerInRange(clock, tickFrom, tickTo);\n while (timer && tickFrom <= tickTo) {\n if (clock.timers[timer.id]) {\n tickFrom = timer.callAt;\n clock.now = timer.callAt;\n oldNow = clock.now;\n try {\n runJobs(clock);\n callTimer(clock, timer);\n } catch (e) {\n firstException = firstException || e;\n }\n if (isAsync) {\n originalSetTimeout(nextPromiseTick);\n return;\n }\n compensationCheck();\n }\n postTimerCall();\n }\n oldNow = clock.now;\n runJobs(clock);\n if (oldNow !== clock.now) {\n tickFrom += clock.now - oldNow;\n tickTo += clock.now - oldNow;\n }\n clock.duringTick = false;\n timer = firstTimerInRange(clock, tickFrom, tickTo);\n if (timer) {\n try {\n clock.tick(tickTo - clock.now);\n } catch (e) {\n firstException = firstException || e;\n }\n } else {\n clock.now = tickTo;\n nanos = nanosTotal;\n }\n if (firstException) {\n throw firstException;\n }\n if (isAsync) {\n resolve(clock.now);\n } else {\n return clock.now;\n }\n }\n nextPromiseTick = isAsync && function() {\n try {\n compensationCheck();\n postTimerCall();\n doTickInner();\n } catch (e) {\n reject(e);\n }\n };\n compensationCheck = function() {\n if (oldNow !== clock.now) {\n tickFrom += clock.now - oldNow;\n tickTo += clock.now - oldNow;\n previous += clock.now - oldNow;\n }\n };\n postTimerCall = function() {\n timer = firstTimerInRange(clock, previous, tickTo);\n previous = tickFrom;\n };\n return doTickInner();\n }\n clock.tick = function tick(tickValue) {\n return doTick(tickValue, false);\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.tickAsync = function tickAsync(tickValue) {\n return new _global.Promise(function(resolve, reject) {\n originalSetTimeout(function() {\n try {\n doTick(tickValue, true, resolve, reject);\n } catch (e) {\n reject(e);\n }\n });\n });\n };\n }\n clock.next = function next() {\n runJobs(clock);\n const timer = firstTimer(clock);\n if (!timer) {\n return clock.now;\n }\n clock.duringTick = true;\n try {\n clock.now = timer.callAt;\n callTimer(clock, timer);\n runJobs(clock);\n return clock.now;\n } finally {\n clock.duringTick = false;\n }\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.nextAsync = function nextAsync() {\n return new _global.Promise(function(resolve, reject) {\n originalSetTimeout(function() {\n try {\n const timer = firstTimer(clock);\n if (!timer) {\n resolve(clock.now);\n return;\n }\n let err;\n clock.duringTick = true;\n clock.now = timer.callAt;\n try {\n callTimer(clock, timer);\n } catch (e) {\n err = e;\n }\n clock.duringTick = false;\n originalSetTimeout(function() {\n if (err) {\n reject(err);\n } else {\n resolve(clock.now);\n }\n });\n } catch (e) {\n reject(e);\n }\n });\n });\n };\n }\n clock.runAll = function runAll() {\n let numTimers, i;\n runJobs(clock);\n for (i = 0; i < clock.loopLimit; i++) {\n if (!clock.timers) {\n resetIsNearInfiniteLimit();\n return clock.now;\n }\n numTimers = Object.keys(clock.timers).length;\n if (numTimers === 0) {\n resetIsNearInfiniteLimit();\n return clock.now;\n }\n clock.next();\n checkIsNearInfiniteLimit(clock, i);\n }\n const excessJob = firstTimer(clock);\n throw getInfiniteLoopError(clock, excessJob);\n };\n clock.runToFrame = function runToFrame() {\n return clock.tick(getTimeToNextFrame());\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.runAllAsync = function runAllAsync() {\n return new _global.Promise(function(resolve, reject) {\n let i = 0;\n function doRun() {\n originalSetTimeout(function() {\n try {\n runJobs(clock);\n let numTimers;\n if (i < clock.loopLimit) {\n if (!clock.timers) {\n resetIsNearInfiniteLimit();\n resolve(clock.now);\n return;\n }\n numTimers = Object.keys(\n clock.timers\n ).length;\n if (numTimers === 0) {\n resetIsNearInfiniteLimit();\n resolve(clock.now);\n return;\n }\n clock.next();\n i++;\n doRun();\n checkIsNearInfiniteLimit(clock, i);\n return;\n }\n const excessJob = firstTimer(clock);\n reject(getInfiniteLoopError(clock, excessJob));\n } catch (e) {\n reject(e);\n }\n });\n }\n doRun();\n });\n };\n }\n clock.runToLast = function runToLast() {\n const timer = lastTimer(clock);\n if (!timer) {\n runJobs(clock);\n return clock.now;\n }\n return clock.tick(timer.callAt - clock.now);\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.runToLastAsync = function runToLastAsync() {\n return new _global.Promise(function(resolve, reject) {\n originalSetTimeout(function() {\n try {\n const timer = lastTimer(clock);\n if (!timer) {\n runJobs(clock);\n resolve(clock.now);\n }\n resolve(clock.tickAsync(timer.callAt - clock.now));\n } catch (e) {\n reject(e);\n }\n });\n });\n };\n }\n clock.reset = function reset() {\n nanos = 0;\n clock.timers = {};\n clock.jobs = [];\n clock.now = start;\n };\n clock.setSystemTime = function setSystemTime(systemTime) {\n const newNow = getEpoch(systemTime);\n const difference = newNow - clock.now;\n let id, timer;\n adjustedSystemTime[0] = adjustedSystemTime[0] + difference;\n adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;\n clock.now = newNow;\n nanos = 0;\n for (id in clock.timers) {\n if (clock.timers.hasOwnProperty(id)) {\n timer = clock.timers[id];\n timer.createdAt += difference;\n timer.callAt += difference;\n }\n }\n };\n clock.jump = function jump(tickValue) {\n const msFloat = typeof tickValue === \"number\" ? tickValue : parseTime(tickValue);\n const ms = Math.floor(msFloat);\n for (const timer of Object.values(clock.timers)) {\n if (clock.now + ms > timer.callAt) {\n timer.callAt = clock.now + ms;\n }\n }\n clock.tick(ms);\n };\n if (performancePresent) {\n clock.performance = /* @__PURE__ */ Object.create(null);\n clock.performance.now = fakePerformanceNow;\n }\n return clock;\n }\n function install2(config) {\n if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || typeof config === \"number\") {\n throw new TypeError(\n `FakeTimers.install called with ${String(\n config\n )} install requires an object parameter`\n );\n }\n if (_global.Date.isFake === true) {\n throw new TypeError(\n \"Can't install fake timers twice on the same global object.\"\n );\n }\n config = typeof config !== \"undefined\" ? config : {};\n config.shouldAdvanceTime = config.shouldAdvanceTime || false;\n config.advanceTimeDelta = config.advanceTimeDelta || 20;\n config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;\n if (config.target) {\n throw new TypeError(\n \"config.target is no longer supported. Use `withGlobal(target)` instead.\"\n );\n }\n let i, l;\n const clock = createClock(config.now, config.loopLimit);\n clock.shouldClearNativeTimers = config.shouldClearNativeTimers;\n clock.uninstall = function() {\n return uninstall(clock, config);\n };\n clock.methods = config.toFake || [];\n if (clock.methods.length === 0) {\n clock.methods = Object.keys(timers).filter(function(key) {\n return key !== \"nextTick\" && key !== \"queueMicrotask\";\n });\n }\n if (config.shouldAdvanceTime === true) {\n const intervalTick = doIntervalTick.bind(\n null,\n clock,\n config.advanceTimeDelta\n );\n const intervalId = _global.setInterval(\n intervalTick,\n config.advanceTimeDelta\n );\n clock.attachedInterval = intervalId;\n }\n if (clock.methods.includes(\"performance\")) {\n const proto = (() => {\n if (hasPerformanceConstructorPrototype) {\n return _global.performance.constructor.prototype;\n }\n if (hasPerformancePrototype) {\n return _global.Performance.prototype;\n }\n })();\n if (proto) {\n Object.getOwnPropertyNames(proto).forEach(function(name) {\n if (name !== \"now\") {\n clock.performance[name] = name.indexOf(\"getEntries\") === 0 ? NOOP_ARRAY : NOOP;\n }\n });\n } else if ((config.toFake || []).includes(\"performance\")) {\n throw new ReferenceError(\n \"non-existent performance object cannot be faked\"\n );\n }\n }\n for (i = 0, l = clock.methods.length; i < l; i++) {\n const nameOfMethodToReplace = clock.methods[i];\n hijackMethod(_global, nameOfMethodToReplace, clock);\n }\n return clock;\n }\n return {\n timers,\n createClock,\n install: install2,\n withGlobal\n };\n }\n var defaultImplementation = withGlobal(globalThis);\n exports.install = defaultImplementation.install;\n }\n});\n\n// packages/playwright-core/src/server/injected/fakeTimers.ts\nvar fakeTimers_exports = {};\n__export(fakeTimers_exports, {\n install: () => install\n});\nmodule.exports = __toCommonJS(fakeTimers_exports);\nvar import_fake_timers_src = __toESM(require_fake_timers_src());\nfunction install(params) {\n var _a, _b;\n const window = globalThis;\n const builtin = {\n setTimeout: window.setTimeout.bind(window),\n clearTimeout: window.clearTimeout.bind(window),\n setInterval: window.setInterval.bind(window),\n clearInterval: window.clearInterval.bind(window),\n requestAnimationFrame: window.requestAnimationFrame.bind(window),\n cancelAnimationFrame: window.cancelAnimationFrame.bind(window),\n requestIdleCallback: (_a = window.requestIdleCallback) == null ? void 0 : _a.bind(window),\n cancelIdleCallback: (_b = window.cancelIdleCallback) == null ? void 0 : _b.bind(window),\n performance: window.performance,\n Intl: window.Intl,\n Date: window.Date\n };\n const result = import_fake_timers_src.default.install(params);\n result.builtin = builtin;\n return result;\n}\n";
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/third_party/fake-timers-src.js\nvar require_fake_timers_src = __commonJS({\n \"packages/playwright-core/src/third_party/fake-timers-src.js\"(exports) {\n \"use strict\";\n function withGlobal(_global) {\n const maxTimeout = Math.pow(2, 31) - 1;\n const idCounterStart = 1e12;\n const NOOP = function() {\n return void 0;\n };\n const NOOP_ARRAY = function() {\n return [];\n };\n const timeoutResult = _global.setTimeout(NOOP, 0);\n const addTimerReturnsObject = typeof timeoutResult === \"object\";\n const performancePresent = _global.performance && typeof _global.performance.now === \"function\";\n const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);\n const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;\n const queueMicrotaskPresent = _global.hasOwnProperty(\"queueMicrotask\");\n const requestAnimationFramePresent = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === \"function\";\n const cancelAnimationFramePresent = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === \"function\";\n const requestIdleCallbackPresent = _global.requestIdleCallback && typeof _global.requestIdleCallback === \"function\";\n const cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === \"function\";\n const setImmediatePresent = _global.setImmediate && typeof _global.setImmediate === \"function\";\n const intlPresent = _global.Intl && typeof _global.Intl === \"object\";\n _global.clearTimeout(timeoutResult);\n const NativeDate = _global.Date;\n const NativeIntl = _global.Intl;\n let uniqueTimerId = idCounterStart;\n function isNumberFinite(num) {\n if (Number.isFinite) {\n return Number.isFinite(num);\n }\n return isFinite(num);\n }\n let isNearInfiniteLimit = false;\n function checkIsNearInfiniteLimit(clock, i) {\n if (clock.loopLimit && i === clock.loopLimit - 1) {\n isNearInfiniteLimit = true;\n }\n }\n function resetIsNearInfiniteLimit() {\n isNearInfiniteLimit = false;\n }\n function parseTime(str) {\n if (!str) {\n return 0;\n }\n const strings = str.split(\":\");\n const l = strings.length;\n let i = l;\n let ms = 0;\n let parsed;\n if (l > 3 || !/^(\\d\\d:){0,2}\\d\\d?$/.test(str)) {\n throw new Error(\n \"tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits\"\n );\n }\n while (i--) {\n parsed = parseInt(strings[i], 10);\n if (parsed >= 60) {\n throw new Error(`Invalid time ${str}`);\n }\n ms += parsed * Math.pow(60, l - i - 1);\n }\n return ms * 1e3;\n }\n function nanoRemainder(msFloat) {\n const modulo = 1e6;\n const remainder = msFloat * 1e6 % modulo;\n const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;\n return Math.floor(positiveRemainder);\n }\n function getEpoch(epoch) {\n if (!epoch) {\n return 0;\n }\n if (typeof epoch.getTime === \"function\") {\n return epoch.getTime();\n }\n if (typeof epoch === \"number\") {\n return epoch;\n }\n throw new TypeError(\"now should be milliseconds since UNIX epoch\");\n }\n function inRange(from, to, timer) {\n return timer && timer.callAt >= from && timer.callAt <= to;\n }\n function getInfiniteLoopError(clock, job) {\n const infiniteLoopError = new Error(\n `Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`\n );\n if (!job.error) {\n return infiniteLoopError;\n }\n const computedTargetPattern = /target\\.*[<|(|[].*?[>|\\]|)]\\s*/;\n let clockMethodPattern = new RegExp(\n String(Object.keys(clock).join(\"|\"))\n );\n if (addTimerReturnsObject) {\n clockMethodPattern = new RegExp(\n `\\\\s+at (Object\\\\.)?(?:${Object.keys(clock).join(\"|\")})\\\\s+`\n );\n }\n let matchedLineIndex = -1;\n job.error.stack.split(\"\\n\").some(function(line, i) {\n const matchedComputedTarget = line.match(computedTargetPattern);\n if (matchedComputedTarget) {\n matchedLineIndex = i;\n return true;\n }\n const matchedClockMethod = line.match(clockMethodPattern);\n if (matchedClockMethod) {\n matchedLineIndex = i;\n return false;\n }\n return matchedLineIndex >= 0;\n });\n const stack = `${infiniteLoopError}\n${job.type || \"Microtask\"} - ${job.func.name || \"anonymous\"}\n${job.error.stack.split(\"\\n\").slice(matchedLineIndex + 1).join(\"\\n\")}`;\n try {\n Object.defineProperty(infiniteLoopError, \"stack\", {\n value: stack\n });\n } catch (e) {\n }\n return infiniteLoopError;\n }\n function mirrorDateProperties(target, source) {\n let prop;\n for (prop in source) {\n if (source.hasOwnProperty(prop)) {\n target[prop] = source[prop];\n }\n }\n if (source.now) {\n target.now = function now() {\n return target.clock.now;\n };\n } else {\n delete target.now;\n }\n if (source.toSource) {\n target.toSource = function toSource() {\n return source.toSource();\n };\n } else {\n delete target.toSource;\n }\n target.toString = function toString() {\n return source.toString();\n };\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 }\n function createDate() {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate)) {\n return new NativeDate(ClockDate.clock.now).toString();\n }\n switch (arguments.length) {\n case 0:\n return new NativeDate(ClockDate.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 return mirrorDateProperties(ClockDate, NativeDate);\n }\n function createIntl() {\n const ClockIntl = {};\n Object.getOwnPropertyNames(NativeIntl).forEach(\n (property) => ClockIntl[property] = NativeIntl[property]\n );\n ClockIntl.DateTimeFormat = function(...args) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args);\n const formatter = {};\n [\"formatRange\", \"formatRangeToParts\", \"resolvedOptions\"].forEach(\n (method) => {\n formatter[method] = realFormatter[method].bind(realFormatter);\n }\n );\n [\"format\", \"formatToParts\"].forEach((method) => {\n formatter[method] = function(date) {\n return realFormatter[method](date || ClockIntl.clock.now);\n };\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 }\n function enqueueJob(clock, job) {\n if (!clock.jobs) {\n clock.jobs = [];\n }\n clock.jobs.push(job);\n }\n function runJobs(clock) {\n if (!clock.jobs) {\n return;\n }\n for (let i = 0; i < clock.jobs.length; i++) {\n const job = clock.jobs[i];\n job.func.apply(null, job.args);\n checkIsNearInfiniteLimit(clock, i);\n if (clock.loopLimit && i > clock.loopLimit) {\n throw getInfiniteLoopError(clock, job);\n }\n }\n resetIsNearInfiniteLimit();\n clock.jobs = [];\n }\n function addTimer(clock, timer) {\n if (timer.func === void 0) {\n throw new Error(\"Callback must be provided to timer calls\");\n }\n if (addTimerReturnsObject) {\n if (typeof timer.func !== \"function\") {\n throw new TypeError(\n `[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`\n );\n }\n }\n if (isNearInfiniteLimit) {\n timer.error = new Error();\n }\n timer.type = timer.immediate ? \"Immediate\" : \"Timeout\";\n if (timer.hasOwnProperty(\"delay\")) {\n if (typeof timer.delay !== \"number\") {\n timer.delay = parseInt(timer.delay, 10);\n }\n if (!isNumberFinite(timer.delay)) {\n timer.delay = 0;\n }\n timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;\n timer.delay = Math.max(0, timer.delay);\n }\n if (timer.hasOwnProperty(\"interval\")) {\n timer.type = \"Interval\";\n timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;\n }\n if (timer.hasOwnProperty(\"animation\")) {\n timer.type = \"AnimationFrame\";\n timer.animation = true;\n }\n if (timer.hasOwnProperty(\"idleCallback\")) {\n timer.type = \"IdleCallback\";\n timer.idleCallback = true;\n }\n if (!clock.timers) {\n clock.timers = {};\n }\n timer.id = uniqueTimerId++;\n timer.createdAt = clock.now;\n timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));\n clock.timers[timer.id] = timer;\n if (addTimerReturnsObject) {\n const res = {\n refed: true,\n ref: function() {\n this.refed = true;\n return res;\n },\n unref: function() {\n this.refed = false;\n return res;\n },\n hasRef: function() {\n return this.refed;\n },\n refresh: function() {\n timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));\n clock.timers[timer.id] = timer;\n return res;\n },\n [Symbol.toPrimitive]: function() {\n return timer.id;\n }\n };\n return res;\n }\n return timer.id;\n }\n function compareTimers(a, b) {\n if (a.callAt < b.callAt) {\n return -1;\n }\n if (a.callAt > b.callAt) {\n return 1;\n }\n if (a.immediate && !b.immediate) {\n return -1;\n }\n if (!a.immediate && b.immediate) {\n return 1;\n }\n if (a.createdAt < b.createdAt) {\n return -1;\n }\n if (a.createdAt > b.createdAt) {\n return 1;\n }\n if (a.id < b.id) {\n return -1;\n }\n if (a.id > b.id) {\n return 1;\n }\n }\n function firstTimerInRange(clock, from, to) {\n const timers2 = clock.timers;\n let timer = null;\n let id, isInRange;\n for (id in timers2) {\n if (timers2.hasOwnProperty(id)) {\n isInRange = inRange(from, to, timers2[id]);\n if (isInRange && (!timer || compareTimers(timer, timers2[id]) === 1)) {\n timer = timers2[id];\n }\n }\n }\n return timer;\n }\n function firstTimer(clock) {\n const timers2 = clock.timers;\n let timer = null;\n let id;\n for (id in timers2) {\n if (timers2.hasOwnProperty(id)) {\n if (!timer || compareTimers(timer, timers2[id]) === 1) {\n timer = timers2[id];\n }\n }\n }\n return timer;\n }\n function lastTimer(clock) {\n const timers2 = clock.timers;\n let timer = null;\n let id;\n for (id in timers2) {\n if (timers2.hasOwnProperty(id)) {\n if (!timer || compareTimers(timer, timers2[id]) === -1) {\n timer = timers2[id];\n }\n }\n }\n return timer;\n }\n function callTimer(clock, timer) {\n if (typeof timer.interval === \"number\") {\n clock.timers[timer.id].callAt += timer.interval;\n } else {\n delete clock.timers[timer.id];\n }\n if (typeof timer.func === \"function\") {\n timer.func.apply(null, timer.args);\n } else {\n const eval2 = eval;\n (function() {\n eval2(timer.func);\n })();\n }\n }\n function getClearHandler(ttype) {\n if (ttype === \"IdleCallback\" || ttype === \"AnimationFrame\") {\n return `cancel${ttype}`;\n }\n return `clear${ttype}`;\n }\n function getScheduleHandler(ttype) {\n if (ttype === \"IdleCallback\" || ttype === \"AnimationFrame\") {\n return `request${ttype}`;\n }\n return `set${ttype}`;\n }\n function createWarnOnce() {\n let calls = 0;\n return function(msg) {\n !calls++ && console.warn(msg);\n };\n }\n const warnOnce = createWarnOnce();\n function clearTimer(clock, timerId, ttype) {\n if (!timerId) {\n return;\n }\n if (!clock.timers) {\n clock.timers = {};\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(ttype);\n if (clock.shouldClearNativeTimers === true) {\n const nativeHandler = clock[`_${handlerName}`];\n return typeof nativeHandler === \"function\" ? nativeHandler(timerId) : void 0;\n }\n warnOnce(\n `FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.\nTo automatically clean-up native timers, use \\`shouldClearNativeTimers\\`.`\n );\n }\n if (clock.timers.hasOwnProperty(id)) {\n const timer = clock.timers[id];\n if (timer.type === ttype || timer.type === \"Timeout\" && ttype === \"Interval\" || timer.type === \"Interval\" && ttype === \"Timeout\") {\n delete clock.timers[id];\n } else {\n const clear = getClearHandler(ttype);\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 function uninstall(clock, config) {\n let method, i, l;\n const installedHrTime = \"_hrtime\";\n const installedNextTick = \"_nextTick\";\n for (i = 0, l = clock.methods.length; i < l; i++) {\n method = clock.methods[i];\n if (method === \"performance\") {\n const originalPerfDescriptor = Object.getOwnPropertyDescriptor(\n clock,\n `_${method}`\n );\n if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {\n Object.defineProperty(\n _global,\n method,\n originalPerfDescriptor\n );\n } else if (originalPerfDescriptor.configurable) {\n _global[method] = clock[`_${method}`];\n }\n } else {\n if (_global[method] && _global[method].hadOwnProperty) {\n _global[method] = clock[`_${method}`];\n } else {\n try {\n delete _global[method];\n } catch (ignore) {\n }\n }\n }\n }\n if (config.shouldAdvanceTime === true) {\n _global.clearInterval(clock.attachedInterval);\n }\n clock.methods = [];\n if (!clock.timers) {\n return [];\n }\n return Object.keys(clock.timers).map(function mapper(key) {\n return clock.timers[key];\n });\n }\n function hijackMethod(target, method, clock) {\n clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(\n target,\n method\n );\n clock[`_${method}`] = target[method];\n if (method === \"Date\") {\n const date = mirrorDateProperties(clock[method], target[method]);\n target[method] = date;\n } else if (method === \"Intl\") {\n target[method] = clock[method];\n } else if (method === \"performance\") {\n const originalPerfDescriptor = Object.getOwnPropertyDescriptor(\n target,\n method\n );\n if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {\n Object.defineProperty(\n clock,\n `_${method}`,\n originalPerfDescriptor\n );\n const perfDescriptor = Object.getOwnPropertyDescriptor(\n clock,\n method\n );\n Object.defineProperty(target, method, perfDescriptor);\n } else {\n target[method] = clock[method];\n }\n } else {\n target[method] = function() {\n return clock[method].apply(clock, arguments);\n };\n Object.defineProperties(\n target[method],\n Object.getOwnPropertyDescriptors(clock[method])\n );\n }\n target[method].clock = clock;\n }\n function doIntervalTick(clock, advanceTimeDelta) {\n clock.tick(advanceTimeDelta);\n }\n const timers = {\n setTimeout: _global.setTimeout,\n clearTimeout: _global.clearTimeout,\n setInterval: _global.setInterval,\n clearInterval: _global.clearInterval,\n Date: _global.Date\n };\n if (setImmediatePresent) {\n timers.setImmediate = _global.setImmediate;\n timers.clearImmediate = _global.clearImmediate;\n }\n if (performancePresent) {\n timers.performance = _global.performance;\n }\n if (requestAnimationFramePresent) {\n timers.requestAnimationFrame = _global.requestAnimationFrame;\n }\n if (queueMicrotaskPresent) {\n timers.queueMicrotask = true;\n }\n if (cancelAnimationFramePresent) {\n timers.cancelAnimationFrame = _global.cancelAnimationFrame;\n }\n if (requestIdleCallbackPresent) {\n timers.requestIdleCallback = _global.requestIdleCallback;\n }\n if (cancelIdleCallbackPresent) {\n timers.cancelIdleCallback = _global.cancelIdleCallback;\n }\n if (intlPresent) {\n timers.Intl = _global.Intl;\n }\n const originalSetTimeout = _global.setImmediate || _global.setTimeout;\n function createClock(start, loopLimit) {\n start = Math.floor(getEpoch(start));\n loopLimit = loopLimit || 1e3;\n let nanos = 0;\n const adjustedSystemTime = [0, 0];\n if (NativeDate === void 0) {\n throw new Error(\n \"The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)\"\n );\n }\n const clock = {\n now: start,\n Date: createDate(),\n loopLimit\n };\n clock.Date.clock = clock;\n function getTimeToNextFrame() {\n return 16 - (clock.now - start) % 16;\n }\n function hrtime(prev) {\n const millisSinceStart = clock.now - adjustedSystemTime[0] - start;\n const secsSinceStart = Math.floor(millisSinceStart / 1e3);\n const remainderInNanos = (millisSinceStart - secsSinceStart * 1e3) * 1e6 + nanos - adjustedSystemTime[1];\n if (Array.isArray(prev)) {\n if (prev[1] > 1e9) {\n throw new TypeError(\n \"Number of nanoseconds can't exceed a billion\"\n );\n }\n const oldSecs = prev[0];\n let nanoDiff = remainderInNanos - prev[1];\n let secDiff = secsSinceStart - oldSecs;\n if (nanoDiff < 0) {\n nanoDiff += 1e9;\n secDiff -= 1;\n }\n return [secDiff, nanoDiff];\n }\n return [secsSinceStart, remainderInNanos];\n }\n function fakePerformanceNow() {\n const hrt = hrtime();\n const millis = hrt[0] * 1e3 + hrt[1] / 1e6;\n return millis;\n }\n if (intlPresent) {\n clock.Intl = createIntl();\n clock.Intl.clock = clock;\n }\n clock.requestIdleCallback = function requestIdleCallback(func, timeout) {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0) {\n timeToNextIdlePeriod = 50;\n }\n const result = addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 2),\n delay: typeof timeout === \"undefined\" ? timeToNextIdlePeriod : Math.min(timeout, timeToNextIdlePeriod),\n idleCallback: true\n });\n return Number(result);\n };\n clock.cancelIdleCallback = function cancelIdleCallback(timerId) {\n return clearTimer(clock, timerId, \"IdleCallback\");\n };\n clock.setTimeout = function setTimeout(func, timeout) {\n return addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 2),\n delay: timeout\n });\n };\n clock.clearTimeout = function clearTimeout(timerId) {\n return clearTimer(clock, timerId, \"Timeout\");\n };\n clock.nextTick = function nextTick(func) {\n return enqueueJob(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 1),\n error: isNearInfiniteLimit ? new Error() : null\n });\n };\n clock.queueMicrotask = function queueMicrotask(func) {\n return clock.nextTick(func);\n };\n clock.setInterval = function setInterval(func, timeout) {\n timeout = parseInt(timeout, 10);\n return addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 2),\n delay: timeout,\n interval: timeout\n });\n };\n clock.clearInterval = function clearInterval(timerId) {\n return clearTimer(clock, timerId, \"Interval\");\n };\n if (setImmediatePresent) {\n clock.setImmediate = function setImmediate(func) {\n return addTimer(clock, {\n func,\n args: Array.prototype.slice.call(arguments, 1),\n immediate: true\n });\n };\n clock.clearImmediate = function clearImmediate(timerId) {\n return clearTimer(clock, timerId, \"Immediate\");\n };\n }\n clock.countTimers = function countTimers() {\n return Object.keys(clock.timers || {}).length + (clock.jobs || []).length;\n };\n clock.requestAnimationFrame = function requestAnimationFrame(func) {\n const result = addTimer(clock, {\n func,\n delay: getTimeToNextFrame(),\n get args() {\n return [fakePerformanceNow()];\n },\n animation: true\n });\n return Number(result);\n };\n clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) {\n return clearTimer(clock, timerId, \"AnimationFrame\");\n };\n clock.runMicrotasks = function runMicrotasks() {\n runJobs(clock);\n };\n function doTick(tickValue, isAsync, resolve, reject) {\n const msFloat = typeof tickValue === \"number\" ? tickValue : parseTime(tickValue);\n const ms = Math.floor(msFloat);\n const remainder = nanoRemainder(msFloat);\n let nanosTotal = nanos + remainder;\n let tickTo = clock.now + ms;\n if (msFloat < 0) {\n throw new TypeError(\"Negative ticks are not supported\");\n }\n if (nanosTotal >= 1e6) {\n tickTo += 1;\n nanosTotal -= 1e6;\n }\n nanos = nanosTotal;\n let tickFrom = clock.now;\n let previous = clock.now;\n let timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;\n clock.duringTick = true;\n oldNow = clock.now;\n runJobs(clock);\n if (oldNow !== clock.now) {\n tickFrom += clock.now - oldNow;\n tickTo += clock.now - oldNow;\n }\n function doTickInner() {\n timer = firstTimerInRange(clock, tickFrom, tickTo);\n while (timer && tickFrom <= tickTo) {\n if (clock.timers[timer.id]) {\n tickFrom = timer.callAt;\n clock.now = timer.callAt;\n oldNow = clock.now;\n try {\n runJobs(clock);\n callTimer(clock, timer);\n } catch (e) {\n firstException = firstException || e;\n }\n if (isAsync) {\n originalSetTimeout(nextPromiseTick);\n return;\n }\n compensationCheck();\n }\n postTimerCall();\n }\n oldNow = clock.now;\n runJobs(clock);\n if (oldNow !== clock.now) {\n tickFrom += clock.now - oldNow;\n tickTo += clock.now - oldNow;\n }\n clock.duringTick = false;\n timer = firstTimerInRange(clock, tickFrom, tickTo);\n if (timer) {\n try {\n clock.tick(tickTo - clock.now);\n } catch (e) {\n firstException = firstException || e;\n }\n } else {\n clock.now = tickTo;\n nanos = nanosTotal;\n }\n if (firstException) {\n throw firstException;\n }\n if (isAsync) {\n resolve(clock.now);\n } else {\n return clock.now;\n }\n }\n nextPromiseTick = isAsync && function() {\n try {\n compensationCheck();\n postTimerCall();\n doTickInner();\n } catch (e) {\n reject(e);\n }\n };\n compensationCheck = function() {\n if (oldNow !== clock.now) {\n tickFrom += clock.now - oldNow;\n tickTo += clock.now - oldNow;\n previous += clock.now - oldNow;\n }\n };\n postTimerCall = function() {\n timer = firstTimerInRange(clock, previous, tickTo);\n previous = tickFrom;\n };\n return doTickInner();\n }\n clock.tick = function tick(tickValue) {\n return doTick(tickValue, false);\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.tickAsync = function tickAsync(tickValue) {\n return new _global.Promise(function(resolve, reject) {\n originalSetTimeout(function() {\n try {\n doTick(tickValue, true, resolve, reject);\n } catch (e) {\n reject(e);\n }\n });\n });\n };\n }\n clock.next = function next() {\n runJobs(clock);\n const timer = firstTimer(clock);\n if (!timer) {\n return clock.now;\n }\n clock.duringTick = true;\n try {\n clock.now = timer.callAt;\n callTimer(clock, timer);\n runJobs(clock);\n return clock.now;\n } finally {\n clock.duringTick = false;\n }\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.nextAsync = function nextAsync() {\n return new _global.Promise(function(resolve, reject) {\n originalSetTimeout(function() {\n try {\n const timer = firstTimer(clock);\n if (!timer) {\n resolve(clock.now);\n return;\n }\n let err;\n clock.duringTick = true;\n clock.now = timer.callAt;\n try {\n callTimer(clock, timer);\n } catch (e) {\n err = e;\n }\n clock.duringTick = false;\n originalSetTimeout(function() {\n if (err) {\n reject(err);\n } else {\n resolve(clock.now);\n }\n });\n } catch (e) {\n reject(e);\n }\n });\n });\n };\n }\n clock.runAll = function runAll() {\n let numTimers, i;\n runJobs(clock);\n for (i = 0; i < clock.loopLimit; i++) {\n if (!clock.timers) {\n resetIsNearInfiniteLimit();\n return clock.now;\n }\n numTimers = Object.keys(clock.timers).length;\n if (numTimers === 0) {\n resetIsNearInfiniteLimit();\n return clock.now;\n }\n clock.next();\n checkIsNearInfiniteLimit(clock, i);\n }\n const excessJob = firstTimer(clock);\n throw getInfiniteLoopError(clock, excessJob);\n };\n clock.runToFrame = function runToFrame() {\n return clock.tick(getTimeToNextFrame());\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.runAllAsync = function runAllAsync() {\n return new _global.Promise(function(resolve, reject) {\n let i = 0;\n function doRun() {\n originalSetTimeout(function() {\n try {\n runJobs(clock);\n let numTimers;\n if (i < clock.loopLimit) {\n if (!clock.timers) {\n resetIsNearInfiniteLimit();\n resolve(clock.now);\n return;\n }\n numTimers = Object.keys(\n clock.timers\n ).length;\n if (numTimers === 0) {\n resetIsNearInfiniteLimit();\n resolve(clock.now);\n return;\n }\n clock.next();\n i++;\n doRun();\n checkIsNearInfiniteLimit(clock, i);\n return;\n }\n const excessJob = firstTimer(clock);\n reject(getInfiniteLoopError(clock, excessJob));\n } catch (e) {\n reject(e);\n }\n });\n }\n doRun();\n });\n };\n }\n clock.runToLast = function runToLast() {\n const timer = lastTimer(clock);\n if (!timer) {\n runJobs(clock);\n return clock.now;\n }\n return clock.tick(timer.callAt - clock.now);\n };\n if (typeof _global.Promise !== \"undefined\") {\n clock.runToLastAsync = function runToLastAsync() {\n return new _global.Promise(function(resolve, reject) {\n originalSetTimeout(function() {\n try {\n const timer = lastTimer(clock);\n if (!timer) {\n runJobs(clock);\n resolve(clock.now);\n }\n resolve(clock.tickAsync(timer.callAt - clock.now));\n } catch (e) {\n reject(e);\n }\n });\n });\n };\n }\n clock.reset = function reset() {\n nanos = 0;\n clock.timers = {};\n clock.jobs = [];\n clock.now = start;\n };\n clock.setSystemTime = function setSystemTime(systemTime) {\n const newNow = getEpoch(systemTime);\n const difference = newNow - clock.now;\n let id, timer;\n adjustedSystemTime[0] = adjustedSystemTime[0] + difference;\n adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;\n clock.now = newNow;\n nanos = 0;\n for (id in clock.timers) {\n if (clock.timers.hasOwnProperty(id)) {\n timer = clock.timers[id];\n timer.createdAt += difference;\n timer.callAt += difference;\n }\n }\n };\n clock.jump = function jump(tickValue) {\n const msFloat = typeof tickValue === \"number\" ? tickValue : parseTime(tickValue);\n const ms = Math.floor(msFloat);\n for (const timer of Object.values(clock.timers)) {\n if (clock.now + ms > timer.callAt) {\n timer.callAt = clock.now + ms;\n }\n }\n clock.tick(ms);\n };\n if (performancePresent) {\n clock.performance = /* @__PURE__ */ Object.create(null);\n clock.performance.now = fakePerformanceNow;\n }\n return clock;\n }\n function install(config) {\n console.log(\"INSTALL\", config);\n if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || typeof config === \"number\") {\n throw new TypeError(\n `FakeTimers.install called with ${String(\n config\n )} install requires an object parameter`\n );\n }\n if (_global.Date.isFake === true) {\n throw new TypeError(\n \"Can't install fake timers twice on the same global object.\"\n );\n }\n config = typeof config !== \"undefined\" ? config : {};\n config.shouldAdvanceTime = config.shouldAdvanceTime || false;\n config.advanceTimeDelta = config.advanceTimeDelta || 20;\n config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;\n if (config.target) {\n throw new TypeError(\n \"config.target is no longer supported. Use `withGlobal(target)` instead.\"\n );\n }\n let i, l;\n const clock = createClock(config.now, config.loopLimit);\n clock.shouldClearNativeTimers = config.shouldClearNativeTimers;\n clock.uninstall = function() {\n return uninstall(clock, config);\n };\n clock.methods = config.toFake || [];\n if (clock.methods.length === 0) {\n clock.methods = Object.keys(timers).filter(function(key) {\n return key !== \"nextTick\" && key !== \"queueMicrotask\";\n });\n }\n if (config.shouldAdvanceTime === true) {\n const intervalTick = doIntervalTick.bind(\n null,\n clock,\n config.advanceTimeDelta\n );\n const intervalId = _global.setInterval(\n intervalTick,\n config.advanceTimeDelta\n );\n clock.attachedInterval = intervalId;\n }\n if (clock.methods.includes(\"performance\")) {\n const proto = (() => {\n if (hasPerformanceConstructorPrototype) {\n return _global.performance.constructor.prototype;\n }\n if (hasPerformancePrototype) {\n return _global.Performance.prototype;\n }\n })();\n if (proto) {\n Object.getOwnPropertyNames(proto).forEach(function(name) {\n if (name !== \"now\") {\n clock.performance[name] = name.indexOf(\"getEntries\") === 0 ? NOOP_ARRAY : NOOP;\n }\n });\n } else if ((config.toFake || []).includes(\"performance\")) {\n throw new ReferenceError(\n \"non-existent performance object cannot be faked\"\n );\n }\n }\n for (i = 0, l = clock.methods.length; i < l; i++) {\n const nameOfMethodToReplace = clock.methods[i];\n hijackMethod(_global, nameOfMethodToReplace, clock);\n }\n return clock;\n }\n return {\n timers,\n createClock,\n install,\n withGlobal\n };\n }\n var defaultImplementation = withGlobal(globalThis);\n exports.install = defaultImplementation.install;\n }\n});\n\n// packages/playwright-core/src/server/injected/fakeTimers.ts\nvar fakeTimers_exports = {};\n__export(fakeTimers_exports, {\n inject: () => inject\n});\nmodule.exports = __toCommonJS(fakeTimers_exports);\nvar import_fake_timers_src = __toESM(require_fake_timers_src());\nfunction inject() {\n var _a, _b;\n const window = globalThis;\n const builtin = {\n setTimeout: window.setTimeout.bind(window),\n clearTimeout: window.clearTimeout.bind(window),\n setInterval: window.setInterval.bind(window),\n clearInterval: window.clearInterval.bind(window),\n requestAnimationFrame: window.requestAnimationFrame.bind(window),\n cancelAnimationFrame: window.cancelAnimationFrame.bind(window),\n requestIdleCallback: (_a = window.requestIdleCallback) == null ? void 0 : _a.bind(window),\n cancelIdleCallback: (_b = window.cancelIdleCallback) == null ? void 0 : _b.bind(window),\n performance: window.performance,\n Intl: window.Intl,\n Date: window.Date\n };\n const result = import_fake_timers_src.default;\n result.builtin = builtin;\n return result;\n}\n";

@@ -29,39 +29,77 @@ "use strict";

this._browserContext = void 0;
this._installed = false;
this._scriptInjected = false;
this._fakeTimersInstalled = false;
this._now = 0;
this._browserContext = browserContext;
}
async install(params) {
if (this._installed) throw new Error('Cannot install more than one clock per context');
this._installed = true;
const script = `(() => {
const module = {};
${fakeTimersSource.source}
globalThis.__pwFakeTimers = (module.exports.install())(${JSON.stringify(params)});
})();`;
await this._addAndEvaluate(script);
async installFakeTimers(time, loopLimit) {
await this._injectScriptIfNeeded();
await this._addAndEvaluate(`(() => {
globalThis.__pwFakeTimers.clock?.uninstall();
globalThis.__pwFakeTimers.clock = globalThis.__pwFakeTimers.install(${JSON.stringify({
now: time,
loopLimit
})});
})();`);
this._now = time;
this._fakeTimersInstalled = true;
}
async jump(time) {
async runToNextTimer() {
this._assertInstalled();
await this._addAndEvaluate(`globalThis.__pwFakeTimers.jump(${JSON.stringify(time)})`);
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.clock.next()`);
this._now = await this._evaluateInFrames(`globalThis.__pwFakeTimers.clock.nextAsync()`);
return this._now;
}
async next() {
async runAllTimers() {
this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.next()`);
return await this._evaluateInFrames(`globalThis.__pwFakeTimers.nextAsync()`);
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.clock.runAll()`);
this._now = await this._evaluateInFrames(`globalThis.__pwFakeTimers.clock.runAllAsync()`);
return this._now;
}
async runAll() {
async runToLastTimer() {
this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.runAll()`);
return await this._evaluateInFrames(`globalThis.__pwFakeTimers.runAllAsync()`);
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.clock.runToLast()`);
this._now = await this._evaluateInFrames(`globalThis.__pwFakeTimers.clock.runToLastAsync()`);
return this._now;
}
async runToLast() {
this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.runToLast()`);
return await this._evaluateInFrames(`globalThis.__pwFakeTimers.runToLastAsync()`);
async setTime(time) {
if (this._fakeTimersInstalled) {
const jump = time - this._now;
if (jump < 0) throw new Error('Unable to set time into the past when fake timers are installed');
await this._addAndEvaluate(`globalThis.__pwFakeTimers.clock.jump(${jump})`);
this._now = time;
return this._now;
}
await this._injectScriptIfNeeded();
await this._addAndEvaluate(`(() => {
globalThis.__pwFakeTimers.clock?.uninstall();
globalThis.__pwFakeTimers.clock = globalThis.__pwFakeTimers.install(${JSON.stringify({
now: time,
toFake: ['Date']
})});
})();`);
this._now = time;
return this._now;
}
async tick(time) {
async skipTime(time) {
const delta = parseTime(time);
await this.setTime(this._now + delta);
return this._now;
}
async runFor(time) {
this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.tick(${JSON.stringify(time)})`);
return await this._evaluateInFrames(`globalThis.__pwFakeTimers.tickAsync(${JSON.stringify(time)})`);
await this._browserContext.addInitScript(`globalThis.__pwFakeTimers.clock.tick(${JSON.stringify(time)})`);
this._now = await this._evaluateInFrames(`globalThis.__pwFakeTimers.clock.tickAsync(${JSON.stringify(time)})`);
return this._now;
}
async _injectScriptIfNeeded() {
if (this._scriptInjected) return;
this._scriptInjected = true;
const script = `(() => {
const module = {};
${fakeTimersSource.source}
globalThis.__pwFakeTimers = (module.exports.inject())();
})();`;
await this._addAndEvaluate(script);
}
async _addAndEvaluate(script) {

@@ -77,5 +115,23 @@ await this._browserContext.addInitScript(script);

_assertInstalled() {
if (!this._installed) throw new Error('Clock is not installed');
if (!this._fakeTimersInstalled) throw new Error('Clock is not installed');
}
}
exports.Clock = Clock;
// Taken from sinonjs/fake-timerss-src.
exports.Clock = Clock;
function parseTime(time) {
if (typeof time === 'number') return time;
if (!time) return 0;
const strings = time.split(':');
const l = strings.length;
let i = l;
let ms = 0;
let parsed;
if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(time)) throw new Error(`tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits`);
while (i--) {
parsed = parseInt(strings[i], 10);
if (parsed >= 60) throw new Error(`Invalid time ${time}`);
ms += parsed * Math.pow(60, l - i - 1);
}
return ms * 1000;
}

@@ -306,26 +306,31 @@ "use strict";

}
async clockInstall(params, metadata) {
await this._context.clock.install(params);
async clockInstallFakeTimers(params, metadata) {
await this._context.clock.installFakeTimers(params.time, params.loopLimit);
}
async clockJump(params, metadata) {
await this._context.clock.jump(params.timeString || params.timeNumber || 0);
async clockRunAllTimers(params, metadata) {
return {
fakeTime: await this._context.clock.runAllTimers()
};
}
async clockNext(params, metadata) {
async clockRunToLastTimer(params, metadata) {
return {
fakeTime: await this._context.clock.next()
fakeTime: await this._context.clock.runToLastTimer()
};
}
async clockRunAll(params, metadata) {
async clockRunToNextTimer(params, metadata) {
return {
fakeTime: await this._context.clock.runAll()
fakeTime: await this._context.clock.runToNextTimer()
};
}
async clockRunToLast(params, metadata) {
async clockSetTime(params, metadata) {
await this._context.clock.setTime(params.time);
}
async clockSkipTime(params, metadata) {
return {
fakeTime: await this._context.clock.runToLast()
fakeTime: await this._context.clock.skipTime(params.timeString || params.timeNumber || 0)
};
}
async clockTick(params, metadata) {
async clockRunFor(params, metadata) {
return {
fakeTime: await this._context.clock.tick(params.timeString || params.timeNumber || 0)
fakeTime: await this._context.clock.runFor(params.timeString || params.timeNumber || 0)
};

@@ -332,0 +337,0 @@ }

@@ -227,3 +227,3 @@ "use strict";

firefox: ['libasound2t64', 'libatk1.0-0t64', 'libcairo-gobject2', 'libcairo2', 'libdbus-1-3', 'libfontconfig1', 'libfreetype6', 'libgdk-pixbuf-2.0-0', 'libglib2.0-0t64', 'libgtk-3-0t64', 'libpango-1.0-0', 'libpangocairo-1.0-0', 'libx11-6', 'libx11-xcb1', 'libxcb-shm0', 'libxcb1', 'libxcomposite1', 'libxcursor1', 'libxdamage1', 'libxext6', 'libxfixes3', 'libxi6', 'libxrandr2', 'libxrender1'],
webkit: ['gstreamer1.0-libav', 'gstreamer1.0-plugins-bad', 'gstreamer1.0-plugins-base', 'gstreamer1.0-plugins-good', 'libatomic1', 'libatk-bridge2.0-0t64', 'libatk1.0-0t64', 'libcairo-gobject2', 'libcairo2', 'libdbus-1-3', 'libdrm2', 'libenchant-2-2', 'libepoxy0', 'libevent-2.1-7t64', 'libflite1', 'libfontconfig1', 'libfreetype6', 'libgbm1', 'libgdk-pixbuf-2.0-0', 'libgles2', 'libglib2.0-0t64', 'libgstreamer-gl1.0-0', 'libgstreamer-plugins-bad1.0-0', 'libgstreamer-plugins-base1.0-0', 'libgstreamer1.0-0', 'libgtk-3-0t64', 'libharfbuzz-icu0', 'libharfbuzz0b', 'libhyphen0', 'libicu74', 'libjpeg-turbo8', 'liblcms2-2', 'libmanette-0.2-0', 'libopus0', 'libpango-1.0-0', 'libpangocairo-1.0-0', 'libpng16-16t64', 'libsecret-1-0', 'libvpx9', 'libwayland-client0', 'libwayland-egl1', 'libwayland-server0', 'libwebp7', 'libwebpdemux2', 'libwoff1', 'libx11-6', 'libxkbcommon0', 'libxml2', 'libxslt1.1', 'libx264-164'],
webkit: ['gstreamer1.0-libav', 'gstreamer1.0-plugins-bad', 'gstreamer1.0-plugins-base', 'gstreamer1.0-plugins-good', 'libicu74', 'libatomic1', 'libatk-bridge2.0-0t64', 'libatk1.0-0t64', 'libcairo-gobject2', 'libcairo2', 'libdbus-1-3', 'libdrm2', 'libenchant-2-2', 'libepoxy0', 'libevent-2.1-7t64', 'libflite1', 'libfontconfig1', 'libfreetype6', 'libgbm1', 'libgdk-pixbuf-2.0-0', 'libgles2', 'libglib2.0-0t64', 'libgstreamer-gl1.0-0', 'libgstreamer-plugins-bad1.0-0', 'libgstreamer-plugins-base1.0-0', 'libgstreamer1.0-0', 'libgtk-3-0t64', 'libharfbuzz-icu0', 'libharfbuzz0b', 'libhyphen0', 'libicu74', 'libjpeg-turbo8', 'liblcms2-2', 'libmanette-0.2-0', 'libopus0', 'libpango-1.0-0', 'libpangocairo-1.0-0', 'libpng16-16t64', 'libsecret-1-0', 'libvpx9', 'libwayland-client0', 'libwayland-egl1', 'libwayland-server0', 'libwebp7', 'libwebpdemux2', 'libwoff1', 'libx11-6', 'libxkbcommon0', 'libxml2', 'libxslt1.1', 'libx264-164'],
lib2package: {

@@ -230,0 +230,0 @@ 'libasound.so.2': 'libasound2t64',

@@ -1657,2 +1657,3 @@ /*

function install(config) {
console.log('INSTALL', config);
if (

@@ -1659,0 +1660,0 @@ arguments.length > 1 ||

@@ -390,3 +390,3 @@ "use strict";

const consumeEscape = function () {
// Assume the the current character is the \
// Assume the current character is the \
// and the next code point is not a newline.

@@ -393,0 +393,0 @@ consume();

{
"name": "playwright-core",
"version": "1.45.0-alpha-2024-06-04",
"version": "1.45.0-alpha-2024-06-05",
"description": "A high-level API to automate web browsers",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc