55 lines
8.9 KiB
JavaScript
55 lines
8.9 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 pipeline_context_1 = __importDefault(require("../request-hooks/pipeline-context"));
|
|
const request_paused_event_based_1 = __importDefault(require("../request-hooks/event-factory/request-paused-event-based"));
|
|
const cdp_1 = require("../utils/cdp");
|
|
const frame_navigated_event_based_1 = __importDefault(require("../request-hooks/event-factory/frame-navigated-event-based"));
|
|
class ProxylessRequestContextInfo {
|
|
constructor(testRunBridge) {
|
|
this._pipelineContexts = {};
|
|
this._eventFactories = {};
|
|
this._testRunBridge = testRunBridge;
|
|
}
|
|
_createPipelineContext(requestId) {
|
|
const pipelineContext = new pipeline_context_1.default(requestId);
|
|
this._pipelineContexts[requestId] = pipelineContext;
|
|
return pipelineContext;
|
|
}
|
|
_createEventFactory(event) {
|
|
const sessionId = this._testRunBridge.getSessionId();
|
|
const requestId = (0, cdp_1.getRequestId)(event);
|
|
const eventFactory = (0, cdp_1.isRequestPausedEvent)(event) ? new request_paused_event_based_1.default(event, sessionId) : new frame_navigated_event_based_1.default(event, sessionId);
|
|
this._eventFactories[requestId] = eventFactory;
|
|
return eventFactory;
|
|
}
|
|
_getEventFactory(requestId) {
|
|
return this._eventFactories[requestId];
|
|
}
|
|
init(event) {
|
|
const requestId = (0, cdp_1.getRequestId)(event);
|
|
const pipelineContext = this._createPipelineContext(requestId);
|
|
const eventFactory = this._createEventFactory(event);
|
|
pipelineContext.setRequestOptions(eventFactory);
|
|
}
|
|
dispose(requestId) {
|
|
if (!requestId)
|
|
return;
|
|
delete this._pipelineContexts[requestId];
|
|
delete this._eventFactories[requestId];
|
|
}
|
|
getPipelineContext(requestId) {
|
|
return this._pipelineContexts[requestId];
|
|
}
|
|
getContextData(event) {
|
|
const requestId = (0, cdp_1.getRequestId)(event);
|
|
const pipelineContext = this.getPipelineContext(requestId);
|
|
const eventFactory = this._getEventFactory(requestId);
|
|
return { pipelineContext, eventFactory };
|
|
}
|
|
}
|
|
exports.default = ProxylessRequestContextInfo;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC1pbmZvLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3Byb3h5bGVzcy9yZXF1ZXN0LXBpcGVsaW5lL2NvbnRleHQtaW5mby50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUNBLHlGQUF5RTtBQUN6RSwySEFBNEc7QUFLNUcsc0NBQWtFO0FBRWxFLDZIQUE4RztBQU85RyxNQUFxQiwyQkFBMkI7SUFLNUMsWUFBb0IsYUFBNEI7UUFDNUMsSUFBSSxDQUFDLGlCQUFpQixHQUFHLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsZUFBZSxHQUFLLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsY0FBYyxHQUFNLGFBQWEsQ0FBQztJQUMzQyxDQUFDO0lBRU8sc0JBQXNCLENBQUUsU0FBaUI7UUFDN0MsTUFBTSxlQUFlLEdBQUcsSUFBSSwwQkFBd0IsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUVoRSxJQUFJLENBQUMsaUJBQWlCLENBQUMsU0FBUyxDQUFDLEdBQUcsZUFBZSxDQUFDO1FBRXBELE9BQU8sZUFBZSxDQUFDO0lBQzNCLENBQUM7SUFFTyxtQkFBbUIsQ0FBRSxLQUErQztRQUN4RSxNQUFNLFNBQVMsR0FBTSxJQUFJLENBQUMsY0FBYyxDQUFDLFlBQVksRUFBRSxDQUFDO1FBQ3hELE1BQU0sU0FBUyxHQUFNLElBQUEsa0JBQVksRUFBQyxLQUFLLENBQUMsQ0FBQztRQUN6QyxNQUFNLFlBQVksR0FBRyxJQUFBLDBCQUFvQixFQUFDL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