135 lines
17 KiB
JavaScript
135 lines
17 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 lodash_1 = require("lodash");
|
|
const promisify_event_1 = __importDefault(require("promisify-event"));
|
|
const browser_job_result_1 = __importDefault(require("../../runner/browser-job-result"));
|
|
const connection_1 = __importDefault(require("../connection"));
|
|
const warning_message_1 = __importDefault(require("../../notifications/warning-message"));
|
|
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
|
|
const name = Symbol();
|
|
class BrowserProviderPluginHost {
|
|
constructor(providerObject, providerName) {
|
|
this.JOB_RESULT = (0, lodash_1.assignIn)({}, browser_job_result_1.default);
|
|
(0, lodash_1.assignIn)(this, providerObject);
|
|
this[name] = providerName;
|
|
}
|
|
// Helpers
|
|
get providerName() {
|
|
return this[name];
|
|
}
|
|
async runInitScript(browserId, code) {
|
|
const connection = connection_1.default.getById(browserId);
|
|
return connection.runInitScript(`(${code})()`);
|
|
}
|
|
calculateWindowId() {
|
|
return (0, testcafe_hammerhead_1.generateUniqueId)();
|
|
}
|
|
waitForConnectionReady(browserId) {
|
|
const connection = connection_1.default.getById(browserId);
|
|
if (connection.isReady())
|
|
return Promise.resolve();
|
|
return (0, promisify_event_1.default)(connection, 'ready');
|
|
}
|
|
reportWarning(browserId, ...args) {
|
|
const connection = connection_1.default.getById(browserId);
|
|
connection.addWarning(...args);
|
|
}
|
|
setUserAgentMetaInfo(browserId, message, ...args) {
|
|
const connection = connection_1.default.getById(browserId);
|
|
connection.setProviderMetaInfo(message, ...args);
|
|
}
|
|
async closeLocalBrowser(browserId) {
|
|
const connection = connection_1.default.getById(browserId);
|
|
await connection.provider._ensureBrowserWindowDescriptor(browserId);
|
|
await connection.provider._closeLocalBrowser(browserId);
|
|
}
|
|
async resizeLocalBrowserWindow(browserId, width, height, currentWidth, currentHeight) {
|
|
const connection = connection_1.default.getById(browserId);
|
|
await connection.provider._ensureBrowserWindowParameters(browserId);
|
|
await connection.provider._resizeLocalBrowserWindow(browserId, width, height, currentWidth, currentHeight);
|
|
}
|
|
// API
|
|
// Browser control
|
|
async openBrowser( /* browserId, pageUrl, browserName */) {
|
|
throw new Error('Not implemented!');
|
|
}
|
|
async closeBrowser( /* browserId */) {
|
|
throw new Error('Not implemented!');
|
|
}
|
|
// Initialization
|
|
async init() {
|
|
return;
|
|
}
|
|
async dispose() {
|
|
return;
|
|
}
|
|
// Browser names handling
|
|
async getBrowserList() {
|
|
throw new Error('Not implemented!');
|
|
}
|
|
async isValidBrowserName( /* browserName */) {
|
|
return true;
|
|
}
|
|
// Extra functions
|
|
// NOTE:
|
|
// The browserName argument is optional, and must be supplied if the browserId argument is not valid
|
|
// (browser is not opened)
|
|
async isLocalBrowser( /* browserId[, browserName] */) {
|
|
return false;
|
|
}
|
|
// NOTE:
|
|
// The browserName argument is optional, and must be supplied if the browserId argument is not valid
|
|
// (browser is not opened)
|
|
isHeadlessBrowser( /* browserId[, browserName] */) {
|
|
return false;
|
|
}
|
|
async hasCustomActionForBrowser( /* browserId */) {
|
|
return {
|
|
hasCloseBrowser: this.hasOwnProperty('closeBrowser'),
|
|
hasResizeWindow: this.hasOwnProperty('resizeWindow'),
|
|
hasTakeScreenshot: this.hasOwnProperty('takeScreenshot'),
|
|
hasGetVideoFrameData: this.hasOwnProperty('getVideoFrameData'),
|
|
hasCanResizeWindowToDimensions: this.hasOwnProperty('canResizeWindowToDimensions'),
|
|
hasMaximizeWindow: this.hasOwnProperty('maximizeWindow'),
|
|
hasChromelessScreenshots: false,
|
|
};
|
|
}
|
|
async resizeWindow(browserId /*, width, height, currentWidth, currentHeight */) {
|
|
this.reportWarning(browserId, warning_message_1.default.resizeNotSupportedByBrowserProvider, this[name]);
|
|
}
|
|
async canResizeWindowToDimensions( /* browserId, width, height */) {
|
|
return true;
|
|
}
|
|
async takeScreenshot(browserId /*, screenshotPath, pageWidth, pageHeight */) {
|
|
this.reportWarning(browserId, warning_message_1.default.screenshotNotSupportedByBrowserProvider, this[name]);
|
|
}
|
|
async maximizeWindow(browserId) {
|
|
this.reportWarning(browserId, warning_message_1.default.maximizeNotSupportedByBrowserProvider, this[name]);
|
|
}
|
|
async startCapturingVideo( /*browserId*/) {
|
|
}
|
|
async stopCapturingVideo( /*browserId*/) {
|
|
}
|
|
async getVideoFrameData(browserId) {
|
|
const browserAlias = connection_1.default.getById(browserId).browserInfo.alias;
|
|
this.reportWarning(browserId, warning_message_1.default.videoNotSupportedByBrowser, browserAlias);
|
|
}
|
|
async reportJobResult( /*browserId, status, data*/) {
|
|
return;
|
|
}
|
|
getConfig(value) {
|
|
return value;
|
|
}
|
|
async closeBrowserChildWindow( /*browserId*/) {
|
|
return Promise.resolve();
|
|
}
|
|
async getOSInfo( /*browserId*/) {
|
|
return null;
|
|
}
|
|
}
|
|
exports.default = BrowserProviderPluginHost;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2luLWhvc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYnJvd3Nlci9wcm92aWRlci9wbHVnaW4taG9zdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1DQUFrQztBQUNsQyxzRUFBNkM7QUFDN0MseUZBQWlFO0FBQ2pFLCtEQUE4QztBQUM5QywwRkFBa0U7QUFDbEUsNkRBQXVEO0FBRXZELE1BQU0sSUFBSSxHQUFHLE1BQU0sRUFBRSxDQUFDO0FBRXRCLE1BQXFCLHlCQUF5QjtJQUMxQyxZQUFhLGNBQWMsRUFBRSxZQUFZO1FBQ3JDLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBQSxpQkFBUSxFQUFDLEVBQUUsRUFBRSw0QkFBa0IsQ0FBQyxDQUFDO1FBRW5ELElBQUEsaUJBQVEs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