playwright-core 1.57.0-alpha-2025-10-14 → 1.57.0-alpha-2025-10-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/locator.js +3 -0
- package/lib/generated/clockSource.js +1 -1
- package/lib/server/bidi/bidiPage.js +2 -0
- package/lib/server/chromium/crServiceWorker.js +1 -1
- package/lib/server/frames.js +4 -2
- package/lib/server/registry/oopDownloadBrowserMain.js +6 -2
- package/lib/server/utils/comparators.js +3 -25
- package/lib/server/utils/imageUtils.js +146 -0
- package/lib/utils/isomorphic/locatorGenerators.js +24 -8
- package/lib/utils/isomorphic/urlMatch.js +5 -2
- package/lib/utils.js +2 -0
- package/lib/vite/htmlReport/index.html +15 -15
- package/lib/vite/recorder/assets/{codeMirrorModule-RJCXzfmE.js → codeMirrorModule-C3YIS0Zg.js} +1 -1
- package/lib/vite/recorder/assets/{index-Y-X2TGJv.js → index-BuEOMwzr.js} +32 -32
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-B5uKI6RV.js → codeMirrorModule-QoZcmYJg.js} +1 -1
- package/lib/vite/traceViewer/assets/{defaultSettingsView-Dcxv4etY.js → defaultSettingsView-Bd3YdMqb.js} +71 -71
- package/lib/vite/traceViewer/{defaultSettingsView.TQ8_7ybu.css → defaultSettingsView.B35d-g1v.css} +1 -1
- package/lib/vite/traceViewer/{index.BhvsVh_m.js → index.Dml2uxSs.js} +1 -1
- package/lib/vite/traceViewer/index.html +3 -3
- package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/lib/vite/traceViewer/{uiMode.CMlmoI2k.js → uiMode.CT7r23XF.js} +1 -1
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/package.json +1 -1
- package/types/types.d.ts +17 -0
package/lib/client/locator.js
CHANGED
|
@@ -167,6 +167,9 @@ class Locator {
|
|
|
167
167
|
describe(description) {
|
|
168
168
|
return new Locator(this._frame, this._selector + " >> internal:describe=" + JSON.stringify(description));
|
|
169
169
|
}
|
|
170
|
+
description() {
|
|
171
|
+
return (0, import_locatorGenerators.locatorCustomDescription)(this._selector) || null;
|
|
172
|
+
}
|
|
170
173
|
first() {
|
|
171
174
|
return new Locator(this._frame, this._selector + " >> nth=0");
|
|
172
175
|
}
|
|
@@ -21,7 +21,7 @@ __export(clockSource_exports, {
|
|
|
21
21
|
source: () => source
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(clockSource_exports);
|
|
24
|
-
const source = '\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, \'default\': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/injected/src/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar ClockController = class {\n constructor(embedder) {\n this._duringTick = false;\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n this._log = [];\n this._timers = /* @__PURE__ */ new Map();\n this._now = { time: asWallTime(0), isFixedTime: false, ticks: 0, origin: asWallTime(-1) };\n this._embedder = embedder;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n this._replayLogOnce();\n this._syncRealTime();\n return this._now.time;\n }\n install(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setSystemTime(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setFixedTime(time) {\n this._replayLogOnce();\n this._innerSetFixedTime(asWallTime(time));\n }\n performanceNow() {\n this._replayLogOnce();\n this._syncRealTime();\n return this._now.ticks;\n }\n _syncRealTime() {\n if (!this._realTime)\n return;\n const now = this._embedder.performanceNow();\n const sinceLastSync = now - this._realTime.lastSyncTicks;\n if (sinceLastSync > 0) {\n this._advanceNow(shiftTicks(this._now.ticks, sinceLastSync));\n this._realTime.lastSyncTicks = now;\n }\n }\n _innerSetTime(time) {\n this._now.time = time;\n this._now.isFixedTime = false;\n if (this._now.origin < 0)\n this._now.origin = this._now.time;\n }\n _innerSetFixedTime(time) {\n this._innerSetTime(time);\n this._now.isFixedTime = true;\n }\n _advanceNow(to) {\n if (!this._now.isFixedTime)\n this._now.time = asWallTime(this._now.time + to - this._now.ticks);\n this._now.ticks = to;\n }\n async log(type, time, param) {\n this._log.push({ type, time, param });\n }\n async runFor(ticks) {\n this._replayLogOnce();\n if (ticks < 0)\n throw new TypeError("Negative ticks are not supported");\n await this._runWithDisabledRealTimeSync(async () => {\n await this._runTo(shiftTicks(this._now.ticks, ticks));\n });\n }\n async _runTo(to) {\n to = Math.ceil(to);\n if (this._now.ticks > to)\n return;\n let firstException;\n while (true) {\n const result = await this._callFirstTimer(to);\n if (!result.timerFound)\n break;\n firstException = firstException || result.error;\n }\n this._advanceNow(to);\n if (firstException)\n throw firstException;\n }\n async pauseAt(time) {\n this._replayLogOnce();\n await this._innerPause();\n const toConsume = time - this._now.time;\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, toConsume));\n return toConsume;\n }\n async _innerPause() {\n var _a;\n this._realTime = void 0;\n await ((_a = this._currentRealTimeTimer) == null ? void 0 : _a.dispose());\n this._currentRealTimeTimer = void 0;\n }\n resume() {\n this._replayLogOnce();\n this._innerResume();\n }\n _innerResume() {\n const now = this._embedder.performanceNow();\n this._realTime = { startTicks: now, lastSyncTicks: now };\n this._updateRealTimeTimer();\n }\n _updateRealTimeTimer() {\n var _a;\n if ((_a = this._currentRealTimeTimer) == null ? void 0 : _a.promise) {\n return;\n }\n const firstTimer = this._firstTimer();\n const nextTick = Math.min(firstTimer ? firstTimer.callAt : this._now.ticks + maxTimeout, this._now.ticks + 100);\n const callAt = this._currentRealTimeTimer ? Math.min(this._currentRealTimeTimer.callAt, nextTick) : nextTick;\n if (this._currentRealTimeTimer) {\n this._currentRealTimeTimer.cancel();\n this._currentRealTimeTimer = void 0;\n }\n const realTimeTimer = {\n callAt,\n promise: void 0,\n cancel: this._embedder.setTimeout(() => {\n this._syncRealTime();\n realTimeTimer.promise = this._runTo(this._now.ticks).catch((e) => console.error(e));\n void realTimeTimer.promise.then(() => {\n this._currentRealTimeTimer = void 0;\n if (this._realTime)\n this._updateRealTimeTimer();\n });\n }, callAt - this._now.ticks),\n dispose: async () => {\n realTimeTimer.cancel();\n await realTimeTimer.promise;\n }\n };\n this._currentRealTimeTimer = realTimeTimer;\n }\n async _runWithDisabledRealTimeSync(fn) {\n if (!this._realTime) {\n await fn();\n return;\n }\n await this._innerPause();\n try {\n await fn();\n } finally {\n this._innerResume();\n }\n }\n async fastForward(ticks) {\n this._replayLogOnce();\n await this._runWithDisabledRealTimeSync(async () => {\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, ticks | 0));\n });\n }\n async _innerFastForwardTo(to) {\n if (to < this._now.ticks)\n throw new Error("Cannot fast-forward to the past");\n for (const timer of this._timers.values()) {\n if (to > timer.callAt)\n timer.callAt = to;\n }\n await this._runTo(to);\n }\n addTimer(options) {\n this._replayLogOnce();\n if (options.type === "AnimationFrame" /* AnimationFrame */ && !options.func)\n throw new Error("Callback must be provided to requestAnimationFrame calls");\n if (options.type === "IdleCallback" /* IdleCallback */ && !options.func)\n throw new Error("Callback must be provided to requestIdleCallback calls");\n if (["Timeout" /* Timeout */, "Interval" /* Interval */].includes(options.type) && !options.func && options.delay === void 0)\n throw new Error("Callback must be provided to timer calls");\n let delay = options.delay ? +options.delay : 0;\n if (!Number.isFinite(delay))\n delay = 0;\n delay = delay > maxTimeout ? 1 : delay;\n delay = Math.max(0, delay);\n const timer = {\n type: options.type,\n func: options.func,\n args: options.args || [],\n delay,\n callAt: shiftTicks(this._now.ticks, delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now.ticks,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n if (this._realTime)\n this._updateRealTimeTimer();\n return timer.id;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer(beforeTick) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = beforeTick === void 0 || timer.callAt <= beforeTick;\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n _takeFirstTimer(beforeTick) {\n const timer = this._firstTimer(beforeTick);\n if (!timer)\n return null;\n this._advanceNow(timer.callAt);\n if (timer.type === "Interval" /* Interval */)\n timer.callAt = shiftTicks(timer.callAt, timer.delay);\n else\n this._timers.delete(timer.id);\n return timer;\n }\n async _callFirstTimer(beforeTick) {\n const timer = this._takeFirstTimer(beforeTick);\n if (!timer)\n return { timerFound: false };\n this._duringTick = true;\n try {\n if (typeof timer.func !== "function") {\n let error2;\n try {\n (() => {\n globalThis.eval(timer.func);\n })();\n } catch (e) {\n error2 = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error: error2 };\n }\n let args = timer.args;\n if (timer.type === "AnimationFrame" /* AnimationFrame */)\n args = [this._now.ticks];\n else if (timer.type === "IdleCallback" /* IdleCallback */)\n args = [{ didTimeout: false, timeRemaining: () => 0 }];\n let error;\n try {\n timer.func.apply(null, args);\n } catch (e) {\n error = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error };\n } finally {\n this._duringTick = false;\n }\n }\n getTimeToNextFrame() {\n return 16 - this._now.ticks % 16;\n }\n clearTimer(timerId, type) {\n this._replayLogOnce();\n if (!timerId) {\n return;\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(type);\n new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);\n }\n const timer = this._timers.get(id);\n if (timer) {\n if (timer.type === type || timer.type === "Timeout" && type === "Interval" || timer.type === "Interval" && type === "Timeout") {\n this._timers.delete(id);\n } else {\n const clear = getClearHandler(type);\n const schedule = getScheduleHandler(timer.type);\n throw new Error(\n `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`\n );\n }\n }\n }\n _replayLogOnce() {\n if (!this._log.length)\n return;\n let lastLogTime = -1;\n let isPaused = false;\n for (const { type, time, param } of this._log) {\n if (!isPaused && lastLogTime !== -1)\n this._advanceNow(shiftTicks(this._now.ticks, time - lastLogTime));\n lastLogTime = time;\n if (type === "install") {\n this._innerSetTime(asWallTime(param));\n } else if (type === "fastForward" || type === "runFor") {\n this._advanceNow(shiftTicks(this._now.ticks, param));\n } else if (type === "pauseAt") {\n isPaused = true;\n this._innerSetTime(asWallTime(param));\n } else if (type === "resume") {\n isPaused = false;\n } else if (type === "setFixedTime") {\n this._innerSetFixedTime(asWallTime(param));\n } else if (type === "setSystemTime") {\n this._innerSetTime(asWallTime(param));\n }\n }\n if (!isPaused) {\n if (lastLogTime > 0)\n this._advanceNow(shiftTicks(this._now.ticks, this._embedder.dateNow() - lastLogTime));\n this._innerResume();\n } else {\n this._realTime = void 0;\n }\n this._log.length = 0;\n }\n};\nfunction mirrorDateProperties(target, source) {\n for (const prop in source) {\n if (source.hasOwnProperty(prop))\n target[prop] = source[prop];\n }\n target.toString = () => source.toString();\n target.prototype = source.prototype;\n target.parse = source.parse;\n target.UTC = source.UTC;\n target.prototype.toUTCString = source.prototype.toUTCString;\n target.isFake = true;\n return target;\n}\nfunction createDate(clock, NativeDate) {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate))\n return new NativeDate(clock.now()).toString();\n switch (arguments.length) {\n case 0:\n return new NativeDate(clock.now());\n case 1:\n return new NativeDate(year);\n case 2:\n return new NativeDate(year, month);\n case 3:\n return new NativeDate(year, month, date);\n case 4:\n return new NativeDate(year, month, date, hour);\n case 5:\n return new NativeDate(year, month, date, hour, minute);\n case 6:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second\n );\n default:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second,\n ms\n );\n }\n }\n ClockDate.now = () => clock.now();\n return mirrorDateProperties(ClockDate, NativeDate);\n}\nfunction createIntl(clock, NativeIntl) {\n const ClockIntl = {};\n for (const key of Object.getOwnPropertyNames(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args);\n const formatter = {\n formatRange: realFormatter.formatRange.bind(realFormatter),\n formatRangeToParts: realFormatter.formatRangeToParts.bind(realFormatter),\n resolvedOptions: realFormatter.resolvedOptions.bind(realFormatter),\n format: (date) => realFormatter.format(date || clock.now()),\n formatToParts: (date) => realFormatter.formatToParts(date || clock.now())\n };\n return formatter;\n };\n ClockIntl.DateTimeFormat.prototype = Object.create(\n NativeIntl.DateTimeFormat.prototype\n );\n ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;\n return ClockIntl;\n}\nfunction compareTimers(a, b) {\n if (a.callAt < b.callAt)\n return -1;\n if (a.callAt > b.callAt)\n return 1;\n if (a.type === "Immediate" /* Immediate */ && b.type !== "Immediate" /* Immediate */)\n return -1;\n if (a.type !== "Immediate" /* Immediate */ && b.type === "Immediate" /* Immediate */)\n return 1;\n if (a.createdAt < b.createdAt)\n return -1;\n if (a.createdAt > b.createdAt)\n return 1;\n if (a.id < b.id)\n return -1;\n if (a.id > b.id)\n return 1;\n}\nvar maxTimeout = Math.pow(2, 31) - 1;\nvar idCounterStart = 1e12;\nfunction platformOriginals(globalObject) {\n const raw = {\n setTimeout: globalObject.setTimeout,\n clearTimeout: globalObject.clearTimeout,\n setInterval: globalObject.setInterval,\n clearInterval: globalObject.clearInterval,\n requestAnimationFrame: globalObject.requestAnimationFrame ? globalObject.requestAnimationFrame : void 0,\n cancelAnimationFrame: globalObject.cancelAnimationFrame ? globalObject.cancelAnimationFrame : void 0,\n requestIdleCallback: globalObject.requestIdleCallback ? globalObject.requestIdleCallback : void 0,\n cancelIdleCallback: globalObject.cancelIdleCallback ? globalObject.cancelIdleCallback : void 0,\n Date: globalObject.Date,\n performance: globalObject.performance,\n Intl: globalObject.Intl\n };\n const bound = { ...raw };\n for (const key of Object.keys(bound)) {\n if (key !== "Date" && typeof bound[key] === "function")\n bound[key] = bound[key].bind(globalObject);\n }\n return { raw, bound };\n}\nfunction getScheduleHandler(type) {\n if (type === "IdleCallback" || type === "AnimationFrame")\n return `request${type}`;\n return `set${type}`;\n}\nfunction createApi(clock, originals) {\n return {\n setTimeout: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: "Timeout" /* Timeout */,\n func,\n args,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, "Timeout" /* Timeout */);\n },\n setInterval: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: "Interval" /* Interval */,\n func,\n args,\n delay\n });\n },\n clearInterval: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, "Interval" /* Interval */);\n },\n requestAnimationFrame: (callback) => {\n return clock.addTimer({\n type: "AnimationFrame" /* AnimationFrame */,\n func: callback,\n delay: clock.getTimeToNextFrame()\n });\n },\n cancelAnimationFrame: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, "AnimationFrame" /* AnimationFrame */);\n },\n requestIdleCallback: (callback, options) => {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0)\n timeToNextIdlePeriod = 50;\n return clock.addTimer({\n type: "IdleCallback" /* IdleCallback */,\n func: callback,\n delay: (options == null ? void 0 : options.timeout) ? Math.min(options == null ? void 0 : options.timeout, timeToNextIdlePeriod) : timeToNextIdlePeriod\n });\n },\n cancelIdleCallback: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, "IdleCallback" /* IdleCallback */);\n },\n Intl: originals.Intl ? createIntl(clock, originals.Intl) : void 0,\n Date: createDate(clock, originals.Date),\n performance: originals.performance ? fakePerformance(clock, originals.performance) : void 0\n };\n}\nfunction getClearHandler(type) {\n if (type === "IdleCallback" || type === "AnimationFrame")\n return `cancel${type}`;\n return `clear${type}`;\n}\nfunction fakePerformance(clock, performance) {\n const result = {\n now: () => clock.performanceNow()\n };\n result.__defineGetter__("timeOrigin", () => clock._now.origin || 0);\n for (const key of Object.keys(performance.__proto__)) {\n if (key === "now" || key === "timeOrigin")\n continue;\n if (key === "getEntries" || key === "getEntriesByName" || key === "getEntriesByType")\n result[key] = () => [];\n else\n result[key] = () => {\n };\n }\n return result;\n}\nfunction createClock(globalObject) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n dateNow: () => originals.raw.Date.now(),\n performanceNow: () => Math.ceil(originals.raw.performance.now()),\n setTimeout: (task, timeout) => {\n const timerId = originals.bound.setTimeout(task, timeout);\n return () => originals.bound.clearTimeout(timerId);\n },\n setInterval: (task, delay) => {\n const intervalId = originals.bound.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder);\n const api = createApi(clock, originals.bound);\n return { clock, api, originals: originals.raw };\n}\nfunction install(globalObject, config = {}) {\n var _a, _b;\n if ((_a = globalObject.Date) == null ? void 0 : _a.isFake) {\n throw new TypeError(`Can\'t install fake timers twice on the same global object.`);\n }\n const { clock, api, originals } = createClock(globalObject);\n const toFake = ((_b = config.toFake) == null ? void 0 : _b.length) ? config.toFake : Object.keys(originals);\n for (const method of toFake) {\n if (method === "Date") {\n globalObject.Date = mirrorDateProperties(api.Date, globalObject.Date);\n } else if (method === "Intl") {\n globalObject.Intl = api[method];\n } else if (method === "performance") {\n globalObject.performance = api[method];\n const kEventTimeStamp = Symbol("playwrightEventTimeStamp");\n Object.defineProperty(Event.prototype, "timeStamp", {\n get() {\n var _a2;\n if (!this[kEventTimeStamp])\n this[kEventTimeStamp] = (_a2 = api.performance) == null ? void 0 : _a2.now();\n return this[kEventTimeStamp];\n }\n });\n } else {\n globalObject[method] = (...args) => {\n return api[method].apply(api, args);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n const builtins = platformOriginals(globalObject).bound;\n const { clock: controller } = install(globalObject);\n controller.resume();\n return {\n controller,\n builtins\n };\n}\nfunction asWallTime(n) {\n return n;\n}\nfunction shiftTicks(ticks, ms) {\n return ticks + ms;\n}\n';
|
|
24
|
+
const source = '\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, \'default\': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/injected/src/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar ClockController = class {\n constructor(embedder) {\n this._duringTick = false;\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n this._log = [];\n this._timers = /* @__PURE__ */ new Map();\n this._now = { time: asWallTime(0), isFixedTime: false, ticks: 0, origin: asWallTime(-1) };\n this._embedder = embedder;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n this._replayLogOnce();\n this._syncRealTime();\n return this._now.time;\n }\n install(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setSystemTime(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setFixedTime(time) {\n this._replayLogOnce();\n this._innerSetFixedTime(asWallTime(time));\n }\n performanceNow() {\n this._replayLogOnce();\n this._syncRealTime();\n return this._now.ticks;\n }\n _syncRealTime() {\n if (!this._realTime)\n return;\n const now = this._embedder.performanceNow();\n const sinceLastSync = now - this._realTime.lastSyncTicks;\n if (sinceLastSync > 0) {\n this._advanceNow(shiftTicks(this._now.ticks, sinceLastSync));\n this._realTime.lastSyncTicks = now;\n }\n }\n _innerSetTime(time) {\n this._now.time = time;\n this._now.isFixedTime = false;\n if (this._now.origin < 0)\n this._now.origin = this._now.time;\n }\n _innerSetFixedTime(time) {\n this._innerSetTime(time);\n this._now.isFixedTime = true;\n }\n _advanceNow(to) {\n if (this._now.ticks > to) {\n return;\n }\n if (!this._now.isFixedTime)\n this._now.time = asWallTime(this._now.time + to - this._now.ticks);\n this._now.ticks = to;\n }\n async log(type, time, param) {\n this._log.push({ type, time, param });\n }\n async runFor(ticks) {\n this._replayLogOnce();\n if (ticks < 0)\n throw new TypeError("Negative ticks are not supported");\n await this._runWithDisabledRealTimeSync(async () => {\n await this._runTo(shiftTicks(this._now.ticks, ticks));\n });\n }\n async _runTo(to) {\n to = Math.ceil(to);\n if (this._now.ticks > to)\n return;\n let firstException;\n while (true) {\n const result = await this._callFirstTimer(to);\n if (!result.timerFound)\n break;\n firstException = firstException || result.error;\n }\n this._advanceNow(to);\n if (firstException)\n throw firstException;\n }\n async pauseAt(time) {\n this._replayLogOnce();\n await this._innerPause();\n const toConsume = time - this._now.time;\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, toConsume));\n return toConsume;\n }\n async _innerPause() {\n var _a;\n this._realTime = void 0;\n await ((_a = this._currentRealTimeTimer) == null ? void 0 : _a.dispose());\n this._currentRealTimeTimer = void 0;\n }\n resume() {\n this._replayLogOnce();\n this._innerResume();\n }\n _innerResume() {\n const now = this._embedder.performanceNow();\n this._realTime = { startTicks: now, lastSyncTicks: now };\n this._updateRealTimeTimer();\n }\n _updateRealTimeTimer() {\n var _a;\n if ((_a = this._currentRealTimeTimer) == null ? void 0 : _a.promise) {\n return;\n }\n const firstTimer = this._firstTimer();\n const nextTick = Math.min(firstTimer ? firstTimer.callAt : this._now.ticks + maxTimeout, this._now.ticks + 100);\n const callAt = this._currentRealTimeTimer ? Math.min(this._currentRealTimeTimer.callAt, nextTick) : nextTick;\n if (this._currentRealTimeTimer) {\n this._currentRealTimeTimer.cancel();\n this._currentRealTimeTimer = void 0;\n }\n const realTimeTimer = {\n callAt,\n promise: void 0,\n cancel: this._embedder.setTimeout(() => {\n this._syncRealTime();\n realTimeTimer.promise = this._runTo(this._now.ticks).catch((e) => console.error(e));\n void realTimeTimer.promise.then(() => {\n this._currentRealTimeTimer = void 0;\n if (this._realTime)\n this._updateRealTimeTimer();\n });\n }, callAt - this._now.ticks),\n dispose: async () => {\n realTimeTimer.cancel();\n await realTimeTimer.promise;\n }\n };\n this._currentRealTimeTimer = realTimeTimer;\n }\n async _runWithDisabledRealTimeSync(fn) {\n if (!this._realTime) {\n await fn();\n return;\n }\n await this._innerPause();\n try {\n await fn();\n } finally {\n this._innerResume();\n }\n }\n async fastForward(ticks) {\n this._replayLogOnce();\n await this._runWithDisabledRealTimeSync(async () => {\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, ticks | 0));\n });\n }\n async _innerFastForwardTo(to) {\n if (to < this._now.ticks)\n throw new Error("Cannot fast-forward to the past");\n for (const timer of this._timers.values()) {\n if (to > timer.callAt)\n timer.callAt = to;\n }\n await this._runTo(to);\n }\n addTimer(options) {\n this._replayLogOnce();\n if (options.type === "AnimationFrame" /* AnimationFrame */ && !options.func)\n throw new Error("Callback must be provided to requestAnimationFrame calls");\n if (options.type === "IdleCallback" /* IdleCallback */ && !options.func)\n throw new Error("Callback must be provided to requestIdleCallback calls");\n if (["Timeout" /* Timeout */, "Interval" /* Interval */].includes(options.type) && !options.func && options.delay === void 0)\n throw new Error("Callback must be provided to timer calls");\n let delay = options.delay ? +options.delay : 0;\n if (!Number.isFinite(delay))\n delay = 0;\n delay = delay > maxTimeout ? 1 : delay;\n delay = Math.max(0, delay);\n const timer = {\n type: options.type,\n func: options.func,\n args: options.args || [],\n delay,\n callAt: shiftTicks(this._now.ticks, delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now.ticks,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n if (this._realTime)\n this._updateRealTimeTimer();\n return timer.id;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer(beforeTick) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = beforeTick === void 0 || timer.callAt <= beforeTick;\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n _takeFirstTimer(beforeTick) {\n const timer = this._firstTimer(beforeTick);\n if (!timer)\n return null;\n this._advanceNow(timer.callAt);\n if (timer.type === "Interval" /* Interval */)\n timer.callAt = shiftTicks(timer.callAt, timer.delay);\n else\n this._timers.delete(timer.id);\n return timer;\n }\n async _callFirstTimer(beforeTick) {\n const timer = this._takeFirstTimer(beforeTick);\n if (!timer)\n return { timerFound: false };\n this._duringTick = true;\n try {\n if (typeof timer.func !== "function") {\n let error2;\n try {\n (() => {\n globalThis.eval(timer.func);\n })();\n } catch (e) {\n error2 = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error: error2 };\n }\n let args = timer.args;\n if (timer.type === "AnimationFrame" /* AnimationFrame */)\n args = [this._now.ticks];\n else if (timer.type === "IdleCallback" /* IdleCallback */)\n args = [{ didTimeout: false, timeRemaining: () => 0 }];\n let error;\n try {\n timer.func.apply(null, args);\n } catch (e) {\n error = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error };\n } finally {\n this._duringTick = false;\n }\n }\n getTimeToNextFrame() {\n this._replayLogOnce();\n return 16 - this._now.ticks % 16;\n }\n clearTimer(timerId, type) {\n this._replayLogOnce();\n if (!timerId) {\n return;\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(type);\n new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);\n }\n const timer = this._timers.get(id);\n if (timer) {\n if (timer.type === type || timer.type === "Timeout" && type === "Interval" || timer.type === "Interval" && type === "Timeout") {\n this._timers.delete(id);\n } else {\n const clear = getClearHandler(type);\n const schedule = getScheduleHandler(timer.type);\n throw new Error(\n `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`\n );\n }\n }\n }\n _replayLogOnce() {\n if (!this._log.length)\n return;\n let lastLogTime = -1;\n let isPaused = false;\n for (const { type, time, param } of this._log) {\n if (!isPaused && lastLogTime !== -1)\n this._advanceNow(shiftTicks(this._now.ticks, time - lastLogTime));\n lastLogTime = time;\n if (type === "install") {\n this._innerSetTime(asWallTime(param));\n } else if (type === "fastForward" || type === "runFor") {\n this._advanceNow(shiftTicks(this._now.ticks, param));\n } else if (type === "pauseAt") {\n isPaused = true;\n this._innerSetTime(asWallTime(param));\n } else if (type === "resume") {\n isPaused = false;\n } else if (type === "setFixedTime") {\n this._innerSetFixedTime(asWallTime(param));\n } else if (type === "setSystemTime") {\n this._innerSetTime(asWallTime(param));\n }\n }\n if (!isPaused) {\n if (lastLogTime > 0)\n this._advanceNow(shiftTicks(this._now.ticks, this._embedder.dateNow() - lastLogTime));\n this._innerResume();\n } else {\n this._realTime = void 0;\n }\n this._log.length = 0;\n }\n};\nfunction mirrorDateProperties(target, source) {\n for (const prop in source) {\n if (source.hasOwnProperty(prop))\n target[prop] = source[prop];\n }\n target.toString = () => source.toString();\n target.prototype = source.prototype;\n target.parse = source.parse;\n target.UTC = source.UTC;\n target.prototype.toUTCString = source.prototype.toUTCString;\n target.isFake = true;\n return target;\n}\nfunction createDate(clock, NativeDate) {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate))\n return new NativeDate(clock.now()).toString();\n switch (arguments.length) {\n case 0:\n return new NativeDate(clock.now());\n case 1:\n return new NativeDate(year);\n case 2:\n return new NativeDate(year, month);\n case 3:\n return new NativeDate(year, month, date);\n case 4:\n return new NativeDate(year, month, date, hour);\n case 5:\n return new NativeDate(year, month, date, hour, minute);\n case 6:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second\n );\n default:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second,\n ms\n );\n }\n }\n ClockDate.now = () => clock.now();\n return mirrorDateProperties(ClockDate, NativeDate);\n}\nfunction createIntl(clock, NativeIntl) {\n const ClockIntl = {};\n for (const key of Object.getOwnPropertyNames(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args);\n const formatter = {\n formatRange: realFormatter.formatRange.bind(realFormatter),\n formatRangeToParts: realFormatter.formatRangeToParts.bind(realFormatter),\n resolvedOptions: realFormatter.resolvedOptions.bind(realFormatter),\n format: (date) => realFormatter.format(date || clock.now()),\n formatToParts: (date) => realFormatter.formatToParts(date || clock.now())\n };\n return formatter;\n };\n ClockIntl.DateTimeFormat.prototype = Object.create(\n NativeIntl.DateTimeFormat.prototype\n );\n ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;\n return ClockIntl;\n}\nfunction compareTimers(a, b) {\n if (a.callAt < b.callAt)\n return -1;\n if (a.callAt > b.callAt)\n return 1;\n if (a.type === "Immediate" /* Immediate */ && b.type !== "Immediate" /* Immediate */)\n return -1;\n if (a.type !== "Immediate" /* Immediate */ && b.type === "Immediate" /* Immediate */)\n return 1;\n if (a.createdAt < b.createdAt)\n return -1;\n if (a.createdAt > b.createdAt)\n return 1;\n if (a.id < b.id)\n return -1;\n if (a.id > b.id)\n return 1;\n}\nvar maxTimeout = Math.pow(2, 31) - 1;\nvar idCounterStart = 1e12;\nfunction platformOriginals(globalObject) {\n const raw = {\n setTimeout: globalObject.setTimeout,\n clearTimeout: globalObject.clearTimeout,\n setInterval: globalObject.setInterval,\n clearInterval: globalObject.clearInterval,\n requestAnimationFrame: globalObject.requestAnimationFrame ? globalObject.requestAnimationFrame : void 0,\n cancelAnimationFrame: globalObject.cancelAnimationFrame ? globalObject.cancelAnimationFrame : void 0,\n requestIdleCallback: globalObject.requestIdleCallback ? globalObject.requestIdleCallback : void 0,\n cancelIdleCallback: globalObject.cancelIdleCallback ? globalObject.cancelIdleCallback : void 0,\n Date: globalObject.Date,\n performance: globalObject.performance,\n Intl: globalObject.Intl\n };\n const bound = { ...raw };\n for (const key of Object.keys(bound)) {\n if (key !== "Date" && typeof bound[key] === "function")\n bound[key] = bound[key].bind(globalObject);\n }\n return { raw, bound };\n}\nfunction getScheduleHandler(type) {\n if (type === "IdleCallback" || type === "AnimationFrame")\n return `request${type}`;\n return `set${type}`;\n}\nfunction createApi(clock, originals) {\n return {\n setTimeout: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: "Timeout" /* Timeout */,\n func,\n args,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, "Timeout" /* Timeout */);\n },\n setInterval: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: "Interval" /* Interval */,\n func,\n args,\n delay\n });\n },\n clearInterval: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, "Interval" /* Interval */);\n },\n requestAnimationFrame: (callback) => {\n return clock.addTimer({\n type: "AnimationFrame" /* AnimationFrame */,\n func: callback,\n delay: clock.getTimeToNextFrame()\n });\n },\n cancelAnimationFrame: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, "AnimationFrame" /* AnimationFrame */);\n },\n requestIdleCallback: (callback, options) => {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0)\n timeToNextIdlePeriod = 50;\n return clock.addTimer({\n type: "IdleCallback" /* IdleCallback */,\n func: callback,\n delay: (options == null ? void 0 : options.timeout) ? Math.min(options == null ? void 0 : options.timeout, timeToNextIdlePeriod) : timeToNextIdlePeriod\n });\n },\n cancelIdleCallback: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, "IdleCallback" /* IdleCallback */);\n },\n Intl: originals.Intl ? createIntl(clock, originals.Intl) : void 0,\n Date: createDate(clock, originals.Date),\n performance: originals.performance ? fakePerformance(clock, originals.performance) : void 0\n };\n}\nfunction getClearHandler(type) {\n if (type === "IdleCallback" || type === "AnimationFrame")\n return `cancel${type}`;\n return `clear${type}`;\n}\nfunction fakePerformance(clock, performance) {\n const result = {\n now: () => clock.performanceNow()\n };\n result.__defineGetter__("timeOrigin", () => clock._now.origin || 0);\n for (const key of Object.keys(performance.__proto__)) {\n if (key === "now" || key === "timeOrigin")\n continue;\n if (key === "getEntries" || key === "getEntriesByName" || key === "getEntriesByType")\n result[key] = () => [];\n else\n result[key] = () => {\n };\n }\n return result;\n}\nfunction createClock(globalObject) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n dateNow: () => originals.raw.Date.now(),\n performanceNow: () => Math.ceil(originals.raw.performance.now()),\n setTimeout: (task, timeout) => {\n const timerId = originals.bound.setTimeout(task, timeout);\n return () => originals.bound.clearTimeout(timerId);\n },\n setInterval: (task, delay) => {\n const intervalId = originals.bound.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder);\n const api = createApi(clock, originals.bound);\n return { clock, api, originals: originals.raw };\n}\nfunction install(globalObject, config = {}) {\n var _a, _b;\n if ((_a = globalObject.Date) == null ? void 0 : _a.isFake) {\n throw new TypeError(`Can\'t install fake timers twice on the same global object.`);\n }\n const { clock, api, originals } = createClock(globalObject);\n const toFake = ((_b = config.toFake) == null ? void 0 : _b.length) ? config.toFake : Object.keys(originals);\n for (const method of toFake) {\n if (method === "Date") {\n globalObject.Date = mirrorDateProperties(api.Date, globalObject.Date);\n } else if (method === "Intl") {\n globalObject.Intl = api[method];\n } else if (method === "performance") {\n globalObject.performance = api[method];\n const kEventTimeStamp = Symbol("playwrightEventTimeStamp");\n Object.defineProperty(Event.prototype, "timeStamp", {\n get() {\n var _a2;\n if (!this[kEventTimeStamp])\n this[kEventTimeStamp] = (_a2 = api.performance) == null ? void 0 : _a2.now();\n return this[kEventTimeStamp];\n }\n });\n } else {\n globalObject[method] = (...args) => {\n return api[method].apply(api, args);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n const builtins = platformOriginals(globalObject).bound;\n const { clock: controller } = install(globalObject);\n controller.resume();\n return {\n controller,\n builtins\n };\n}\nfunction asWallTime(n) {\n return n;\n}\nfunction shiftTicks(ticks, ms) {\n return ticks + ms;\n}\n';
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
source
|
|
@@ -379,6 +379,8 @@ ${params.stackTrace?.callFrames.map((f) => {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
async setBackgroundColor(color) {
|
|
382
|
+
if (color)
|
|
383
|
+
throw new Error("Not implemented");
|
|
382
384
|
}
|
|
383
385
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
384
386
|
const rect = documentRect || viewportRect;
|
|
@@ -41,7 +41,7 @@ class CRServiceWorker extends import_page.Worker {
|
|
|
41
41
|
super(browserContext, url);
|
|
42
42
|
this._session = session;
|
|
43
43
|
this.browserContext = browserContext;
|
|
44
|
-
if (
|
|
44
|
+
if (!process.env.PLAYWRIGHT_DISABLE_SERVICE_WORKER_NETWORK)
|
|
45
45
|
this._networkManager = new import_crNetworkManager.CRNetworkManager(null, this);
|
|
46
46
|
session.once("Runtime.executionContextCreated", (event) => {
|
|
47
47
|
this.createExecutionContext(new import_crExecutionContext.CRExecutionContext(session, event.context));
|
package/lib/server/frames.js
CHANGED
|
@@ -1200,10 +1200,12 @@ class Frame extends import_instrumentation.SdkObject {
|
|
|
1200
1200
|
if (log)
|
|
1201
1201
|
progress.log(log);
|
|
1202
1202
|
if (matches === options.isNot) {
|
|
1203
|
-
if (missingReceived)
|
|
1203
|
+
if (missingReceived) {
|
|
1204
1204
|
lastIntermediateResult.errorMessage = "Error: element(s) not found";
|
|
1205
|
-
else
|
|
1205
|
+
} else {
|
|
1206
|
+
lastIntermediateResult.errorMessage = void 0;
|
|
1206
1207
|
lastIntermediateResult.received = received;
|
|
1208
|
+
}
|
|
1207
1209
|
lastIntermediateResult.isSet = true;
|
|
1208
1210
|
if (!missingReceived && !Array.isArray(received))
|
|
1209
1211
|
progress.log(` unexpected value "${renderUnexpectedValue(options.expression, received)}"`);
|
|
@@ -41,6 +41,7 @@ function browserDirectoryToMarkerFilePath(browserDirectory) {
|
|
|
41
41
|
function downloadFile(options) {
|
|
42
42
|
let downloadedBytes = 0;
|
|
43
43
|
let totalBytes = 0;
|
|
44
|
+
let chunked = false;
|
|
44
45
|
const promise = new import_manualPromise.ManualPromise();
|
|
45
46
|
(0, import_network.httpRequest)({
|
|
46
47
|
url: options.url,
|
|
@@ -60,11 +61,13 @@ function downloadFile(options) {
|
|
|
60
61
|
response.on("data", (chunk) => content += chunk).on("end", handleError).on("error", handleError);
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
64
|
+
chunked = response.headers["transfer-encoding"] === "chunked";
|
|
65
|
+
log(`-- is chunked: ${chunked}`);
|
|
63
66
|
totalBytes = parseInt(response.headers["content-length"] || "0", 10);
|
|
64
67
|
log(`-- total bytes: ${totalBytes}`);
|
|
65
68
|
const file = import_fs.default.createWriteStream(options.zipPath);
|
|
66
69
|
file.on("finish", () => {
|
|
67
|
-
if (downloadedBytes !== totalBytes) {
|
|
70
|
+
if (!chunked && downloadedBytes !== totalBytes) {
|
|
68
71
|
log(`-- download failed, size mismatch: ${downloadedBytes} != ${totalBytes}`);
|
|
69
72
|
promise.reject(new Error(`Download failed: size mismatch, file size: ${downloadedBytes}, expected size: ${totalBytes} URL: ${options.url}`));
|
|
70
73
|
} else {
|
|
@@ -89,7 +92,8 @@ function downloadFile(options) {
|
|
|
89
92
|
return promise;
|
|
90
93
|
function onData(chunk) {
|
|
91
94
|
downloadedBytes += chunk.length;
|
|
92
|
-
|
|
95
|
+
if (!chunked)
|
|
96
|
+
progress(downloadedBytes, totalBytes);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
async function main(options) {
|
|
@@ -37,6 +37,7 @@ var import_pixelmatch = __toESM(require("../../third_party/pixelmatch"));
|
|
|
37
37
|
var import_utilsBundle = require("../../utilsBundle");
|
|
38
38
|
var import_utilsBundle2 = require("../../utilsBundle");
|
|
39
39
|
var import_utilsBundle3 = require("../../utilsBundle");
|
|
40
|
+
var import_imageUtils = require("./imageUtils");
|
|
40
41
|
function getComparator(mimeType) {
|
|
41
42
|
if (mimeType === "image/png")
|
|
42
43
|
return compareImages.bind(null, "image/png");
|
|
@@ -66,8 +67,8 @@ function compareImages(mimeType, actualBuffer, expectedBuffer, options = {}) {
|
|
|
66
67
|
let sizesMismatchError = "";
|
|
67
68
|
if (expected.width !== actual.width || expected.height !== actual.height) {
|
|
68
69
|
sizesMismatchError = `Expected an image ${expected.width}px by ${expected.height}px, received ${actual.width}px by ${actual.height}px. `;
|
|
69
|
-
actual =
|
|
70
|
-
expected =
|
|
70
|
+
actual = (0, import_imageUtils.padImageToSize)(actual, size);
|
|
71
|
+
expected = (0, import_imageUtils.padImageToSize)(expected, size);
|
|
71
72
|
}
|
|
72
73
|
const diff2 = new import_utilsBundle3.PNG({ width: size.width, height: size.height });
|
|
73
74
|
let count;
|
|
@@ -131,29 +132,6 @@ function compareText(actual, expectedBuffer) {
|
|
|
131
132
|
const errorMessage = coloredLines.join("\n");
|
|
132
133
|
return { errorMessage };
|
|
133
134
|
}
|
|
134
|
-
function resizeImage(image, size) {
|
|
135
|
-
if (image.width === size.width && image.height === size.height)
|
|
136
|
-
return image;
|
|
137
|
-
const buffer = new Uint8Array(size.width * size.height * 4);
|
|
138
|
-
for (let y = 0; y < size.height; y++) {
|
|
139
|
-
for (let x = 0; x < size.width; x++) {
|
|
140
|
-
const to = (y * size.width + x) * 4;
|
|
141
|
-
if (y < image.height && x < image.width) {
|
|
142
|
-
const from = (y * image.width + x) * 4;
|
|
143
|
-
buffer[to] = image.data[from];
|
|
144
|
-
buffer[to + 1] = image.data[from + 1];
|
|
145
|
-
buffer[to + 2] = image.data[from + 2];
|
|
146
|
-
buffer[to + 3] = image.data[from + 3];
|
|
147
|
-
} else {
|
|
148
|
-
buffer[to] = 0;
|
|
149
|
-
buffer[to + 1] = 0;
|
|
150
|
-
buffer[to + 2] = 0;
|
|
151
|
-
buffer[to + 3] = 0;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return { data: Buffer.from(buffer), width: size.width, height: size.height };
|
|
156
|
-
}
|
|
157
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
158
136
|
0 && (module.exports = {
|
|
159
137
|
compareBuffersOrStrings,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var imageUtils_exports = {};
|
|
20
|
+
__export(imageUtils_exports, {
|
|
21
|
+
padImageToSize: () => padImageToSize,
|
|
22
|
+
scaleImageToSize: () => scaleImageToSize
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(imageUtils_exports);
|
|
25
|
+
function padImageToSize(image, size) {
|
|
26
|
+
if (image.width === size.width && image.height === size.height)
|
|
27
|
+
return image;
|
|
28
|
+
const buffer = new Uint8Array(size.width * size.height * 4);
|
|
29
|
+
for (let y = 0; y < size.height; y++) {
|
|
30
|
+
for (let x = 0; x < size.width; x++) {
|
|
31
|
+
const to = (y * size.width + x) * 4;
|
|
32
|
+
if (y < image.height && x < image.width) {
|
|
33
|
+
const from = (y * image.width + x) * 4;
|
|
34
|
+
buffer[to] = image.data[from];
|
|
35
|
+
buffer[to + 1] = image.data[from + 1];
|
|
36
|
+
buffer[to + 2] = image.data[from + 2];
|
|
37
|
+
buffer[to + 3] = image.data[from + 3];
|
|
38
|
+
} else {
|
|
39
|
+
buffer[to] = 0;
|
|
40
|
+
buffer[to + 1] = 0;
|
|
41
|
+
buffer[to + 2] = 0;
|
|
42
|
+
buffer[to + 3] = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { data: Buffer.from(buffer), width: size.width, height: size.height };
|
|
47
|
+
}
|
|
48
|
+
function scaleImageToSize(image, size) {
|
|
49
|
+
const { data: src, width: w1, height: h1 } = image;
|
|
50
|
+
const w2 = size.width | 0, h2 = size.height | 0;
|
|
51
|
+
if (w1 === w2 && h1 === h2)
|
|
52
|
+
return image;
|
|
53
|
+
const clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
54
|
+
const weights = (t, o) => {
|
|
55
|
+
const t2 = t * t, t3 = t2 * t;
|
|
56
|
+
o[0] = -0.5 * t + 1 * t2 - 0.5 * t3;
|
|
57
|
+
o[1] = 1 - 2.5 * t2 + 1.5 * t3;
|
|
58
|
+
o[2] = 0.5 * t + 2 * t2 - 1.5 * t3;
|
|
59
|
+
o[3] = -0.5 * t2 + 0.5 * t3;
|
|
60
|
+
};
|
|
61
|
+
const srcRowStride = w1 * 4;
|
|
62
|
+
const dstRowStride = w2 * 4;
|
|
63
|
+
const xIdx = new Int32Array(w2 * 4);
|
|
64
|
+
const xOff = new Int32Array(w2 * 4);
|
|
65
|
+
const xW = new Float32Array(w2 * 4);
|
|
66
|
+
const wx = new Float32Array(4);
|
|
67
|
+
const xScale = w1 / w2;
|
|
68
|
+
for (let x = 0; x < w2; x++) {
|
|
69
|
+
const sx = (x + 0.5) * xScale - 0.5;
|
|
70
|
+
const sxi = Math.floor(sx);
|
|
71
|
+
const t = sx - sxi;
|
|
72
|
+
weights(t, wx);
|
|
73
|
+
const b = x * 4;
|
|
74
|
+
const i0 = clamp(sxi - 1, 0, w1 - 1);
|
|
75
|
+
const i1 = clamp(sxi + 0, 0, w1 - 1);
|
|
76
|
+
const i2 = clamp(sxi + 1, 0, w1 - 1);
|
|
77
|
+
const i3 = clamp(sxi + 2, 0, w1 - 1);
|
|
78
|
+
xIdx[b + 0] = i0;
|
|
79
|
+
xIdx[b + 1] = i1;
|
|
80
|
+
xIdx[b + 2] = i2;
|
|
81
|
+
xIdx[b + 3] = i3;
|
|
82
|
+
xOff[b + 0] = i0 << 2;
|
|
83
|
+
xOff[b + 1] = i1 << 2;
|
|
84
|
+
xOff[b + 2] = i2 << 2;
|
|
85
|
+
xOff[b + 3] = i3 << 2;
|
|
86
|
+
xW[b + 0] = wx[0];
|
|
87
|
+
xW[b + 1] = wx[1];
|
|
88
|
+
xW[b + 2] = wx[2];
|
|
89
|
+
xW[b + 3] = wx[3];
|
|
90
|
+
}
|
|
91
|
+
const yIdx = new Int32Array(h2 * 4);
|
|
92
|
+
const yRow = new Int32Array(h2 * 4);
|
|
93
|
+
const yW = new Float32Array(h2 * 4);
|
|
94
|
+
const wy = new Float32Array(4);
|
|
95
|
+
const yScale = h1 / h2;
|
|
96
|
+
for (let y = 0; y < h2; y++) {
|
|
97
|
+
const sy = (y + 0.5) * yScale - 0.5;
|
|
98
|
+
const syi = Math.floor(sy);
|
|
99
|
+
const t = sy - syi;
|
|
100
|
+
weights(t, wy);
|
|
101
|
+
const b = y * 4;
|
|
102
|
+
const j0 = clamp(syi - 1, 0, h1 - 1);
|
|
103
|
+
const j1 = clamp(syi + 0, 0, h1 - 1);
|
|
104
|
+
const j2 = clamp(syi + 1, 0, h1 - 1);
|
|
105
|
+
const j3 = clamp(syi + 2, 0, h1 - 1);
|
|
106
|
+
yIdx[b + 0] = j0;
|
|
107
|
+
yIdx[b + 1] = j1;
|
|
108
|
+
yIdx[b + 2] = j2;
|
|
109
|
+
yIdx[b + 3] = j3;
|
|
110
|
+
yRow[b + 0] = j0 * srcRowStride;
|
|
111
|
+
yRow[b + 1] = j1 * srcRowStride;
|
|
112
|
+
yRow[b + 2] = j2 * srcRowStride;
|
|
113
|
+
yRow[b + 3] = j3 * srcRowStride;
|
|
114
|
+
yW[b + 0] = wy[0];
|
|
115
|
+
yW[b + 1] = wy[1];
|
|
116
|
+
yW[b + 2] = wy[2];
|
|
117
|
+
yW[b + 3] = wy[3];
|
|
118
|
+
}
|
|
119
|
+
const dst = new Uint8Array(w2 * h2 * 4);
|
|
120
|
+
for (let y = 0; y < h2; y++) {
|
|
121
|
+
const yb = y * 4;
|
|
122
|
+
const rb0 = yRow[yb + 0], rb1 = yRow[yb + 1], rb2 = yRow[yb + 2], rb3 = yRow[yb + 3];
|
|
123
|
+
const wy0 = yW[yb + 0], wy1 = yW[yb + 1], wy2 = yW[yb + 2], wy3 = yW[yb + 3];
|
|
124
|
+
const dstBase = y * dstRowStride;
|
|
125
|
+
for (let x = 0; x < w2; x++) {
|
|
126
|
+
const xb = x * 4;
|
|
127
|
+
const xo0 = xOff[xb + 0], xo1 = xOff[xb + 1], xo2 = xOff[xb + 2], xo3 = xOff[xb + 3];
|
|
128
|
+
const wx0 = xW[xb + 0], wx1 = xW[xb + 1], wx2 = xW[xb + 2], wx3 = xW[xb + 3];
|
|
129
|
+
const di = dstBase + (x << 2);
|
|
130
|
+
for (let c = 0; c < 4; c++) {
|
|
131
|
+
const r0 = src[rb0 + xo0 + c] * wx0 + src[rb0 + xo1 + c] * wx1 + src[rb0 + xo2 + c] * wx2 + src[rb0 + xo3 + c] * wx3;
|
|
132
|
+
const r1 = src[rb1 + xo0 + c] * wx0 + src[rb1 + xo1 + c] * wx1 + src[rb1 + xo2 + c] * wx2 + src[rb1 + xo3 + c] * wx3;
|
|
133
|
+
const r2 = src[rb2 + xo0 + c] * wx0 + src[rb2 + xo1 + c] * wx1 + src[rb2 + xo2 + c] * wx2 + src[rb2 + xo3 + c] * wx3;
|
|
134
|
+
const r3 = src[rb3 + xo0 + c] * wx0 + src[rb3 + xo1 + c] * wx1 + src[rb3 + xo2 + c] * wx2 + src[rb3 + xo3 + c] * wx3;
|
|
135
|
+
const v = r0 * wy0 + r1 * wy1 + r2 * wy2 + r3 * wy3;
|
|
136
|
+
dst[di + c] = v < 0 ? 0 : v > 255 ? 255 : v | 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { data: Buffer.from(dst), width: w2, height: h2 };
|
|
141
|
+
}
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
padImageToSize,
|
|
145
|
+
scaleImageToSize
|
|
146
|
+
});
|
|
@@ -25,7 +25,8 @@ __export(locatorGenerators_exports, {
|
|
|
25
25
|
PythonLocatorFactory: () => PythonLocatorFactory,
|
|
26
26
|
asLocator: () => asLocator,
|
|
27
27
|
asLocatorDescription: () => asLocatorDescription,
|
|
28
|
-
asLocators: () => asLocators
|
|
28
|
+
asLocators: () => asLocators,
|
|
29
|
+
locatorCustomDescription: () => locatorCustomDescription
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(locatorGenerators_exports);
|
|
31
32
|
var import_selectorParser = require("./selectorParser");
|
|
@@ -33,17 +34,31 @@ var import_stringUtils = require("./stringUtils");
|
|
|
33
34
|
function asLocatorDescription(lang, selector) {
|
|
34
35
|
try {
|
|
35
36
|
const parsed = (0, import_selectorParser.parseSelector)(selector);
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
if (typeof description === "string")
|
|
40
|
-
return description;
|
|
41
|
-
}
|
|
37
|
+
const customDescription = parseCustomDescription(parsed);
|
|
38
|
+
if (customDescription)
|
|
39
|
+
return customDescription;
|
|
42
40
|
return innerAsLocators(new generators[lang](), parsed, false, 1)[0];
|
|
43
41
|
} catch (e) {
|
|
44
42
|
return selector;
|
|
45
43
|
}
|
|
46
44
|
}
|
|
45
|
+
function locatorCustomDescription(selector) {
|
|
46
|
+
try {
|
|
47
|
+
const parsed = (0, import_selectorParser.parseSelector)(selector);
|
|
48
|
+
return parseCustomDescription(parsed);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function parseCustomDescription(parsed) {
|
|
54
|
+
const lastPart = parsed.parts[parsed.parts.length - 1];
|
|
55
|
+
if (lastPart?.name === "internal:describe") {
|
|
56
|
+
const description = JSON.parse(lastPart.body);
|
|
57
|
+
if (typeof description === "string")
|
|
58
|
+
return description;
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
47
62
|
function asLocator(lang, selector, isFrameLocator = false) {
|
|
48
63
|
return asLocators(lang, selector, isFrameLocator, 1)[0];
|
|
49
64
|
}
|
|
@@ -669,5 +684,6 @@ function isRegExp(obj) {
|
|
|
669
684
|
PythonLocatorFactory,
|
|
670
685
|
asLocator,
|
|
671
686
|
asLocatorDescription,
|
|
672
|
-
asLocators
|
|
687
|
+
asLocators,
|
|
688
|
+
locatorCustomDescription
|
|
673
689
|
});
|
|
@@ -123,8 +123,11 @@ function resolveGlobBase(baseURL, match) {
|
|
|
123
123
|
const relativePath = match.split("/").map((token, index) => {
|
|
124
124
|
if (token === "." || token === ".." || token === "")
|
|
125
125
|
return token;
|
|
126
|
-
if (index === 0 && token.endsWith(":"))
|
|
127
|
-
|
|
126
|
+
if (index === 0 && token.endsWith(":")) {
|
|
127
|
+
if (token.indexOf("*") !== -1 || token.indexOf("{") !== -1)
|
|
128
|
+
return mapToken2(token, "http:");
|
|
129
|
+
return token;
|
|
130
|
+
}
|
|
128
131
|
const questionIndex = token.indexOf("?");
|
|
129
132
|
if (questionIndex === -1)
|
|
130
133
|
return mapToken2(token, `$_${index}_$`);
|
package/lib/utils.js
CHANGED
|
@@ -50,6 +50,7 @@ __reExport(utils_exports, require("./server/utils/expectUtils"), module.exports)
|
|
|
50
50
|
__reExport(utils_exports, require("./server/utils/fileUtils"), module.exports);
|
|
51
51
|
__reExport(utils_exports, require("./server/utils/hostPlatform"), module.exports);
|
|
52
52
|
__reExport(utils_exports, require("./server/utils/httpServer"), module.exports);
|
|
53
|
+
__reExport(utils_exports, require("./server/utils/imageUtils"), module.exports);
|
|
53
54
|
__reExport(utils_exports, require("./server/utils/network"), module.exports);
|
|
54
55
|
__reExport(utils_exports, require("./server/utils/nodePlatform"), module.exports);
|
|
55
56
|
__reExport(utils_exports, require("./server/utils/processLauncher"), module.exports);
|
|
@@ -93,6 +94,7 @@ var import_utilsBundle = require("./utilsBundle");
|
|
|
93
94
|
...require("./server/utils/fileUtils"),
|
|
94
95
|
...require("./server/utils/hostPlatform"),
|
|
95
96
|
...require("./server/utils/httpServer"),
|
|
97
|
+
...require("./server/utils/imageUtils"),
|
|
96
98
|
...require("./server/utils/network"),
|
|
97
99
|
...require("./server/utils/nodePlatform"),
|
|
98
100
|
...require("./server/utils/processLauncher"),
|