Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
}
Expand Down