Innovenergy_trunk/frontend/node_modules/testcafe/lib/browser/provider/plugin-host.js

135 lines
17 KiB
JavaScript
Raw Normal View History

"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 = ex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