Innovenergy_trunk/frontend/node_modules/testcafe/lib/proxyless/index.js

53 lines
8.3 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const request_pipeline_1 = __importDefault(require("./request-pipeline"));
const add_custom_debug_formatters_1 = __importDefault(require("./add-custom-debug-formatters"));
const debug_loggers_1 = require("../utils/debug-loggers");
const session_storage_1 = __importDefault(require("./session-storage"));
const ALL_REQUEST_RESPONSES = { requestStage: 'Request' };
const ALL_REQUEST_REQUESTS = { requestStage: 'Response' };
const ALL_REQUESTS_DATA = [ALL_REQUEST_REQUESTS, ALL_REQUEST_RESPONSES];
class Proxyless {
constructor(browserId, client) {
this._client = client;
this.requestPipeline = new request_pipeline_1.default(browserId, client);
this.sessionStorage = new session_storage_1.default(browserId, client);
this.sessionStorage.on('contextStorageSync', ({ sessionStorage, testRunId, frameDriverId }) => {
if (sessionStorage) {
this.requestPipeline.contextStorage = this.requestPipeline.contextStorage || {};
this.requestPipeline.contextStorage[testRunId] = this.requestPipeline.contextStorage[testRunId] || {};
this.requestPipeline.contextStorage[testRunId][frameDriverId] = sessionStorage;
}
});
this.sessionStorage.on('contextStorageTestRunDone', ({ testRunId }) => {
if (this.requestPipeline.contextStorage)
delete this.requestPipeline.contextStorage[testRunId];
});
(0, add_custom_debug_formatters_1.default)();
}
async init(options) {
// NOTE: We are forced to handle all requests and responses at once
// because CDP API does not allow specifying request filtering behavior for different handlers.
await this._client.Fetch.enable({
patterns: ALL_REQUESTS_DATA,
});
const proxylessSystems = [
this.requestPipeline,
this.sessionStorage,
];
for (const api of proxylessSystems)
await api.init(options);
(0, debug_loggers_1.proxylessLogger)('proxyless initialized');
}
async dispose() {
this.requestPipeline.stop();
await this._client.Fetch.disable();
(0, debug_loggers_1.proxylessLogger)('proxyless disposed');
}
}
exports.default = Proxyless;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2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