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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC1pbmZvLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3Byb3h5bGVzcy9yZXF1ZXN0LXBpcGVsaW5lL2NvbnRleHQtaW5mby50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUNBLHlGQUF5RTtBQUN6RSwySEFBNEc7QUFLNUcsc0NBQWtFO0FBRWxFLDZIQUE4RztBQU85RyxNQUFxQiwyQkFBMkI7SUFLNUMsWUFBb0IsYUFBNEI7UUFDNUMsSUFBSSxDQUFDLGlCQUFpQixHQUFHLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsZUFBZSxHQUFLLEVBQUUsQ0FBQztRQUM1QixJQUFJLENBQUMsY0FBYyxHQUFNLGFBQWEsQ0FBQztJQUMzQyxDQUFDO0lBRU8sc0JBQXNCLENBQUUsU0FBaUI7UUFDN0MsTUFBTSxlQUFlLEdBQUcsSUFBSSwwQkFBd0IsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUVoRSxJQUFJLENBQUMsaUJBQWlCLENBQUMsU0FBUyxDQUFDLEdBQUcsZUFBZSxDQUFDO1FBRXBELE9BQU8sZUFBZSxDQUFDO0lBQzNCLENBQUM7SUFFTyxtQkFBbUIsQ0FBRSxLQUErQztRQUN4RSxNQUFNLFNBQVMsR0FBTSxJQUFJLENBQUMsY0FBYyxDQUFDLFlBQVksRUFBRSxDQUFDO1FBQ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