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

53 lines
8.3 KiB
JavaScript
Raw Normal View History

"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;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