Innovenergy_trunk/frontend/node_modules/testcafe-browser-tools/lib/api/close.js

33 lines
3.8 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 os_family_1 = __importDefault(require("os-family"));
const find_window_1 = __importDefault(require("./find-window"));
const exec_1 = require("../utils/exec");
const binaries_1 = __importDefault(require("../binaries"));
/**
* Closes the browser window where the specified web page is opened.
* @function
* @async
* @name close
* @param {string | object} windowDescriptor - The title of the web page opened in the window or a descriptor returned by findWindow.
*/
async function default_1(windowDescriptor) {
var windowDescription = typeof windowDescriptor === 'string' ? await find_window_1.default(windowDescriptor) : windowDescriptor;
if (!windowDescription)
return;
var closeWindowArguments = void 0;
if (os_family_1.default.win)
closeWindowArguments = [windowDescription.hwnd];
else if (os_family_1.default.mac)
closeWindowArguments = [windowDescription.processId, windowDescription.windowId];
else if (os_family_1.default.linux)
closeWindowArguments = [windowDescription.windowId];
else
return;
await exec_1.execFile(binaries_1.default.close, closeWindowArguments);
}
exports.default = default_1;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xvc2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXBpL2Nsb3NlLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsMERBQTJCO0FBQzNCLGdFQUF1QztBQUN2Qyx3Q0FBeUM7QUFDekMsMkRBQW1DO0FBRW5DOzs7Ozs7R0FNRztBQUNZLEtBQUssb0JBQVcsZ0JBQWdCO0lBQzNDLElBQUksaUJBQWlCLEdBQUcsT0FBTyxnQkFBZ0IsS0FBSyxRQUFRLENBQUMsQ0FBQyxDQUFDLE1BQU0scUJBQVUsQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDLENBQUMsQ0FBQyxnQkFBZ0IsQ0FBQztJQUVySCxJQ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