diff --git a/lib/devtools.js b/lib/devtools.js index 7fcadef..9958b30 100644 --- a/lib/devtools.js +++ b/lib/devtools.js @@ -29,8 +29,18 @@ const Devtools = module.exports = function (options) { log.silly('devtools: create') this.options = options || {} + + // the caller make have asked us to set the window size and position + const chromeOptions = new chrome.Options() + if (this.options.width && this.options.height) { + chromeOptions.addArguments([`--window-size=${this.options.width},${this.options.height}`]) + } + if (this.options.windowPosition) { + chromeOptions.addArguments([`--window-position=${this.options.windowPosition.left},${this.options.windowPosition.top}`]) + } + this.service = new chrome.ServiceBuilder(chromedriver.path).build() - this.driver = chrome.Driver.createSession(new chrome.Options(), this.service) + this.driver = chrome.Driver.createSession(chromeOptions, this.service) } Devtools.prototype.open = function (debuggerUrl, options) { @@ -68,6 +78,11 @@ Devtools.prototype._resize = function () { const window = this.driver.manage().window() + // this may now be done on initialization, above + if (this.options.width && this.options.height) { + return Promise.resolve(window) + } + return window.getSize() .then((size) => window.setSize(size.width, 450)) }