Skip to content

Commit

Permalink
Add "--proxy-bypass-list=<-loopback>" flag to default chrome args (#3049
Browse files Browse the repository at this point in the history
)

* Add "--proxy-bypass-list=<-loopback>" flag to default chrome args

* Add --proxy-bypass-list=<-loopback> to Electron command line switch

- Since this is supported switch in Electron
https://electronjs.org/docs/api/chrome-command-line-switches#--proxy-byp
ass-listhosts

* Add issue comment to electron switch

* Wrote check to ensure loopback proxy bypass is only used on version 72+ of chromium

- Wrote chrome test

* pull in dev

* Set proxy bypass rules within Electron session, not browser window
  • Loading branch information
jennifer-shehane authored and brian-mann committed Jan 30, 2019
1 parent acceb79 commit a1c6e90
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/server/lib/browsers/chrome.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ utils = require("./utils")

LOAD_EXTENSION = "--load-extension="
CHROME_VERSIONS_WITH_BUGGY_ROOT_LAYER_SCROLLING = "66 67".split(" ")
CHROME_VERSION_INTRODUCING_PROXY_BYPASS_ON_LOOPBACK = 72

pathToExtension = extension.getPathToExtension()
pathToTheme = extension.getPathToTheme()
Expand Down Expand Up @@ -157,6 +158,11 @@ module.exports = {
if majorVersion in CHROME_VERSIONS_WITH_BUGGY_ROOT_LAYER_SCROLLING
args.push("--disable-blink-features=RootLayerScrolling")

## https://chromium.googlesource.com/chromium/src/+/da790f920bbc169a6805a4fb83b4c2ab09532d91
## https://github.com/cypress-io/cypress/issues/1872
if majorVersion >= CHROME_VERSION_INTRODUCING_PROXY_BYPASS_ON_LOOPBACK
args.push("--proxy-bypass-list=<-loopback>")

args

open: (browserName, url, options = {}, automation) ->
Expand Down
4 changes: 4 additions & 0 deletions packages/server/lib/browsers/electron.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ module.exports = {
new Promise (resolve) ->
webContents.session.setProxy({
proxyRules: proxyServer
## this should really only be necessary when
## running Chromium versions >= 72
## https://github.com/cypress-io/cypress/issues/1872
proxyBypassRules: "<-loopback>"
}, resolve)

open: (browserName, url, options = {}, automation) ->
Expand Down
2 changes: 2 additions & 0 deletions packages/server/lib/util/ci_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,11 @@ const commitDefaults = function (existingInfo) {
debug(existingInfo)

const providerName = provider()

debug('detected provider name: %s', providerName)

let commitParamsObj = commitParams()

if (!commitParamsObj) {
debug('could not get commit param object, using empty one')
commitParamsObj = {}
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/e2e/4_window_open_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe.skip "e2e window.open", ->

## skipping this for now due to
## snap-shot-it monkey patching
## .only causing test failures
## causing test failures
# it "passes", ->
# e2e.exec(@, {
# spec: "window_open_spec.coffee"
Expand Down
21 changes: 21 additions & 0 deletions packages/server/test/unit/browsers/chrome_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,24 @@ describe "lib/browsers/chrome", ->
disabledRootLayerScrolling("66", true)
disabledRootLayerScrolling("67", true)
disabledRootLayerScrolling("68", false)

## https://github.com/cypress-io/cypress/issues/1872
it "adds <-loopback> proxy bypass rule in version 72+", ->
arg = "--proxy-bypass-list=<-loopback>"

chromeVersionHasLoopback = (version, bool) ->
args = chrome._getArgs({
browser: {
majorVersion: version
}
})

if bool
expect(args).to.include(arg)
else
expect(args).not.to.include(arg)

chromeVersionHasLoopback("71", false)
chromeVersionHasLoopback("72", true)
chromeVersionHasLoopback("73", true)

1 change: 1 addition & 0 deletions packages/server/test/unit/browsers/electron_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,5 @@ describe "lib/browsers/electron", ->
.then ->
expect(webContents.session.setProxy).to.be.calledWith({
proxyRules: "proxy rules"
proxyBypassRules: "<-loopback>"
})

0 comments on commit a1c6e90

Please sign in to comment.