Socket
Socket
Sign inDemoInstall

playwright-core

Package Overview
Dependencies
0
Maintainers
4
Versions
4384
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.45.0-alpha-2024-05-22 to 1.45.0-alpha-2024-05-23

lib/vite/recorder/assets/codeMirrorModule-D7ReU7TF.js

3

lib/client/browserContext.js

@@ -441,2 +441,5 @@ "use strict";

await this._wrapApiCall(async () => {
await this.request.dispose(options);
}, true);
await this._wrapApiCall(async () => {
var _this$_browserType2;

@@ -443,0 +446,0 @@ await ((_this$_browserType2 = this._browserType) === null || _this$_browserType2 === void 0 ? void 0 : _this$_browserType2._willCloseContext(this));

9

lib/client/fetch.js

@@ -85,3 +85,8 @@ "use strict";

await this._instrumentation.onWillCloseRequestContext(this);
await this._channel.dispose(options);
try {
await this._channel.dispose(options);
} catch (e) {
if ((0, _errors.isTargetClosedError)(e)) return;
throw e;
}
this._tracing._resetStackCounter();

@@ -138,3 +143,3 @@ (_this$_request = this._request) === null || _this$_request === void 0 || _this$_request._contexts.delete(this);

var _options$request, _options$request2, _options$request3;
if (this._closeReason) throw new Error(this._closeReason);
if (this._closeReason) throw new _errors.TargetClosedError(this._closeReason);
(0, _utils.assert)(options.request || typeof options.url === 'string', 'First argument must be either URL string or Request');

@@ -141,0 +146,0 @@ (0, _utils.assert)((options.data === undefined ? 0 : 1) + (options.form === undefined ? 0 : 1) + (options.multipart === undefined ? 0 : 1) <= 1, `Only one of 'data', 'form' or 'multipart' can be specified`);

@@ -21,2 +21,3 @@ "use strict";

var _fetch = require("./fetch");
var _errors = require("./errors");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -536,2 +537,7 @@ /**

if (this._ignoreException) return false;
if ((0, _errors.isTargetClosedError)(e)) {
// We are failing in the handler because the target close closed.
// Give user a hint!
(0, _utils.rewriteErrorMessage)(e, `"${e.message}" while running route callback.\nConsider awaiting \`await page.unrouteAll({ behavior: 'ignoreErrors' })\`\nbefore the end of the test to ignore remaining routes in flight.`);
}
throw e;

@@ -538,0 +544,0 @@ } finally {

@@ -12,6 +12,3 @@ "use strict";

var _debug = require("../../../protocol/debug");
var _manualPromise = require("../../../utils/manualPromise");
var _eventsHelper = require("../../../utils/eventsHelper");
var _utils = require("../../../utils");
var _fileUtils = require("../../../utils/fileUtils");
var _artifact = require("../../artifact");

@@ -23,3 +20,2 @@ var _browserContext = require("../../browserContext");

var _snapshotter = require("./snapshotter");
var _zipBundle = require("../../../zipBundle");
var _dispatcher = require("../../dispatchers/dispatcher");

@@ -53,3 +49,3 @@ var _errors = require("../../errors");

super(context, 'tracing');
this._fs = new SerializedFS();
this._fs = new _utils.SerializedFS();
this._snapshotter = void 0;

@@ -158,3 +154,3 @@ this._harTracer = void 0;

this._context.instrumentation.addListener(this, this._context);
this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(this._context, _browserContext.BrowserContext.Events.Console, this._onConsoleMessage.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._context, _browserContext.BrowserContext.Events.PageError, this._onPageError.bind(this)));
this._eventListeners.push(_utils.eventsHelper.addEventListener(this._context, _browserContext.BrowserContext.Events.Console, this._onConsoleMessage.bind(this)), _utils.eventsHelper.addEventListener(this._context, _browserContext.BrowserContext.Events.PageError, this._onPageError.bind(this)));
if (this._state.options.screenshots) this._startScreencast();

@@ -169,6 +165,6 @@ if (this._state.options.snapshots) await ((_this$_snapshotter2 = this._snapshotter) === null || _this$_snapshotter2 === void 0 ? void 0 : _this$_snapshotter2.start());

for (const page of this._context.pages()) this._startScreencastInPage(page);
this._screencastListeners.push(_eventsHelper.eventsHelper.addEventListener(this._context, _browserContext.BrowserContext.Events.Page, this._startScreencastInPage.bind(this)));
this._screencastListeners.push(_utils.eventsHelper.addEventListener(this._context, _browserContext.BrowserContext.Events.Page, this._startScreencastInPage.bind(this)));
}
_stopScreencast() {
_eventsHelper.eventsHelper.removeEventListeners(this._screencastListeners);
_utils.eventsHelper.removeEventListeners(this._screencastListeners);
if (!(this._context instanceof _browserContext.BrowserContext)) return;

@@ -202,3 +198,3 @@ for (const page of this._context.pages()) page.setScreencastOptions(null);

async deleteTmpTracesDir() {
if (this._tracesTmpDir) await (0, _fileUtils.removeFolders)([this._tracesTmpDir]);
if (this._tracesTmpDir) await (0, _utils.removeFolders)([this._tracesTmpDir]);
}

@@ -229,3 +225,3 @@ _createTracesDirIfNeeded() {

this._context.instrumentation.removeListener(this);
_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
_utils.eventsHelper.removeEventListeners(this._eventListeners);
if (this._state.options.screenshots) this._stopScreencast();

@@ -404,3 +400,3 @@ if (this._state.options.snapshots) await ((_this$_snapshotter4 = this._snapshotter) === null || _this$_snapshotter4 === void 0 ? void 0 : _this$_snapshotter4.stop());

const prefix = page.guid;
this._screencastListeners.push(_eventsHelper.eventsHelper.addEventListener(page, _page.Page.Events.ScreencastFrame, params => {
this._screencastListeners.push(_utils.eventsHelper.addEventListener(page, _page.Page.Events.ScreencastFrame, params => {
const suffix = params.timestamp || Date.now();

@@ -498,76 +494,2 @@ const sha1 = `${prefix}-${suffix}.jpeg`;

};
}
class SerializedFS {
constructor() {
this._writeChain = Promise.resolve();
this._buffers = new Map();
// Should never be accessed from within appendOperation.
this._error = void 0;
}
mkdir(dir) {
this._appendOperation(() => _fs.default.promises.mkdir(dir, {
recursive: true
}));
}
writeFile(file, content, skipIfExists) {
this._buffers.delete(file); // No need to flush the buffer since we'll overwrite anyway.
// Note: 'wx' flag only writes when the file does not exist.
// See https://nodejs.org/api/fs.html#file-system-flags.
// This way tracing never have to write the same resource twice.
this._appendOperation(async () => {
if (skipIfExists) await _fs.default.promises.writeFile(file, content, {
flag: 'wx'
}).catch(() => {});else await _fs.default.promises.writeFile(file, content);
});
}
appendFile(file, text, flush) {
if (!this._buffers.has(file)) this._buffers.set(file, []);
this._buffers.get(file).push(text);
if (flush) this._flushFile(file);
}
_flushFile(file) {
const buffer = this._buffers.get(file);
if (buffer === undefined) return;
const text = buffer.join('');
this._buffers.delete(file);
this._appendOperation(() => _fs.default.promises.appendFile(file, text));
}
copyFile(from, to) {
this._flushFile(from);
this._buffers.delete(to); // No need to flush the buffer since we'll overwrite anyway.
this._appendOperation(() => _fs.default.promises.copyFile(from, to));
}
async syncAndGetError() {
for (const file of this._buffers.keys()) this._flushFile(file);
await this._writeChain;
return this._error;
}
zip(entries, zipFileName) {
for (const file of this._buffers.keys()) this._flushFile(file);
// Chain the export operation against write operations,
// so that files do not change during the export.
this._appendOperation(async () => {
const zipFile = new _zipBundle.yazl.ZipFile();
const result = new _manualPromise.ManualPromise();
zipFile.on('error', error => result.reject(error));
for (const entry of entries) zipFile.addFile(entry.value, entry.name);
zipFile.end();
zipFile.outputStream.pipe(_fs.default.createWriteStream(zipFileName)).on('close', () => result.resolve()).on('error', error => result.reject(error));
await result;
});
}
_appendOperation(cb) {
// This method serializes all writes to the trace.
this._writeChain = this._writeChain.then(async () => {
// Ignore all operations after the first error.
if (this._error) return;
try {
await cb();
} catch (e) {
this._error = e;
}
});
}
}

@@ -6,2 +6,3 @@ "use strict";

});
exports.SerializedFS = void 0;
exports.canAccessFile = canAccessFile;

@@ -16,2 +17,4 @@ exports.copyFileAndMakeWritable = copyFileAndMakeWritable;

var _path = _interopRequireDefault(require("path"));
var _manualPromise = require("./manualPromise");
var _zipBundle = require("../zipBundle");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -68,2 +71,138 @@ /**

return aPath.split(_path.default.sep).join(_path.default.posix.sep);
}
}
class SerializedFS {
constructor() {
this._buffers = new Map();
// Should never be accessed from within appendOperation.
this._error = void 0;
this._operations = [];
this._operationsDone = void 0;
this._operationsDone = new _manualPromise.ManualPromise();
this._operationsDone.resolve(); // No operations scheduled yet.
}
mkdir(dir) {
this._appendOperation({
op: 'mkdir',
dir
});
}
writeFile(file, content, skipIfExists) {
this._buffers.delete(file); // No need to flush the buffer since we'll overwrite anyway.
this._appendOperation({
op: 'writeFile',
file,
content,
skipIfExists
});
}
appendFile(file, text, flush) {
if (!this._buffers.has(file)) this._buffers.set(file, []);
this._buffers.get(file).push(text);
if (flush) this._flushFile(file);
}
_flushFile(file) {
const buffer = this._buffers.get(file);
if (buffer === undefined) return;
const content = buffer.join('');
this._buffers.delete(file);
this._appendOperation({
op: 'appendFile',
file,
content
});
}
copyFile(from, to) {
this._flushFile(from);
this._buffers.delete(to); // No need to flush the buffer since we'll overwrite anyway.
this._appendOperation({
op: 'copyFile',
from,
to
});
}
async syncAndGetError() {
for (const file of this._buffers.keys()) this._flushFile(file);
await this._operationsDone;
return this._error;
}
zip(entries, zipFileName) {
for (const file of this._buffers.keys()) this._flushFile(file);
// Chain the export operation against write operations,
// so that files do not change during the export.
this._appendOperation({
op: 'zip',
entries,
zipFileName
});
}
// This method serializes all writes to the trace.
_appendOperation(op) {
const last = this._operations[this._operations.length - 1];
if ((last === null || last === void 0 ? void 0 : last.op) === 'appendFile' && op.op === 'appendFile' && last.file === op.file) {
// Merge pending appendFile operations for performance.
last.content += op.content;
return;
}
this._operations.push(op);
if (this._operationsDone.isDone()) this._performOperations();
}
async _performOperations() {
this._operationsDone = new _manualPromise.ManualPromise();
while (this._operations.length) {
const op = this._operations.shift();
// Ignore all operations after the first error.
if (this._error) continue;
try {
await this._performOperation(op);
} catch (e) {
this._error = e;
}
}
this._operationsDone.resolve();
}
async _performOperation(op) {
switch (op.op) {
case 'mkdir':
{
await _fs.default.promises.mkdir(op.dir, {
recursive: true
});
return;
}
case 'writeFile':
{
// Note: 'wx' flag only writes when the file does not exist.
// See https://nodejs.org/api/fs.html#file-system-flags.
// This way tracing never have to write the same resource twice.
if (op.skipIfExists) await _fs.default.promises.writeFile(op.file, op.content, {
flag: 'wx'
}).catch(() => {});else await _fs.default.promises.writeFile(op.file, op.content);
return;
}
case 'copyFile':
{
await _fs.default.promises.copyFile(op.from, op.to);
return;
}
case 'appendFile':
{
await _fs.default.promises.appendFile(op.file, op.content);
return;
}
case 'zip':
{
const zipFile = new _zipBundle.yazl.ZipFile();
const result = new _manualPromise.ManualPromise();
zipFile.on('error', error => result.reject(error));
for (const entry of op.entries) zipFile.addFile(entry.value, entry.name);
zipFile.end();
zipFile.outputStream.pipe(_fs.default.createWriteStream(op.zipFileName)).on('close', () => result.resolve()).on('error', error => result.reject(error));
await result;
return;
}
}
}
}
exports.SerializedFS = SerializedFS;
{
"name": "playwright-core",
"version": "1.45.0-alpha-2024-05-22",
"version": "1.45.0-alpha-2024-05-23",
"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

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc