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I,EAAK,IAAM,EAAI,GAAG,QAAQ,UAAU,IAE1C,EAAK,KAAK,EACZ,CACF,CACA,EAAS,EACX,IAEO,IACT,EAaA,MAAO,SAAS,EAAK,EAAO,GAC1B,IAAK,EACH,MAAM,IAAI,MAAM,2CAQlB,OANA,EAAW,GAAY,WAAW,EACb,mBAAV,IACT,EAAW,EACX,GAAQ,GAEV,GAAG,KAAK,iBAAmB,IAAiB,IAAV,EAAiB,MAAQ,IAAI,GACxD,IACT,GAKF,OAAO,QAAU","file":"/npm/dalek-browser-ie@0.0.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/dalek-browser-ie@0.0.2/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*!\n *\n * Copyright (c) 2013 Sebastian Golasch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n *\n */\n\n'use strict';\n\n// ext. libs\nvar Q = require('q');\nvar cp = require('child_process');\nvar portscanner = require('portscanner');\n\n// int. libs\nvar iedriver = require('./lib/iedriver');\n\n/**\n * This module is a browser plugin for [DalekJS](//github.com/dalekjs/dalek).\n * It provides all a WebDriverServer & browser launcher for Internet Explorer.\n *\n * The browser plugin can be installed with the following command:\n *\n * ```bash\n * $ npm install dalek-browser-ie --save-dev\n * ```\n *\n * You can use the browser plugin by adding a config option to the your Dalekfile\n *\n * ```javascript\n * \"browsers\": [\"IE\"]\n * ```\n *\n * Or you can tell Dalek that it should test in this browser via the command line:\n *\n * ```bash\n * $ dalek mytest.js -b IE\n * ```\n *\n * The Webdriver Server tries to open Port 5555 by default,\n * if this port is blocked, it tries to use a port between 5555 & 5564\n * You can specifiy a different port from within your [Dalekfile](/pages/config.html) like so:\n *\n * ```javascript\n * \"browsers\": {\n *   \"ie\": {\n *     \"port\": 6555 \n *   }\n * }\n * ```\n *\n * It is also possible to specify a range of ports:\n *\n * ```javascript\n * \"browsers\": {\n *   \"ie\": {\n *     \"portRange\": [6100, 6120] \n *   }\n * }\n * ```\n * \n * @module DalekJS\n * @class InternetExplorer\n * @namespace Browser\n * @part InternetExplorer\n * @api\n */\n\nvar InternetExplorer = {\n\n  /**\n   * Verbose version of the browser name\n   *\n   * @property longName\n   * @type string\n   * @default Internet Explorer\n   * @api\n   */\n\n  longName: 'Internet Explorer',\n\n  /**\n   * Default port of the IEDriverServer\n   * The port may change, cause the port conflict resultion\n   * tool might pick another one, if the default one is blocked\n   *\n   * @property port\n   * @type integer\n   * @default 5555\n   */\n\n  port: 5555,\n\n  /**\n   * Default maximum port of the IEDriverServer\n   * The port is the highest port in the range that can be allocated\n   * by the IEDriverServer\n   *\n   * @property maxPort\n   * @type integer\n   * @default 5654\n   */\n\n  maxPort: 5654,\n\n  /**\n   * Default host of the IEDriverServer\n   * The host may be overridden with\n   * a user configured value\n   *\n   * @property host\n   * @type string\n   * @default localhost\n   */\n\n  host: 'localhost',\n\n  /**\n   * Default desired capabilities that should be\n   * transferred when the browser session gets requested\n   *\n   * @property desiredCapabilities\n   * @type object\n   */\n\n  desiredCapabilities: {\n    browserName: 'InternetExplorer'\n  },\n\n  /**\n   * Driver defaults, what should the driver be able to access.\n   *\n   * @property driverDefaults\n   * @type object\n   */\n\n  driverDefaults: {\n    viewport: true,\n    status: true,\n    sessionInfo: true\n  },\n\n  /**\n   * Path to the IEDriverServer.exe file\n   *\n   * @property path\n   * @type string\n   * @default /\n   */\n\n  path: '/',\n\n  /**\n   * Child process instance of the IEDriverServer\n   *\n   * @property spawned\n   * @type null|Object\n   */\n\n  spawned: null,\n\n  /**\n   * IE processes that are running on startup,\n   * and therefor shouldn`t be closed\n   *\n   * @property openProcesses\n   * @type array\n   * @default []   \n   */\n\n  openProcesses: [],\n\n  /**\n   * Resolves the driver port\n   *\n   * @method getPort\n   * @return {integer} port WebDriver server port\n   */\n\n  getPort: function () {\n    return this.port;\n  },\n\n  /**\n   * Returns the driver host\n   *\n   * @method getHost\n   * @return {string} host WebDriver server hostname\n   */\n\n  getHost: function () {\n    return this.host;\n  },\n\n  /**\n   * Resolves the maximum range for the driver port\n   *\n   * @method getMaxPort\n   * @return {integer} port Max WebDriver server port range\n   */\n\n  getMaxPort: function () {\n    return this.maxPort;\n  },\n\n  /**\n   * Launches the driver\n   * (the driver takes care of launching the browser)\n   *\n   * @method launch\n   * @return {object} promise Browser promise\n   */\n\n  launch: function (configuration, events, config) {\n    var deferred = Q.defer();\n\n    // store injected configuration/log event handlers\n    this.reporterEvents = events;\n    this.configuration = configuration;\n    this.config = config;\n\n    // check for a user set port\n    var browsers = this.config.get('browsers');\n    if (browsers && Array.isArray(browsers)) {\n      browsers.forEach(this._checkUserDefinedPorts.bind(this));\n    }\n\n    // check if the current port is in use, if so, scan for free ports\n    portscanner.findAPortNotInUse(this.getPort(), this.getMaxPort(), this.getHost(), this._checkPorts.bind(this, deferred));\n    return deferred.promise;\n  },\n\n  /**\n   * Kills the driver & browser processes\n   *\n   * @method kill\n   * @chainable\n   */\n\n  kill: function () {\n    // get a list of all running processes\n    this._list(function(svc){\n      // filter out the browser process\n      svc.forEach(function (item, idx) {\n        Object.keys(item).forEach(function (key) {\n          if(svc[idx][key] === 'iexplore.exe') {\n            // kill the browser process\n            this._kill(svc[idx].PID);\n          }\n        }.bind(this));\n      }.bind(this));\n    }.bind(this),true);\n\n    // kill the driver process\n    this.spawned.kill('SIGTERM');\n    return this;\n  },\n\n  _checkPorts: function (deferred, err, port) {\n    // check if the port was blocked & if we need to switch to another port\n    if (this.port !== port) {\n      this.reporterEvents.emit('report:log:system', 'dalek-browser-ie: Switching to port: ' + port);\n      this.port = port;\n    }\n\n    // invoke the ie driver afterwards\n    this._startIEdriver(deferred);\n    return this;\n  },\n\n  _startIEdriver: function (deferred) {\n    var stream = '';\n    this.spawned = cp.spawn(iedriver.path, ['--port=' + this.getPort()]);\n\n    this.spawned.stdout.on('data', function (data) {\n      var dataStr = data + '';\n      stream += dataStr;\n      if (stream.search('Listening on port') !== -1) {\n        deferred.resolve();\n      }\n    });\n    return this;\n  },\n\n  /**\n   * Process user defined ports\n   *\n   * @method _checkUserDefinedPorts\n   * @param {object} browser Browser configuration\n   * @chainable\n   * @private\n   */\n\n  _checkUserDefinedPorts: function (browser) {\n    // check for a single defined port\n    if (browser.ie && browser.ie.port) {\n      this.port = parseInt(browser.ie.port, 10);\n      this.maxPort = this.port + 90;\n      this.reporterEvents.emit('report:log:system', 'dalek-browser-ie: Switching to user defined port: ' + this.port);\n    }\n\n    // check for a port range\n    if (browser.ie && browser.ie.portRange && browser.ie.portRange.length === 2) {\n      this.port = parseInt(browser.ie.portRange[0], 10);\n      this.maxPort = parseInt(browser.ie.portRange[1], 10);\n      this.reporterEvents.emit('report:log:system', 'dalek-browser-ie: Switching to user defined port(s): ' + this.port + ' -> ' + this.maxPort);\n    }\n\n    return this;\n  },\n\n  /**\n   * Lists all running processes (win only)\n   *\n   * @method _list\n   * @param {Function} callback Receives the process object as the only callback argument\n   * @param {Boolean} [verbose=false] Verbose output\n   * @chainable\n   * @private\n   */\n\n  _list: function(callback, verbose) {\n    verbose = typeof verbose === 'boolean' ? verbose : false;\n    cp.exec('tasklist /FO CSV' + (verbose === true ? ' /V' : ''), function (err, stdout) {\n      var pi = stdout.split('\\r\\n');\n      var p = [];\n\n      pi.forEach(function (line) {\n        if (line.trim().length !== 0) {\n          p.push(line);\n        }\n      });\n\n      var proc = [];\n      var head = null;\n      while (p.length > 1) {\n        var rec = p.shift();\n        rec = rec.replace(/\\\"\\,/gi,'\";').replace(/\\\"|\\'/gi,'').split(';');\n        if (head === null){\n          head = rec;\n          for (var i=0;i<head.length;i++){\n            head[i] = head[i].replace(/ /gi,'');\n          }\n        } else {\n          var tmp = {};\n          for (var j=0;j<rec.length;j++){\n            tmp[head[j]] = rec[j].replace(/\\\"|\\'/gi,'');\n          }\n          proc.push(tmp);\n        }\n      }\n      callback(proc);\n    });\n\n    return this;\n  },\n\n  /**\n   * Kill a specific process (win only)\n   *\n   * @method _kill\n   * @param {Number} PID Process ID\n   * @param {Boolean} [force=false] Force close the process.\n   * @param {Function} [callback] Callback after process has been killed\n   * @chainable\n   * @private\n   */\n\n  _kill: function(pid, force, callback) {\n    if (!pid){\n      throw new Error('PID is required for the kill operation.');\n    }\n    callback = callback || function(){};\n    if (typeof force === 'function'){\n      callback = force;\n      force = false;\n    }\n    cp.exec('taskkill /PID ' + pid + (force === true ? ' /f' : ''),callback);\n    return this;\n  }\n\n};\n\n// expose the module\nmodule.exports = InternetExplorer;\n"]}