├── .gitignore ├── .npmignore ├── .eslintrc ├── .editorconfig ├── test ├── .eslintrc ├── mocha-globals.js └── launcher.spec.js ├── .travis.yml ├── LICENSE ├── package.json ├── gruntfile.js ├── CHANGELOG.md ├── README.md └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .idea 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .* 2 | 3 | Gruntfile.coffee 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "standard" 3 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | insert_final_newline = true 6 | 7 | [*.js] 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "expect": false, 7 | "should": false, 8 | "sinon": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | - "8" 5 | - "10" 6 | 7 | # Make sure we have new NPM. 8 | before_install: 9 | - npm install -g npm 10 | 11 | before_script: 12 | - npm install -g grunt-cli 13 | 14 | script: 15 | - grunt 16 | -------------------------------------------------------------------------------- /test/mocha-globals.js: -------------------------------------------------------------------------------- 1 | var sinon = require('sinon') 2 | var chai = require('chai') 3 | 4 | // publish globals that all specs can use 5 | global.expect = chai.expect 6 | global.should = chai.should() 7 | global.sinon = sinon 8 | 9 | // chai plugins 10 | chai.use(require('sinon-chai')) 11 | 12 | beforeEach(function () { 13 | global.sinon = sinon.sandbox.create() 14 | }) 15 | 16 | afterEach(function () { 17 | global.sinon.restore() 18 | }) 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (C) 2011-2013 Google, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "karma-ie-launcher", 3 | "version": "1.0.0", 4 | "description": "A Karma plugin. Launcher for Internet Explorer.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/karma-runner/karma-ie-launcher.git" 12 | }, 13 | "keywords": [ 14 | "karma-plugin", 15 | "karma-launcher", 16 | "ie" 17 | ], 18 | "author": "Vojta Jina ", 19 | "dependencies": { 20 | "lodash": "^4.6.1" 21 | }, 22 | "peerDependencies": { 23 | "karma": ">=0.9" 24 | }, 25 | "license": "MIT", 26 | "devDependencies": { 27 | "chai": "^3.5.0", 28 | "di": "^0.0.1", 29 | "eslint": "^2.4.0", 30 | "eslint-config-standard": "^5.1.0", 31 | "eslint-plugin-promise": "^1.1.0", 32 | "eslint-plugin-react": "^4.2.1", 33 | "eslint-plugin-standard": "^1.3.2", 34 | "grunt": "^0.4.1", 35 | "grunt-auto-release": "^0.0.6", 36 | "grunt-bump": "^0.7.0", 37 | "grunt-contrib-watch": "^1.0.0", 38 | "grunt-conventional-changelog": "^6.1.0", 39 | "grunt-conventional-github-releaser": "^0.5.0", 40 | "grunt-eslint": "^18.0.0", 41 | "grunt-npm": "^0.0.2", 42 | "grunt-simple-mocha": "^0.4.0", 43 | "karma": "1.x || ^0.13.22", 44 | "load-grunt-tasks": "^3.2.0", 45 | "mocks": "0.0.15", 46 | "sinon": "^1.14.1", 47 | "sinon-chai": "^2.8.0" 48 | }, 49 | "contributors": [ 50 | "sarychev ", 51 | "Mark Ethan Trostler ", 52 | "sylvain-hamel ", 53 | "dignifiedquire ", 54 | "Sylvain Hamel ", 55 | "Andreas Krummsdorf ", 56 | "Nikita Khomyakov ", 57 | "Friedel Ziegelmayer ", 58 | "Christopher Currie " 59 | ] 60 | } 61 | -------------------------------------------------------------------------------- /gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | grunt.initConfig({ 3 | pkgFile: 'package.json', 4 | simplemocha: { 5 | options: { 6 | ui: 'bdd', 7 | reporter: 'dot' 8 | }, 9 | unit: { 10 | src: [ 11 | 'test/mocha-globals.js', 12 | 'test/*.spec.js' 13 | ] 14 | } 15 | }, 16 | 'npm-contributors': { 17 | options: { 18 | commitMessage: 'chore: update contributors' 19 | } 20 | }, 21 | bump: { 22 | options: { 23 | commitMessage: 'chore: release v%VERSION%', 24 | pushTo: 'upstream', 25 | commitFiles: [ 26 | 'package.json', 27 | 'CHANGELOG.md' 28 | ] 29 | } 30 | }, 31 | conventionalChangelog: { 32 | release: { 33 | options: { 34 | changelogOpts: { 35 | preset: 'angular' 36 | } 37 | }, 38 | src: 'CHANGELOG.md' 39 | } 40 | }, 41 | conventionalGithubReleaser: { 42 | release: { 43 | options: { 44 | auth: { 45 | type: 'oauth', 46 | token: process.env.GH_TOKEN 47 | }, 48 | changelogOpts: { 49 | preset: 'angular', 50 | releaseCount: 0 51 | } 52 | } 53 | } 54 | }, 55 | eslint: { 56 | target: [ 57 | 'index.js', 58 | 'gruntfile.js', 59 | 'karma.conf.js', 60 | 'test/*.js' 61 | ] 62 | } 63 | }) 64 | 65 | require('load-grunt-tasks')(grunt) 66 | 67 | grunt.registerTask('test', ['simplemocha']) 68 | grunt.registerTask('default', ['eslint', 'test']) 69 | 70 | grunt.registerTask('release', 'Bump the version and publish to NPM.', function (type) { 71 | grunt.task.run([ 72 | 'npm-contributors', 73 | 'bump:' + (type || 'patch') + ':bump-only', 74 | 'conventionalChangelog', 75 | 'bump-commit', 76 | 'conventionalGithubReleaser', 77 | 'npm-publish' 78 | ]) 79 | }) 80 | } 81 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # [1.0.0](https://github.com/karma-runner/karma-ie-launcher/compare/v2.0.0...v1.0.0) (2016-05-03) 3 | 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * travis([68c0920](https://github.com/karma-runner/karma-ie-launcher/commit/68c0920)) 9 | * travis([0f584d9](https://github.com/karma-runner/karma-ie-launcher/commit/0f584d9)) 10 | 11 | 12 | 13 | 14 | ## 0.2.0 (2015-06-09) 15 | 16 | #### Features 17 | 18 | * Disable `-extoff` flag to be set by default ([5aa409e7](https://github.com/karma-runner/karma-ie-launcher/commit/5aa409e7), closes [#27](https://github.com/karma-runner/karma-ie-launcher/issues/27)) 19 | 20 | 21 | #### Breaking Changes 22 | 23 | * IE Addons are now disabled by default when using the karma-ie-launcher ([5aa409e7](https://github.com/karma-runner/karma-ie-launcher/commit/5aa409e7)) 24 | 25 | 26 | 27 | 28 | ### 0.1.5 (2015-06-09) 29 | 30 | 31 | #### Bug Fixes 32 | 33 | * fail when launcher is called if IE is not found instead of failing as soon as the plugin is loaded ([4ff5d1e6](https://github.com/karma-runner/karma-ie-launcher/commit/4ff5d1e6), closes [#14](https://github.com/karma-runner/karma-ie-launcher/issues/14)) 34 | 35 | 36 | 37 | ### 0.1.4 (2015-06-09) 38 | 39 | 40 | #### Bug Fixes 41 | 42 | * add Travis build status to README.md ([373f886c](https://github.com/karma-runner/karma-ie-launcher/commit/373f886c)) 43 | * setup travis build ([c739d2de](https://github.com/karma-runner/karma-ie-launcher/commit/c739d2de), closes [#18](https://github.com/karma-runner/karma-ie-launcher/issues/18)) 44 | * setup travis build ([8092fc03](https://github.com/karma-runner/karma-ie-launcher/commit/8092fc03), closes [#18](https://github.com/karma-runner/karma-ie-launcher/issues/18)) 45 | * add code style verification ([d482680a](https://github.com/karma-runner/karma-ie-launcher/commit/d482680a), closes [#17](https://github.com/karma-runner/karma-ie-launcher/issues/17)) 46 | * kill all IE processes when terminating browser process ([12793814](https://github.com/karma-runner/karma-ie-launcher/commit/12793814), closes [#15](https://github.com/karma-runner/karma-ie-launcher/issues/15)) 47 | 48 | 49 | #### Features 50 | 51 | * allow multiple IE versions in emulation modes Closes https://github.com/karma-ru ([052cf5ca](https://github.com/karma-runner/karma-ie-launcher/commit/052cf5ca)) 52 | 53 | 54 | 55 | ### 0.1.3 (2015-06-09) 56 | 57 | 58 | 59 | ### 0.1.2 (2015-06-09) 60 | 61 | 62 | #### Features 63 | 64 | * support 64-bit IE and isolate environment. ([c75ed348](https://github.com/karma-runner/karma-ie-launcher/commit/c75ed348), closes [#1](https://github.com/karma-runner/karma-ie-launcher/issues/1)) 65 | 66 | 67 | 68 | ### 0.1.1 (2015-06-09) 69 | 70 | 71 | 72 | ## 0.1.0 (2015-06-09) 73 | 74 | 75 | 76 | ### 0.0.1 (2015-06-09) 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # karma-ie-launcher 2 | 3 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-ie-launcher) 4 | [![npm version](https://img.shields.io/npm/v/karma-ie-launcher.svg?style=flat-square)](https://www.npmjs.com/package/karma-ie-launcher) [![npm downloads](https://img.shields.io/npm/dm/karma-ie-launcher.svg?style=flat-square)](https://www.npmjs.com/package/karma-ie-launcher) 5 | 6 | [![Build Status](https://img.shields.io/travis/karma-runner/karma-ie-launcher/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-ie-launcher) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-ie-launcher.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-ie-launcher) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-ie-launcher.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-ie-launcher#info=devDependencies) 7 | 8 | > Launcher for Internet Explorer. 9 | 10 | ## Installation 11 | 12 | The easiest way is to keep `karma-ie-launcher` as a devDependency, by running 13 | 14 | ```bash 15 | npm install karma-ie-launcher --save-dev 16 | ``` 17 | 18 | ## Configuration 19 | ```js 20 | // karma.conf.js 21 | module.exports = function(config) { 22 | config.set({ 23 | browsers: ['IE'] 24 | }); 25 | }; 26 | ``` 27 | 28 | You can pass list of browsers as a CLI argument too: 29 | ```bash 30 | karma start --browsers IE 31 | ``` 32 | 33 | You can run IE in emulation mode by setting the 'x-ua-compatible' option: 34 | ```js 35 | customLaunchers: { 36 | IE9: { 37 | base: 'IE', 38 | 'x-ua-compatible': 'IE=EmulateIE9' 39 | }, 40 | IE8: { 41 | base: 'IE', 42 | 'x-ua-compatible': 'IE=EmulateIE8' 43 | } 44 | } 45 | ``` 46 | See [Specifying legacy document modes] on MSDN. 47 | 48 | ### Running IE in "No add-ons mode" 49 | 50 | Please note that since **v0.2.0** default behaviour of launching Internet Explorer has changed. 51 | Now it runs using system-wide configuration (uses same settings as if you would run it manually) but prior to **v0.2.0** it was spawned with `-extoff` flag set explicitly, so all extensions were disabled. 52 | 53 | If you expect the same behaviour as it was before **v0.2.0**, Karma configuration should be slightly changed: 54 | - create new `customLauncher` configuration (`IE_no_addons` is used in an example below) with custom flags (in our case it is `-extoff` only) 55 | - browser `IE` in `browsers` field should be replaced with your new custom launcher name 56 | ```js 57 | browsers: ['IE_no_addons'], 58 | customLaunchers: { 59 | IE_no_addons: { 60 | base: 'IE', 61 | flags: ['-extoff'] 62 | } 63 | } 64 | ``` 65 | 66 | See [IE Command-Line Options] on MSDN. 67 | 68 | ---- 69 | 70 | For more information on Karma see the [homepage]. 71 | 72 | 73 | [homepage]: http://karma-runner.github.com 74 | [Specifying legacy document modes]: http://msdn.microsoft.com/en-us/library/ie/jj676915(v=vs.85).aspx 75 | [IE Command-Line Options]: https://msdn.microsoft.com/en-us/library/hh826025(v=vs.85).aspx 76 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Karme IE Launcher 2 | // ================= 3 | 4 | // Dependencies 5 | // ------------ 6 | 7 | var path = require('path') 8 | var fs = require('fs') 9 | var urlparse = require('url').parse 10 | var urlformat = require('url').format 11 | var exec = require('child_process').exec 12 | var _ = require('lodash') 13 | 14 | // Constants 15 | // --------- 16 | 17 | var PROCESS_NAME = 'iexplore.exe' 18 | 19 | // Find the ie executable 20 | function getInternetExplorerExe () { 21 | var suffix = path.join('Internet Explorer', PROCESS_NAME) 22 | var locations = _.map(_.compact([ 23 | process.env['PROGRAMW6432'], 24 | process.env['PROGRAMFILES(X86)'], 25 | process.env['PROGRAMFILES'] 26 | ]), function (prefix) { 27 | return path.join(prefix, suffix) 28 | }) 29 | 30 | return _.find(locations, function (location) { 31 | return fs.existsSync(location) 32 | }) 33 | } 34 | 35 | // Constructor 36 | function IEBrowser (baseBrowserDecorator, logger, args) { 37 | baseBrowserDecorator(this) 38 | 39 | var log = logger.create('launcher') 40 | var flags = args.flags || [] 41 | 42 | // Handle x-ua-compatible option: 43 | // 44 | // Usage : 45 | // customLaunchers: { 46 | // IE9: { 47 | // base: 'IE', 48 | // 'x-ua-compatible': 'IE=EmulateIE9' 49 | // } 50 | // } 51 | // 52 | // This is done by passing the option on the url, in response the Karma server will 53 | // set the following meta in the page. 54 | // 55 | function handleXUaCompatible (args, urlObj) { 56 | if (args['x-ua-compatible']) { 57 | urlObj.query['x-ua-compatible'] = args['x-ua-compatible'] 58 | } 59 | } 60 | 61 | // Spawning iexplore.exe spawns two processes (IE does that). The way karma kills the 62 | // browser process (hard kill) leaves the other process in memory. 63 | // 64 | // The second process is created using command-line args like this: 65 | // "C:\Program Files\Internet Explorer\iexplore.exe" SCODEF:2632 CREDAT:275457 /prefetch:2 66 | // Where the SCODEF value is the pid of the 'original' process created by this launcher. 67 | // 68 | // This function kills any iexplore.exe process who's command line args match 'SCODEF:pid'. 69 | // On IE11 this will kill the extra process. On older versions, no process will be found. 70 | function killExtraIEProcess (pid, cb) { 71 | var scodef = 'SCODEF:' + pid 72 | 73 | // wmic.exe : http://msdn.microsoft.com/en-us/library/aa394531(v=vs.85).aspx 74 | var wmic = 'wmic.exe Path win32_Process ' + 75 | 'where "Name=\'' + PROCESS_NAME + "' and " + 76 | "CommandLine Like '%" + scodef + '%\'" call Terminate' 77 | 78 | exec(wmic, function (err) { 79 | if (err) { 80 | log.error('Killing extra IE process failed. ' + err) 81 | } else { 82 | log.debug('Killed extra IE process ' + pid) 83 | } 84 | cb() 85 | }) 86 | } 87 | 88 | this._getOptions = function (url) { 89 | var urlObj = urlparse(url, true) 90 | 91 | handleXUaCompatible(args, urlObj) 92 | 93 | // url.format does not want search attribute 94 | delete urlObj.search 95 | url = urlformat(urlObj) 96 | 97 | return flags.concat(url) 98 | } 99 | 100 | var baseOnProcessExit = this._onProcessExit 101 | this._onProcessExit = function (code, errorOutput) { 102 | var pid = this._process.pid 103 | killExtraIEProcess(pid, function () { 104 | if (baseOnProcessExit) { 105 | baseOnProcessExit(code, errorOutput) 106 | } 107 | }) 108 | } 109 | 110 | // this is to expose the function for unit testing 111 | this._getInternetExplorerExe = getInternetExplorerExe 112 | } 113 | 114 | IEBrowser.prototype = { 115 | name: 'IE', 116 | DEFAULT_CMD: { 117 | win32: getInternetExplorerExe() 118 | }, 119 | ENV_CMD: 'IE_BIN' 120 | } 121 | 122 | IEBrowser.$inject = ['baseBrowserDecorator', 'logger', 'args'] 123 | 124 | // Publish di module 125 | // ----------------- 126 | 127 | module.exports = { 128 | 'launcher:IE': ['type', IEBrowser] 129 | } 130 | -------------------------------------------------------------------------------- /test/launcher.spec.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var di = require('di') 3 | var mocks = require('mocks') 4 | 5 | describe('launcher', function () { 6 | var EventEmitter, IELauncher, injector, launcher, module 7 | 8 | beforeEach(function () { 9 | EventEmitter = require('../node_modules/karma/lib/events').EventEmitter 10 | IELauncher = mocks.loadFile(path.join(__dirname, '/../index')).module.exports 11 | module = { 12 | baseBrowserDecorator: ['value', function () {}], 13 | emitter: ['value', new EventEmitter()], 14 | logger: [ 15 | 'value', { 16 | create: function () { 17 | return { 18 | error: function () {}, 19 | debug: function () {} 20 | } 21 | } 22 | } 23 | ], 24 | args: ['value', []] 25 | } 26 | }) 27 | 28 | afterEach(function () { 29 | injector = null 30 | launcher = null 31 | }) 32 | 33 | describe('exports', function () { 34 | it('should export launcher:IE', function (done) { 35 | expect(IELauncher['launcher:IE']).to.defined 36 | done() 37 | }) 38 | }) 39 | 40 | describe('initialization', function () { 41 | beforeEach(function () { 42 | injector = new di.Injector([module, IELauncher]) 43 | launcher = injector.get('launcher:IE') 44 | }) 45 | 46 | it('should initialize name', function (done) { 47 | expect(launcher.name).to.equal('IE') 48 | done() 49 | }) 50 | 51 | it('should initialize ENV_CMD', function (done) { 52 | expect(launcher.ENV_CMD).to.equal('IE_BIN') 53 | done() 54 | }) 55 | 56 | it('should initialize DEFAULT_CMD.win32', function (done) { 57 | expect(launcher.DEFAULT_CMD.win32).to.beDefined 58 | done() 59 | }) 60 | }) 61 | 62 | describe('_getOptions', function () { 63 | var getOptions 64 | 65 | beforeEach(function () { 66 | getOptions = function (url, module) { 67 | injector = new di.Injector([module, IELauncher]) 68 | launcher = injector.get('launcher:IE') 69 | return launcher._getOptions('url') 70 | } 71 | }) 72 | 73 | it('should include args.flags', function (done) { 74 | var options 75 | module.args[1] = { 76 | flags: ['-flag1', '-flag2'] 77 | } 78 | options = getOptions('url', module) 79 | expect(options[0]).to.equal('-flag1') 80 | expect(options[1]).to.equal('-flag2') 81 | done() 82 | }) 83 | 84 | it('should return url as the last flag', function (done) { 85 | var options = getOptions('url', module) 86 | expect(options[options.length - 1]).to.equal('url') 87 | done() 88 | }) 89 | 90 | it('should convert x-ua-compatible arg to encoded url', function (done) { 91 | module.args[1] = { 92 | 'x-ua-compatible': 'browser=mode' 93 | } 94 | var options = getOptions('url', module) 95 | expect(options[options.length - 1]).to.equal('url?x-ua-compatible=browser%3Dmode') 96 | done() 97 | }) 98 | }) 99 | 100 | describe('locating iexplore.exe', function () { 101 | var fsMock, win32Location 102 | 103 | beforeEach(function () { 104 | process.env['PROGRAMW6432'] = path.normalize('/fake/PROGRAMW6432') 105 | process.env['PROGRAMFILES(X86)'] = path.normalize('/fake/PROGRAMFILES(X86)') 106 | process.env['PROGRAMFILES'] = path.normalize('/fake/PROGRAMFILES') 107 | fsMock = mocks.fs.create({ 108 | 'folder1': { 109 | 'Internet Explorer': { 110 | 'iexplore.exe': 1 111 | } 112 | } 113 | }) 114 | 115 | IELauncher = mocks.loadFile(path.join(__dirname, '/../index'), { 116 | fs: fsMock 117 | }).module.exports 118 | 119 | win32Location = function () { 120 | injector = new di.Injector([module, IELauncher]) 121 | launcher = injector.get('launcher:IE') 122 | return launcher._getInternetExplorerExe() 123 | } 124 | }) 125 | 126 | it('should locate in PROGRAMW6432', function (done) { 127 | process.env['' + 'PROGRAMW6432'] = path.normalize('/folder1') 128 | expect(win32Location()).to.equal(path.normalize('/folder1/Internet Explorer/iexplore.exe')) 129 | done() 130 | }) 131 | 132 | it('should locate in PROGRAMFILES(X86)', function (done) { 133 | process.env['' + 'PROGRAMFILES(X86)'] = path.normalize('/folder1') 134 | expect(win32Location()).to.equal(path.normalize('/folder1/Internet Explorer/iexplore.exe')) 135 | done() 136 | }) 137 | 138 | it('should locate in PROGRAMFILES', function (done) { 139 | process.env['' + 'PROGRAMFILES'] = path.normalize('/folder1') 140 | expect(win32Location()).to.equal(path.normalize('/folder1/Internet Explorer/iexplore.exe')) 141 | done() 142 | }) 143 | 144 | it('should return undefined when not found', function (done) { 145 | expect(win32Location()).to.equal(void 0) 146 | done() 147 | }) 148 | }) 149 | 150 | describe('_onProcessExit', function () { 151 | var childProcessCmd, onProcessExit 152 | 153 | beforeEach(function () { 154 | onProcessExit = function () { 155 | var childProcessMock 156 | childProcessMock = { 157 | exec: function (cmd, cb) { 158 | childProcessCmd = cmd 159 | cb() 160 | } 161 | } 162 | 163 | IELauncher = mocks.loadFile(path.join(__dirname, '/../index'), { 164 | child_process: childProcessMock 165 | }).module.exports 166 | injector = new di.Injector([module, IELauncher]) 167 | launcher = injector.get('launcher:IE') 168 | launcher._process = { 169 | pid: 10 170 | } 171 | launcher._onProcessExit(1, 2) 172 | } 173 | }) 174 | 175 | it('should call wmic with process ID', function (done) { 176 | onProcessExit() 177 | expect(childProcessCmd).to.equal( 178 | 'wmic.exe Path win32_Process where ' + 179 | '"Name=\'iexplore.exe\' and CommandLine Like \'%SCODEF:10%\'" call Terminate' 180 | ) 181 | done() 182 | }) 183 | }) 184 | }) 185 | --------------------------------------------------------------------------------