From fd91564bde8cd7c50a5c38e333c63ffad2167245 Mon Sep 17 00:00:00 2001 From: "Nick M. Mitchell" Date: Sun, 18 Jun 2017 20:56:17 -0400 Subject: [PATCH 1/2] update lib/devtools to set window size and position on initialization this avoids the flashing in the current impl, as the size is set after the window has already opened this also adds the ability for callers to specify the window size, whereas before the height was hardwired --- lib/devtools.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/devtools.js b/lib/devtools.js index 7fcadef..483e245 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 window + } + return window.getSize() .then((size) => window.setSize(size.width, 450)) } From f090e1e2232191214656f2e07964cda3aabde12e Mon Sep 17 00:00:00 2001 From: "Nick M. Mitchell" Date: Sun, 18 Jun 2017 21:11:51 -0400 Subject: [PATCH 2/2] fix for missing Promise.resolve() in the _resize update --- lib/devtools.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/devtools.js b/lib/devtools.js index 483e245..9958b30 100644 --- a/lib/devtools.js +++ b/lib/devtools.js @@ -80,7 +80,7 @@ Devtools.prototype._resize = function () { // this may now be done on initialization, above if (this.options.width && this.options.height) { - return window + return Promise.resolve(window) } return window.getSize()