Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

playwright-core

Package Overview
Dependencies
0
Maintainers
4
Versions
4380
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.45.0-alpha-2024-06-07 to 1.45.0-alpha-2024-06-08

lib/vite/traceViewer/assets/codeMirrorModule-CCz01He6.js

4

browsers.json

@@ -18,3 +18,3 @@ {

"name": "firefox",
"revision": "1452",
"revision": "1453",
"installByDefault": true,

@@ -25,3 +25,3 @@ "browserVersion": "126.0"

"name": "firefox-beta",
"revision": "1452",
"revision": "1453",
"installByDefault": false,

@@ -28,0 +28,0 @@ "browserVersion": "127.0b3"

@@ -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/server/injected/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar TimerType = /* @__PURE__ */ ((TimerType2) => {\n TimerType2[\"Timeout\"] = \"Timeout\";\n TimerType2[\"Interval\"] = \"Interval\";\n TimerType2[\"Immediate\"] = \"Immediate\";\n TimerType2[\"AnimationFrame\"] = \"AnimationFrame\";\n TimerType2[\"IdleCallback\"] = \"IdleCallback\";\n return TimerType2;\n})(TimerType || {});\nvar ClockController = class {\n constructor(embedder, startDate, loopLimit = 1e3) {\n this._adjustedSystemTime = 0;\n this._duringTick = false;\n this._timers = /* @__PURE__ */ new Map();\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n const start = Math.floor(getEpoch(startDate));\n this.start = start;\n this._now = start;\n this._embedder = embedder;\n this._loopLimit = loopLimit;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n return this._now;\n }\n performanceNow() {\n return this._now - this._adjustedSystemTime - this.start;\n }\n _doTick(tickValue, isAsync, resolve, reject) {\n const msFloat = typeof tickValue === \"number\" ? tickValue : parseTime(tickValue);\n const ms = Math.floor(msFloat);\n let tickTo = this._now + ms;\n if (msFloat < 0)\n throw new TypeError(\"Negative ticks are not supported\");\n let tickFrom = this._now;\n let previous = this._now;\n let timer;\n let firstException;\n let oldNow;\n let nextPromiseTick;\n let compensationCheck;\n let postTimerCall;\n this._duringTick = true;\n oldNow = this._now;\n if (oldNow !== this._now) {\n tickFrom += this._now - oldNow;\n tickTo += this._now - oldNow;\n }\n const doTickInner = () => {\n timer = this._firstTimerInRange(tickFrom, tickTo);\n while (timer && tickFrom <= tickTo) {\n if (this._timers.has(timer.id)) {\n tickFrom = timer.callAt;\n this._now = timer.callAt;\n oldNow = this._now;\n try {\n this._callTimer(timer);\n } catch (e) {\n firstException = firstException || e;\n }\n if (isAsync) {\n this._embedder.postTask(nextPromiseTick);\n return;\n }\n compensationCheck();\n }\n postTimerCall();\n }\n oldNow = this._now;\n if (oldNow !== this._now) {\n tickFrom += this._now - oldNow;\n tickTo += this._now - oldNow;\n }\n this._duringTick = false;\n timer = this._firstTimerInRange(tickFrom, tickTo);\n if (timer) {\n try {\n this.tick(tickTo - this._now);\n } catch (e) {\n firstException = firstException || e;\n }\n } else {\n this._now = tickTo;\n }\n if (firstException)\n throw firstException;\n if (isAsync)\n resolve(this._now);\n else\n return this._now;\n };\n nextPromiseTick = isAsync ? () => {\n try {\n compensationCheck();\n postTimerCall();\n doTickInner();\n } catch (e) {\n reject(e);\n }\n } : null;\n compensationCheck = () => {\n if (oldNow !== this._now) {\n tickFrom += this._now - oldNow;\n tickTo += this._now - oldNow;\n previous += this._now - oldNow;\n }\n };\n postTimerCall = () => {\n timer = this._firstTimerInRange(previous, tickTo);\n previous = tickFrom;\n };\n return doTickInner();\n }\n tick(tickValue) {\n return this._doTick(tickValue, false);\n }\n async tickAsync(tickValue) {\n await new Promise((f) => this._embedder.postTask(f));\n return new Promise((resolve, reject) => this._doTick(tickValue, true, resolve, reject));\n }\n next() {\n const timer = this._firstTimer();\n if (!timer)\n return this._now;\n this._duringTick = true;\n try {\n this._now = timer.callAt;\n this._callTimer(timer);\n return this._now;\n } finally {\n this._duringTick = false;\n }\n }\n async nextAsync() {\n await new Promise((f) => this._embedder.postTask(f));\n const timer = this._firstTimer();\n if (!timer)\n return this._now;\n let err;\n this._duringTick = true;\n this._now = timer.callAt;\n try {\n this._callTimer(timer);\n } catch (e) {\n err = e;\n }\n this._duringTick = false;\n await new Promise((f) => this._embedder.postTask(f));\n if (err)\n throw err;\n return this._now;\n }\n runAll() {\n for (let i = 0; i < this._loopLimit; i++) {\n const numTimers = this._timers.size;\n if (numTimers === 0)\n return this._now;\n this.next();\n }\n const excessJob = this._firstTimer();\n if (!excessJob)\n return;\n throw this._getInfiniteLoopError(excessJob);\n }\n runToFrame() {\n return this.tick(this.getTimeToNextFrame());\n }\n async runAllAsync() {\n for (let i = 0; i < this._loopLimit; i++) {\n await new Promise((f) => this._embedder.postTask(f));\n const numTimers = this._timers.size;\n if (numTimers === 0)\n return this._now;\n this.next();\n }\n await new Promise((f) => this._embedder.postTask(f));\n const excessJob = this._firstTimer();\n if (!excessJob)\n return;\n throw this._getInfiniteLoopError(excessJob);\n }\n runToLast() {\n const timer = this._lastTimer();\n if (!timer)\n return this._now;\n return this.tick(timer.callAt - this._now);\n }\n runToLastAsync() {\n return new Promise((resolve, reject) => {\n this._embedder.postTask(() => {\n try {\n const timer = this._lastTimer();\n if (!timer) {\n resolve(this._now);\n return;\n }\n this.tickAsync(timer.callAt - this._now).then(resolve);\n } catch (e) {\n reject(e);\n }\n });\n });\n }\n reset() {\n this._timers.clear();\n this._now = this.start;\n }\n setSystemTime(systemTime) {\n const newNow = getEpoch(systemTime);\n const difference = newNow - this._now;\n this._adjustedSystemTime = this._adjustedSystemTime + difference;\n this._now = newNow;\n for (const timer of this._timers.values()) {\n timer.createdAt += difference;\n timer.callAt += difference;\n }\n }\n jump(tickValue) {\n const msFloat = typeof tickValue === \"number\" ? tickValue : parseTime(tickValue);\n const ms = Math.floor(msFloat);\n for (const timer of this._timers.values()) {\n if (this._now + ms > timer.callAt)\n timer.callAt = this._now + ms;\n }\n return this.tick(ms);\n }\n addTimer(options) {\n if (options.func === 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: this._now + (delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n return timer.id;\n }\n _firstTimerInRange(from, to) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = inRange(from, to, timer);\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer() {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n if (!firstTimer || compareTimers(firstTimer, timer) === 1)\n firstTimer = timer;\n }\n return firstTimer;\n }\n _lastTimer() {\n let lastTimer = null;\n for (const timer of this._timers.values()) {\n if (!lastTimer || compareTimers(lastTimer, timer) === -1)\n lastTimer = timer;\n }\n return lastTimer;\n }\n _callTimer(timer) {\n if (timer.type === \"Interval\" /* Interval */)\n this._timers.get(timer.id).callAt += timer.delay;\n else\n this._timers.delete(timer.id);\n callFunction(timer.func, timer.args());\n }\n _getInfiniteLoopError(job) {\n const infiniteLoopError = new Error(\n `Aborting after running ${this._loopLimit} timers, assuming an infinite loop!`\n );\n if (!job.error)\n return infiniteLoopError;\n const computedTargetPattern = /target\\.*[<|(|[].*?[>|\\]|)]\\s*/;\n const clockMethodPattern = new RegExp(\n String(Object.keys(this).join(\"|\"))\n );\n let matchedLineIndex = -1;\n job.error.stack.split(\"\\n\").some((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 funcName = typeof job.func === \"function\" ? job.func.name : \"anonymous\";\n const stack = `${infiniteLoopError}\n${job.type || \"Microtask\"} - ${funcName}\n${job.error.stack.split(\"\\n\").slice(matchedLineIndex + 1).join(\"\\n\")}`;\n infiniteLoopError.stack = stack;\n return infiniteLoopError;\n }\n getTimeToNextFrame() {\n return 16 - (this._now - this.start) % 16;\n }\n clearTimer(timerId, type) {\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 advanceAutomatically(advanceTimeDelta = 20) {\n return this._embedder.postTaskPeriodically(\n () => this.tick(advanceTimeDelta),\n advanceTimeDelta\n );\n }\n};\nfunction getEpoch(epoch) {\n if (!epoch)\n return 0;\n if (typeof epoch !== \"number\")\n return epoch.getTime();\n return epoch;\n}\nfunction inRange(from, to, timer) {\n return timer && timer.callAt >= from && timer.callAt <= to;\n}\nfunction parseTime(str) {\n if (!str)\n return 0;\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 `Clock only understands numbers, 'mm:ss' and 'hh:mm:ss'`\n );\n }\n while (i--) {\n parsed = parseInt(strings[i], 10);\n if (parsed >= 60)\n throw new Error(`Invalid time ${str}`);\n ms += parsed * Math.pow(60, l - i - 1);\n }\n return ms * 1e3;\n}\nfunction mirrorDateProperties(target, source) {\n let prop;\n for (prop of Object.keys(source))\n target[prop] = source[prop];\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.keys(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args2) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args2);\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}\nfunction callFunction(func, args) {\n if (typeof func === \"function\")\n func.apply(null, args);\n else\n (() => {\n eval(func);\n })();\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: (func2, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Timeout\" /* Timeout */,\n func: func2,\n args: () => args2,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, \"Timeout\" /* Timeout */);\n },\n setInterval: (func2, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Interval\" /* Interval */,\n func: func2,\n args: () => args2,\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 args: () => [clock.performanceNow()]\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 args: () => [],\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 timeOrigin: clock.start\n };\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, config = {}) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n postTask: (task) => {\n originals.bound.setTimeout(task, 0);\n },\n postTaskPeriodically: (task, delay) => {\n const intervalId = globalObject.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder, config.now, config.loopLimit);\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, config);\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 } else {\n globalObject[method] = (...args2) => {\n return api[method].apply(api, args2);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n return {\n install: (config) => {\n const { clock } = install(globalObject, config);\n return clock;\n },\n builtin: platformOriginals(globalObject).bound\n };\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/server/injected/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar TimerType = /* @__PURE__ */ ((TimerType2) => {\n TimerType2[\"Timeout\"] = \"Timeout\";\n TimerType2[\"Interval\"] = \"Interval\";\n TimerType2[\"Immediate\"] = \"Immediate\";\n TimerType2[\"AnimationFrame\"] = \"AnimationFrame\";\n TimerType2[\"IdleCallback\"] = \"IdleCallback\";\n return TimerType2;\n})(TimerType || {});\nvar ClockController = class {\n constructor(embedder, startDate, loopLimit = 1e3) {\n this._adjustedSystemTime = 0;\n this._duringTick = false;\n this._timers = /* @__PURE__ */ new Map();\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n const start = Math.floor(getEpoch(startDate));\n this.start = start;\n this._now = start;\n this._embedder = embedder;\n this._loopLimit = loopLimit;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n return this._now;\n }\n performanceNow() {\n return this._now - this._adjustedSystemTime - this.start;\n }\n async _doTick(msFloat) {\n if (msFloat < 0)\n throw new TypeError(\"Negative ticks are not supported\");\n const ms = Math.floor(msFloat);\n let tickTo = this._now + ms;\n let tickFrom = this._now;\n let previous = this._now;\n let firstException;\n this._duringTick = true;\n let timer = this._firstTimerInRange(tickFrom, tickTo);\n while (timer && tickFrom <= tickTo) {\n tickFrom = timer.callAt;\n this._now = timer.callAt;\n const oldNow = this._now;\n try {\n this._callTimer(timer);\n await new Promise((f) => this._embedder.postTask(f));\n } catch (e) {\n firstException = firstException || e;\n }\n if (oldNow !== this._now) {\n tickFrom += this._now - oldNow;\n tickTo += this._now - oldNow;\n previous += this._now - oldNow;\n }\n timer = this._firstTimerInRange(previous, tickTo);\n previous = tickFrom;\n }\n this._duringTick = false;\n this._now = tickTo;\n if (firstException)\n throw firstException;\n return this._now;\n }\n async recordTick(tickValue) {\n const msFloat = parseTime(tickValue);\n this._now += msFloat;\n }\n async tick(tickValue) {\n return await this._doTick(parseTime(tickValue));\n }\n async next() {\n const timer = this._firstTimer();\n if (!timer)\n return this._now;\n let err;\n this._duringTick = true;\n this._now = timer.callAt;\n try {\n this._callTimer(timer);\n await new Promise((f) => this._embedder.postTask(f));\n } catch (e) {\n err = e;\n }\n this._duringTick = false;\n if (err)\n throw err;\n return this._now;\n }\n async runToFrame() {\n return this.tick(this.getTimeToNextFrame());\n }\n async runAll() {\n for (let i = 0; i < this._loopLimit; i++) {\n const numTimers = this._timers.size;\n if (numTimers === 0)\n return this._now;\n await this.next();\n }\n const excessJob = this._firstTimer();\n if (!excessJob)\n return;\n throw this._getInfiniteLoopError(excessJob);\n }\n async runToLast() {\n const timer = this._lastTimer();\n if (!timer)\n return this._now;\n return await this.tick(timer.callAt - this._now);\n }\n reset() {\n this._timers.clear();\n this._now = this.start;\n }\n setSystemTime(systemTime) {\n const newNow = getEpoch(systemTime);\n const difference = newNow - this._now;\n this._adjustedSystemTime = this._adjustedSystemTime + difference;\n this._now = newNow;\n for (const timer of this._timers.values()) {\n timer.createdAt += difference;\n timer.callAt += difference;\n }\n }\n async jump(tickValue) {\n const msFloat = parseTime(tickValue);\n const ms = Math.floor(msFloat);\n for (const timer of this._timers.values()) {\n if (this._now + ms > timer.callAt)\n timer.callAt = this._now + ms;\n }\n return await this.tick(ms);\n }\n addTimer(options) {\n if (options.func === 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: this._now + (delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n return timer.id;\n }\n _firstTimerInRange(from, to) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = inRange(from, to, timer);\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer() {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n if (!firstTimer || compareTimers(firstTimer, timer) === 1)\n firstTimer = timer;\n }\n return firstTimer;\n }\n _lastTimer() {\n let lastTimer = null;\n for (const timer of this._timers.values()) {\n if (!lastTimer || compareTimers(lastTimer, timer) === -1)\n lastTimer = timer;\n }\n return lastTimer;\n }\n _callTimer(timer) {\n if (timer.type === \"Interval\" /* Interval */)\n this._timers.get(timer.id).callAt += timer.delay;\n else\n this._timers.delete(timer.id);\n callFunction(timer.func, timer.args());\n }\n _getInfiniteLoopError(job) {\n const infiniteLoopError = new Error(\n `Aborting after running ${this._loopLimit} timers, assuming an infinite loop!`\n );\n if (!job.error)\n return infiniteLoopError;\n const computedTargetPattern = /target\\.*[<|(|[].*?[>|\\]|)]\\s*/;\n const clockMethodPattern = new RegExp(\n String(Object.keys(this).join(\"|\"))\n );\n let matchedLineIndex = -1;\n job.error.stack.split(\"\\n\").some((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 funcName = typeof job.func === \"function\" ? job.func.name : \"anonymous\";\n const stack = `${infiniteLoopError}\n${job.type || \"Microtask\"} - ${funcName}\n${job.error.stack.split(\"\\n\").slice(matchedLineIndex + 1).join(\"\\n\")}`;\n infiniteLoopError.stack = stack;\n return infiniteLoopError;\n }\n getTimeToNextFrame() {\n return 16 - (this._now - this.start) % 16;\n }\n clearTimer(timerId, type) {\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 advanceAutomatically(advanceTimeDelta = 20) {\n return this._embedder.postTaskPeriodically(\n () => this.tick(advanceTimeDelta),\n advanceTimeDelta\n );\n }\n};\nfunction getEpoch(epoch) {\n if (!epoch)\n return 0;\n if (typeof epoch !== \"number\")\n return epoch.getTime();\n return epoch;\n}\nfunction inRange(from, to, timer) {\n return timer && timer.callAt >= from && timer.callAt <= to;\n}\nfunction parseTime(value) {\n if (typeof value === \"number\")\n return value;\n if (!value)\n return 0;\n const str = value;\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 `Clock only understands numbers, 'mm:ss' and 'hh:mm:ss'`\n );\n }\n while (i--) {\n parsed = parseInt(strings[i], 10);\n if (parsed >= 60)\n throw new Error(`Invalid time ${str}`);\n ms += parsed * Math.pow(60, l - i - 1);\n }\n return ms * 1e3;\n}\nfunction mirrorDateProperties(target, source) {\n let prop;\n for (prop of Object.keys(source))\n target[prop] = source[prop];\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.keys(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args2) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args2);\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}\nfunction callFunction(func, args) {\n if (typeof func === \"function\")\n func.apply(null, args);\n else\n (() => {\n eval(func);\n })();\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: (func2, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Timeout\" /* Timeout */,\n func: func2,\n args: () => args2,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, \"Timeout\" /* Timeout */);\n },\n setInterval: (func2, timeout, ...args2) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Interval\" /* Interval */,\n func: func2,\n args: () => args2,\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 args: () => [clock.performanceNow()]\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 args: () => [],\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 timeOrigin: clock.start\n };\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, config = {}) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n postTask: (task) => {\n originals.bound.setTimeout(task, 0);\n },\n postTaskPeriodically: (task, delay) => {\n const intervalId = globalObject.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder, config.now, config.loopLimit);\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, config);\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 } else {\n globalObject[method] = (...args2) => {\n return api[method].apply(api, args2);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n return {\n install: (config) => {\n const { clock } = install(globalObject, config);\n return clock;\n },\n builtin: platformOriginals(globalObject).bound\n };\n}\n";

@@ -48,4 +48,3 @@ "use strict";

this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwClock.clock.next()`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.nextAsync()`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.next()`);
return this._now;

@@ -55,4 +54,3 @@ }

this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwClock.clock.runAll()`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.runAllAsync()`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.runAll()`);
return this._now;

@@ -62,4 +60,3 @@ }

this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwClock.clock.runToLast()`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.runToLastAsync()`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.runToLast()`);
return this._now;

@@ -93,4 +90,4 @@ }

this._assertInstalled();
await this._browserContext.addInitScript(`globalThis.__pwClock.clock.tick(${JSON.stringify(time)})`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.tickAsync(${JSON.stringify(time)})`);
await this._browserContext.addInitScript(`globalThis.__pwClock.clock.recordTick(${JSON.stringify(time)})`);
this._now = await this._evaluateInFrames(`globalThis.__pwClock.clock.tick(${JSON.stringify(time)})`);
return this._now;

@@ -97,0 +94,0 @@ }

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc