Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async _resizeLocalBrowserWindow (browserId: string, width: number, height: number, currentWidth: number, currentHeight: number): Promise {
const resizeCorrections = this._getResizeCorrections(browserId);
if (resizeCorrections && await browserTools.isMaximized(this._getWindowDescriptor(browserId))) {
width -= resizeCorrections.width;
height -= resizeCorrections.height;
}
await browserTools.resize(this._getWindowDescriptor(browserId), currentWidth, currentHeight, width, height);
}
private async _calculateResizeCorrections (browserId: string): Promise {
if (!this._isBrowserIdle(browserId))
return;
const title = await this.plugin.runInitScript(browserId, GET_TITLE_SCRIPT);
if (!await browserTools.isMaximized(title))
return;
const currentSize = await this.plugin.runInitScript(browserId, GET_WINDOW_DIMENSIONS_INFO_SCRIPT);
const etalonSize = subtractSizes(currentSize, RESIZE_DIFF_SIZE);
await browserTools.resize(title, currentSize.width, currentSize.height, etalonSize.width, etalonSize.height);
let resizedSize = await this.plugin.runInitScript(browserId, GET_WINDOW_DIMENSIONS_INFO_SCRIPT);
let correctionSize = subtractSizes(resizedSize, etalonSize);
await browserTools.resize(title, resizedSize.width, resizedSize.height, etalonSize.width, etalonSize.height);
resizedSize = await this.plugin.runInitScript(browserId, GET_WINDOW_DIMENSIONS_INFO_SCRIPT);
correctionSize = sumSizes(correctionSize, subtractSizes(resizedSize, etalonSize));