Innovenergy_trunk/frontend/node_modules/testcafe/lib/test-run/bookmark.js

133 lines
20 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 phase_1 = __importDefault(require("../test-run/phase"));
const types_1 = require("../errors/types");
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
const actions_1 = require("./commands/actions");
const test_run_1 = require("../errors/test-run");
const default_values_1 = require("../configuration/default-values");
class TestRunBookmark {
constructor(testRun, role) {
this.testRun = testRun;
this.role = role;
this.url = testcafe_hammerhead_1.SPECIAL_BLANK_PAGE;
this.ctx = null;
this.fixtureCtx = null;
this.dialogHandler = null;
this.iframeSelector = null;
this.speed = default_values_1.DEFAULT_SPEED_VALUE;
this.pageLoadTimeout = 0;
this.consoleMessages = null;
this.dialogHandler = this.testRun.activeDialogHandler;
this.iframeSelector = this.testRun.activeIframeSelector;
this.speed = this.testRun.speed;
this.pageLoadTimeout = this.testRun.pageLoadTimeout;
this.consoleMessages = this.testRun.consoleMessages;
}
async _initCtxs() {
if (this.testRun.compilerService) {
this.ctx = await this.testRun.compilerService.getCtx({ testRunId: this.testRun.id });
this.fixtureCtx = await this.testRun.compilerService.getFixtureCtx({ testRunId: this.testRun.id });
}
else {
this.ctx = this.testRun.ctx;
this.fixtureCtx = this.testRun.fixtureCtx;
}
}
async _restoreCtxs() {
if (this.testRun.compilerService) {
await this.testRun.compilerService.setCtx({
testRunId: this.testRun.id,
value: this.ctx,
});
await this.testRun.compilerService.setFixtureCtx({
testRunId: this.testRun.id,
value: this.fixtureCtx,
});
}
else {
this.testRun.ctx = this.ctx;
this.testRun.fixtureCtx = this.fixtureCtx;
}
}
async init() {
await this._initCtxs();
if (this.testRun.activeIframeSelector)
await this.testRun.executeCommand(new actions_1.SwitchToMainWindowCommand());
if (!this.role.opts.preserveUrl)
await this.role.setCurrentUrlAsRedirectUrl(this.testRun);
}
async _restoreDialogHandler() {
if (this.testRun.activeDialogHandler !== this.dialogHandler) {
const restoreDialogCommand = new actions_1.SetNativeDialogHandlerCommand({ dialogHandler: { fn: this.dialogHandler } });
await this.testRun.executeCommand(restoreDialogCommand);
}
}
async _restoreSpeed() {
if (this.testRun.speed !== this.speed) {
const restoreSpeedCommand = new actions_1.SetTestSpeedCommand({ speed: this.speed });
await this.testRun.executeCommand(restoreSpeedCommand);
}
}
async _restorePageLoadTimeout() {
if (this.testRun.pageLoadTimeout !== this.pageLoadTimeout) {
const restorePageLoadTimeoutCommand = new actions_1.SetPageLoadTimeoutCommand({ duration: this.pageLoadTimeout });
await this.testRun.executeCommand(restorePageLoadTimeoutCommand);
}
}
async _restoreWorkingFrame() {
if (this.testRun.activeIframeSelector !== this.iframeSelector) {
const switchWorkingFrameCommand = this.iframeSelector ?
new actions_1.SwitchToIframeCommand({ selector: this.iframeSelector }) :
new actions_1.SwitchToMainWindowCommand();
try {
await this.testRun.executeCommand(switchWorkingFrameCommand);
}
catch (err) {
if (err.code === types_1.TEST_RUN_ERRORS.actionElementNotFoundError)
throw new test_run_1.CurrentIframeNotFoundError();
if (err.code === types_1.TEST_RUN_ERRORS.actionIframeIsNotLoadedError)
throw new test_run_1.CurrentIframeIsNotLoadedError();
throw err;
}
}
}
async _restorePage(url, stateSnapshot) {
await this.testRun.navigateToUrl(url, true, JSON.stringify(stateSnapshot));
}
_setConsoleMessages() {
this.testRun.consoleMessages = this.consoleMessages;
}
_setPhase(value) {
this.testRun.phase = value;
}
async restore(callsite, stateSnapshot) {
const prevPhase = await this.testRun.phase;
this._setPhase(phase_1.default.inBookmarkRestore);
await this._restoreCtxs();
this._setConsoleMessages();
try {
await this._restoreSpeed();
await this._restorePageLoadTimeout();
await this._restoreDialogHandler();
const preserveUrl = this.role.opts.preserveUrl;
const redirectUrl = preserveUrl
? this.role.redirectUrl
: this.role.redirectUrl[this.testRun.test.id];
await this._restorePage(redirectUrl, stateSnapshot);
if (!preserveUrl)
await this._restoreWorkingFrame();
}
catch (err) {
err.callsite = callsite;
throw err;
}
this._setPhase(prevPhase);
}
}
exports.default = TestRunBookmark;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm9va21hcmsuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC1ydW4vYm9va21hcmsudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSw4REFBK0M7QUFDL0MsMkNBQWtEO0FBQ2xELDZEQUF3RTtBQUV4RSxnREFNNEI7QUFFNUIsaURBQStGO0FBSS9GLG9FQUFzRTtBQUt0RSxNQUFxQixlQUFlO0lBWWhDLFlBQW9CLE9BQWdCLEVBQUUsSUFBVTtRQUM1QyxJQUFJLENBQUMsT0FBTyxHQUFXLE9BQU8sQ0FBQztRQUMvQixJQUFJLENBQUMsSUFBSSxHQUFjLElBQUksQ0FBQztRQUM1QixJQUFJLENBQUMsR0FBRyxHQUFlLHdDQUFrQixDQUFDO1FBQzFDLElBQUksQ0FBQyxHQUFHLEdBQWUsSUFBSSxDQUFDO1FBQzVCLElBQUksQ0FBQyxVQUFVLEdBQVEsSUFBSSxDQUFDO1FBQzVCLElBQUksQ0FBQyxhQUFhLEdBQUssSUFBSSxDQUFDO1FBQzVCLElBQUksQ0FBQyxjQUFjLEdBQUksSUFBSSxDQUFDO1FBQzVCLElBQUksQ0FBQyxLQUFLLEdBQWEsb0NBQW1CLENBQUM7UUFDM0MsSUFBSSxDQUFDLGVBQWUsR0FBRyxDQUFDLENBQUM7UUFDekIsSUFBSSxDQUFDLGVBQWUsR0FBRyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLGFBQWEsR0FBSyxJQUFJLENBQUMsT0FBTyxDQUFDLG1CQUFtQixDQUFDO1FBQ3hELElBQUksQ0FBQyxjQUFjLEdBQUksSUFBSSxDQUFDLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQztR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