99 lines
15 KiB
JavaScript
99 lines
15 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 device_specs_1 = require("device-specs");
|
|
const utils_1 = require("./commands/utils");
|
|
const type_1 = __importDefault(require("./commands/type"));
|
|
const warning_message_1 = __importDefault(require("../notifications/warning-message"));
|
|
const test_run_1 = require("../errors/test-run/");
|
|
class BrowserManipulationQueue {
|
|
constructor(browserConnection, screenshotCapturer, warningLog) {
|
|
this.commands = [];
|
|
this.browserId = browserConnection.id;
|
|
this.browserProvider = browserConnection.provider;
|
|
this.screenshotCapturer = screenshotCapturer;
|
|
this.warningLog = warningLog;
|
|
}
|
|
async _resizeWindow(width, height, currentWidth, currentHeight) {
|
|
const canResizeWindow = await this.browserProvider.canResizeWindowToDimensions(this.browserId, width, height);
|
|
if (!canResizeWindow)
|
|
throw new test_run_1.WindowDimensionsOverflowError();
|
|
try {
|
|
return await this.browserProvider.resizeWindow(this.browserId, width, height, currentWidth, currentHeight);
|
|
}
|
|
catch (err) {
|
|
this.warningLog.addWarning(warning_message_1.default.resizeError, err.message);
|
|
return null;
|
|
}
|
|
}
|
|
async _resizeWindowToFitDevice(device, portrait, currentWidth, currentHeight) {
|
|
const { landscapeWidth, portraitWidth } = (0, device_specs_1.getViewportSize)(device);
|
|
const width = portrait ? portraitWidth : landscapeWidth;
|
|
const height = portrait ? landscapeWidth : portraitWidth;
|
|
return await this._resizeWindow(width, height, currentWidth, currentHeight);
|
|
}
|
|
async _maximizeWindow() {
|
|
try {
|
|
return await this.browserProvider.maximizeWindow(this.browserId);
|
|
}
|
|
catch (err) {
|
|
this.warningLog.addWarning(warning_message_1.default.maximizeError, err.message);
|
|
return null;
|
|
}
|
|
}
|
|
async _takeScreenshot(capture) {
|
|
return capture();
|
|
}
|
|
async _executeCommand(driverMsg) {
|
|
const command = this.commands.shift();
|
|
switch (command.type) {
|
|
case type_1.default.takeElementScreenshot:
|
|
case type_1.default.takeScreenshot:
|
|
return await this._takeScreenshot(() => this.screenshotCapturer.captureAction({
|
|
actionId: command.actionId,
|
|
customPath: command.path,
|
|
pageDimensions: driverMsg.pageDimensions,
|
|
cropDimensions: driverMsg.cropDimensions,
|
|
markSeed: command.markSeed,
|
|
fullPage: command.fullPage,
|
|
thumbnails: command.thumbnails,
|
|
}));
|
|
case type_1.default.takeScreenshotOnFail:
|
|
return await this._takeScreenshot(() => this.screenshotCapturer.captureError({
|
|
actionId: command.actionId,
|
|
failedActionId: command.failedActionId,
|
|
pageDimensions: driverMsg.pageDimensions,
|
|
markSeed: command.markSeed,
|
|
fullPage: command.fullPage,
|
|
}));
|
|
case type_1.default.resizeWindow:
|
|
return await this._resizeWindow(command.width, command.height, driverMsg.pageDimensions.innerWidth, driverMsg.pageDimensions.innerHeight);
|
|
case type_1.default.resizeWindowToFitDevice:
|
|
return await this._resizeWindowToFitDevice(command.device, command.options.portraitOrientation, driverMsg.pageDimensions.innerWidth, driverMsg.pageDimensions.innerHeight);
|
|
case type_1.default.maximizeWindow:
|
|
return await this._maximizeWindow();
|
|
}
|
|
return null;
|
|
}
|
|
async executePendingManipulation(driverMsg, messageBus) {
|
|
const command = this.commands[0];
|
|
const handleBrowserManipulationWarning = warning => {
|
|
warning.actionId = warning.actionId || command.actionId;
|
|
};
|
|
messageBus.on('before-warning-add', handleBrowserManipulationWarning);
|
|
const result = await this._executeCommand(driverMsg);
|
|
messageBus.off('before-warning-add', handleBrowserManipulationWarning);
|
|
return result;
|
|
}
|
|
push(command) {
|
|
this.commands.push(command);
|
|
}
|
|
removeAllNonServiceManipulations() {
|
|
this.commands = this.commands.filter(command => (0, utils_1.isServiceCommand)(command));
|
|
}
|
|
}
|
|
exports.default = BrowserManipulationQueue;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvd3Nl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ICB9XG5cbiAgICBhc3luYyBfZXhlY3V0ZUNvbW1hbmQgKGRyaXZlck1zZykge1xuICAgICAgICBjb25zdCBjb21tYW5kID0gdGhpcy5jb21tYW5kcy5zaGlmdCgpO1xuXG4gICAgICAgIHN3aXRjaCAoY29tbWFuZC50eXBlKSB7XG4gICAgICAgICAgICBjYXNlIENPTU1BTkRfVFlQRS50YWtlRWxlbWVudFNjcmVlbnNob3Q6XG4gICAgICAgICAgICBjYXNlIENPTU1BTkRfVFlQRS50YWtlU2NyZWVuc2hvdDpcbiAgICAgICAgICAgICAgICByZXR1cm4gYXdhaXQgdGhpcy5fdGFrZVNjcmVlbnNob3QoKCkgPT4gdGhpcy5zY3JlZW5zaG90Q2FwdHVyZXIuY2FwdHVyZUFjdGlvbih7XG4gICAgICAgICAgICAgICAgICAgIGFjdGlvbklkOiAgICAgICBjb21tYW5kLmFjdGlvbklkLFxuICAgICAgICAgICAgICAgICAgICBjdXN0b21QYXRoOiAgICAgY29tbWFuZC5wYXRoLFxuICAgICAgICAgICAgICAgICAgICBwYWdlRGltZW5zaW9uczogZHJpdmVyTXNnLnBhZ2VEaW1lbnNpb25zLFxuICAgICAgICAgICAgICAgICAgICBjcm9wRGltZW5zaW9uczogZHJpdmVyTXNnLmNyb3BEaW1lbnNpb25zLFxuICAgICAgICAgICAgICAgICAgICBtYXJrU2VlZDogICAgICAgY29tbWFuZC5tYXJrU2VlZCxcbiAgICAgICAgICAgICAgICAgICAgZnVsbFBhZ2U6ICAgICAgIGNvbW1hbmQuZnVsbFBhZ2UsXG4gICAgICAgICAgICAgICAgICAgIHRodW1ibmFpbHM6ICAgICBjb21tYW5kLnRodW1ibmFpbHMsXG4gICAgICAgICAgICAgICAgfSkpO1xuXG4gICAgICAgICAgICBjYXNlIENPTU1BTkRfVFlQRS50YWtlU2NyZWVuc2hvdE9uRmFpbDpcbiAgICAgICAgICAgICAgICByZXR1cm4gYXdhaXQgdGhpcy5fdGFrZVNjcmVlbnNob3QoKCkgPT4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