Innovenergy_trunk/frontend/node_modules/testcafe/lib/test-run/role-provider.js

41 lines
5.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProxyRoleProvider = exports.ProxylessRoleProvider = void 0;
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
const cookie_provider_1 = require("../proxyless/cookie-provider");
class RoleProviderBase {
constructor(testRun) {
this._testRun = testRun;
}
get session() {
return this._testRun.session;
}
}
class ProxylessRoleProvider extends RoleProviderBase {
constructor(testRun) {
super(testRun);
this._cookieProvider = new cookie_provider_1.CdpCookieProvider(testRun);
}
async getStateSnapshot() {
const cookies = await this._cookieProvider.getCookies([]);
return new testcafe_hammerhead_1.StateSnapshot(JSON.stringify(cookies), null);
}
async useStateSnapshot(stateSnapshot) {
const { cookies } = stateSnapshot;
await this._cookieProvider.deleteCookies();
if (cookies)
await this._cookieProvider.setCookies(JSON.parse(cookies), '');
this._testRun.saveStoragesSnapshot(stateSnapshot.storages);
}
}
exports.ProxylessRoleProvider = ProxylessRoleProvider;
class ProxyRoleProvider extends RoleProviderBase {
async getStateSnapshot() {
return this.session.getStateSnapshot();
}
async useStateSnapshot(stateSnapshot) {
await this.session.useStateSnapshot(stateSnapshot);
}
}
exports.ProxyRoleProvider = ProxyRoleProvider;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sZS1wcm92aWRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0LXJ1bi9yb2xlLXByb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDZEQUFvRDtBQUVwRCxrRUFBaUU7QUFRakUsTUFBTSxnQkFBZ0I7SUFHbEIsWUFBYSxPQUFnQjtRQUN6QixJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQztJQUM1QixDQUFDO0lBRUQsSUFBSSxPQUFPO1FBQ1AsT0FBTy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