Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow overriding of default debug port #191

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion index.js
Expand Up @@ -165,7 +165,15 @@ ChromeBrowser.prototype = {
ChromeBrowser.$inject = ['baseBrowserDecorator', 'args']

function headlessGetOptions (url, args, parent) {
return parent.call(this, url, args).concat(['--headless', '--disable-gpu', '--remote-debugging-port=9222'])
var mergedArgs = parent.call(this, url, args).concat(['--headless', '--disable-gpu'])

var isRemoteDebuggingFlag = function (flag) {
return flag.indexOf('--remote-debugging-port=') !== -1
}

return mergedArgs.some(isRemoteDebuggingFlag)
? mergedArgs
: mergedArgs.concat(['--remote-debugging-port=9222'])
}

var ChromeHeadlessBrowser = function (baseBrowserDecorator, args) {
Expand Down
15 changes: 15 additions & 0 deletions test/jsflags.spec.js
Expand Up @@ -69,4 +69,19 @@ describe('headlessGetOptions', function () {
'--remote-debugging-port=9222'
])
})

it('should not overwrite custom remote-debugging-port', function () {
var parent = sinon.stub().returns(
['-incognito', '--remote-debugging-port=9333']
)
var context = {}
var url = 'http://localhost:9876'
var args = {}
expect(headlessGetOptions.call(context, url, args, parent)).to.be.eql([
'-incognito',
'--remote-debugging-port=9333',
'--headless',
'--disable-gpu'
])
})
})