95 lines
14 KiB
JavaScript
95 lines
14 KiB
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.isExecutableOnClientCommand = exports.isJSExpression = exports.isExecutableInTopWindowOnly = exports.isServiceCommand = exports.isBrowserManipulationCommand = exports.isResizeWindowCommand = exports.isScreenshotCommand = exports.canSetDebuggerBreakpointBeforeCommand = exports.isAssertionCommand = exports.isObservationCommand = exports.isClientFunctionCommand = exports.isCommandRejectableByPageError = void 0;
|
||
|
// -------------------------------------------------------------
|
||
|
// WARNING: this file is used by both the client and the server.
|
||
|
// Do not use any browser or node-specific API!
|
||
|
// -------------------------------------------------------------
|
||
|
const type_1 = __importDefault(require("./type"));
|
||
|
const RAW_API_JS_EXPRESSION_TYPE = 'js-expr';
|
||
|
function isCommandRejectableByPageError(command) {
|
||
|
return !isObservationCommand(command) && !isBrowserManipulationCommand(command) && !isServiceCommand(command) ||
|
||
|
isResizeWindowCommand(command)
|
||
|
&& !isWindowSwitchingCommand(command);
|
||
|
}
|
||
|
exports.isCommandRejectableByPageError = isCommandRejectableByPageError;
|
||
|
function isClientFunctionCommand(command) {
|
||
|
return command.type === type_1.default.executeClientFunction ||
|
||
|
command.type === type_1.default.executeSelector;
|
||
|
}
|
||
|
exports.isClientFunctionCommand = isClientFunctionCommand;
|
||
|
function isObservationCommand(command) {
|
||
|
return isClientFunctionCommand(command) ||
|
||
|
command.type === type_1.default.wait ||
|
||
|
command.type === type_1.default.assertion ||
|
||
|
command.type === type_1.default.executeExpression;
|
||
|
}
|
||
|
exports.isObservationCommand = isObservationCommand;
|
||
|
function isAssertionCommand(command) {
|
||
|
return !!command.assertionType;
|
||
|
}
|
||
|
exports.isAssertionCommand = isAssertionCommand;
|
||
|
function isWindowSwitchingCommand(command) {
|
||
|
return command.type === type_1.default.switchToIframe || command.type === type_1.default.switchToMainWindow;
|
||
|
}
|
||
|
function canSetDebuggerBreakpointBeforeCommand(command) {
|
||
|
return command.type !== type_1.default.debug && !isClientFunctionCommand(command) && !isServiceCommand(command);
|
||
|
}
|
||
|
exports.canSetDebuggerBreakpointBeforeCommand = canSetDebuggerBreakpointBeforeCommand;
|
||
|
function isScreenshotCommand(command) {
|
||
|
return command.type === type_1.default.takeScreenshot ||
|
||
|
command.type === type_1.default.takeElementScreenshot ||
|
||
|
command.type === type_1.default.takeScreenshotOnFail;
|
||
|
}
|
||
|
exports.isScreenshotCommand = isScreenshotCommand;
|
||
|
function isResizeWindowCommand(command) {
|
||
|
return command.type === type_1.default.resizeWindow ||
|
||
|
command.type === type_1.default.resizeWindowToFitDevice ||
|
||
|
command.type === type_1.default.maximizeWindow;
|
||
|
}
|
||
|
exports.isResizeWindowCommand = isResizeWindowCommand;
|
||
|
function isBrowserManipulationCommand(command) {
|
||
|
return isScreenshotCommand(command) || isResizeWindowCommand(command);
|
||
|
}
|
||
|
exports.isBrowserManipulationCommand = isBrowserManipulationCommand;
|
||
|
function isServiceCommand(command) {
|
||
|
return command.type === type_1.default.testDone ||
|
||
|
command.type === type_1.default.showAssertionRetriesStatus ||
|
||
|
command.type === type_1.default.hideAssertionRetriesStatus ||
|
||
|
command.type === type_1.default.setBreakpoint ||
|
||
|
command.type === type_1.default.takeScreenshotOnFail ||
|
||
|
command.type === type_1.default.recorder ||
|
||
|
command.type === type_1.default.getProxyUrl;
|
||
|
}
|
||
|
exports.isServiceCommand = isServiceCommand;
|
||
|
function isExecutableInTopWindowOnly(command) {
|
||
|
return command.type === type_1.default.testDone ||
|
||
|
command.type === type_1.default.switchToMainWindow ||
|
||
|
command.type === type_1.default.setNativeDialogHandler ||
|
||
|
command.type === type_1.default.getNativeDialogHistory ||
|
||
|
command.type === type_1.default.setTestSpeed ||
|
||
|
command.type === type_1.default.showAssertionRetriesStatus ||
|
||
|
command.type === type_1.default.hideAssertionRetriesStatus ||
|
||
|
command.type === type_1.default.setBreakpoint ||
|
||
|
isBrowserManipulationCommand(command) && command.type !== type_1.default.takeElementScreenshot;
|
||
|
}
|
||
|
exports.isExecutableInTopWindowOnly = isExecutableInTopWindowOnly;
|
||
|
function isJSExpression(val) {
|
||
|
return val !== null && typeof val === 'object' && val.type === RAW_API_JS_EXPRESSION_TYPE &&
|
||
|
typeof val.value === 'string';
|
||
|
}
|
||
|
exports.isJSExpression = isJSExpression;
|
||
|
function isExecutableOnClientCommand(command) {
|
||
|
return command.type !== type_1.default.wait &&
|
||
|
command.type !== type_1.default.setPageLoadTimeout &&
|
||
|
command.type !== type_1.default.debug &&
|
||
|
command.type !== type_1.default.useRole &&
|
||
|
command.type !== type_1.default.assertion &&
|
||
|
command.type !== type_1.default.executeExpression &&
|
||
|
command.type !== type_1.default.executeAsyncExpression;
|
||
|
}
|
||
|
exports.isExecutableOnClientCommand = isExecutableOnClientCommand;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdC1ydW4vY29tbWFuZHMvdXRpbHMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsZ0VBQWdFO0FBQ2hFLGdFQUFnRTtBQUNoRSwrQ0FBK0M7QUFDL0MsZ0VBQWdFO0FBQ2hFLGtEQUEwQjtBQUUxQixNQUFNLDBCQUEwQixHQUFHLFNBQVMsQ0FBQztBQUU3QyxTQUFnQiw4QkFBOEIsQ0FBRSxPQUFPO0lBQ25ELE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLDRCQUE0QixDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxDQUFDO1FBQ3RHLHFCQUFxQixDQUFDLE9BQU8sQ0FBQztlQUMzQixDQUFDLHdCQUF3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