From 4c6d784af1902c49718d073b47c58bb3f44b69d5 Mon Sep 17 00:00:00 2001 From: Christopher Currie Date: Wed, 22 Jan 2014 10:47:02 -0800 Subject: [PATCH] Support 64-bit IE and isolate environment. This patch tries to auto-detect 64-bit IE by checking for the appropriate environment variables. It also improves reliability of the tests by disabling extensions and using "InPrivate" mode to ignore existing user data. Addresses #1, #2, #4, and possibly #8. --- index.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3088926..e7a86cf 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,38 @@ -var IEBrowser = function(baseBrowserDecorator) { +var fs = require('fs'); + +var IEBrowser = function(baseBrowserDecorator, args) { baseBrowserDecorator(this); + + args = args || {}; + var flags = args.flags || []; + + this._getOptions = function(url) { + return [ + '-extoff', + '-private' + ].concat(flags, [url]); + } }; +function getInternetExplorerExe() { + var suffix = '\\Internet Explorer\\iexplore.exe', + prefixes = [process.env['PROGRAMW6432'], process.env['PROGRAMFILES(X86)'], process.env['PROGRAMFILES']], + prefix, i; + + for (i = 0; i < prefixes.length; i++) { + prefix = prefixes[i]; + if (prefix && fs.existsSync(prefix + suffix)) { + return prefix + suffix; + } + } + + throw new Error("Internet Explorer not found"); +} + IEBrowser.prototype = { name: 'IE', DEFAULT_CMD: { - win32: process.env.ProgramFiles + '\\Internet Explorer\\iexplore.exe' + win32: getInternetExplorerExe() }, ENV_CMD: 'IE_BIN' };