45 lines
5.2 KiB
JavaScript
45 lines
5.2 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 connection_1 = __importDefault(require("../../browser/connection"));
|
|
class TestRunBridge {
|
|
constructor(browserId) {
|
|
this._browserId = browserId;
|
|
}
|
|
getBrowserConnection() {
|
|
return connection_1.default.getById(this._browserId);
|
|
}
|
|
getCurrentTestRun() {
|
|
const browserConnection = this.getBrowserConnection();
|
|
return browserConnection.getCurrentTestRun();
|
|
}
|
|
getSessionId() {
|
|
var _a;
|
|
return ((_a = this.getCurrentTestRun()) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
}
|
|
getUserScripts() {
|
|
const currentTestRun = this.getCurrentTestRun();
|
|
if (!currentTestRun)
|
|
return [];
|
|
return currentTestRun.injectable.userScripts;
|
|
}
|
|
async getTaskScript({ isIframe }) {
|
|
const browserConnection = this.getBrowserConnection();
|
|
const proxy = browserConnection.browserConnectionGateway.proxy;
|
|
const windowId = browserConnection.activeWindowId;
|
|
// @ts-ignore
|
|
return await this.getCurrentTestRun().session.getTaskScript({
|
|
referer: '',
|
|
cookieUrl: '',
|
|
withPayload: true,
|
|
serverInfo: proxy.server1Info,
|
|
windowId,
|
|
isIframe,
|
|
});
|
|
}
|
|
}
|
|
exports.default = TestRunBridge;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1ydW4tYnJpZGdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3Byb3h5bGVzcy9yZXF1ZXN0LXBpcGVsaW5lL3Rlc3QtcnVuLWJyaWRnZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUNBLDBFQUF5RDtBQUl6RCxNQUFxQixhQUFhO0l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