Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1c6e90

Browse files
jennifer-shehanebrian-mann
authored andcommitted
Add "--proxy-bypass-list=<-loopback>" flag to default chrome args (cypress-io#3049)
* 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
1 parent acceb79 commit a1c6e90

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

packages/server/lib/browsers/chrome.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ utils = require("./utils")
1313

1414
LOAD_EXTENSION = "--load-extension="
1515
CHROME_VERSIONS_WITH_BUGGY_ROOT_LAYER_SCROLLING = "66 67".split(" ")
16+
CHROME_VERSION_INTRODUCING_PROXY_BYPASS_ON_LOOPBACK = 72
1617

1718
pathToExtension = extension.getPathToExtension()
1819
pathToTheme = extension.getPathToTheme()
@@ -157,6 +158,11 @@ module.exports = {
157158
if majorVersion in CHROME_VERSIONS_WITH_BUGGY_ROOT_LAYER_SCROLLING
158159
args.push("--disable-blink-features=RootLayerScrolling")
159160

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

162168
open: (browserName, url, options = {}, automation) ->

packages/server/lib/browsers/electron.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ module.exports = {
148148
new Promise (resolve) ->
149149
webContents.session.setProxy({
150150
proxyRules: proxyServer
151+
## this should really only be necessary when
152+
## running Chromium versions >= 72
153+
## https://github.com/cypress-io/cypress/issues/1872
154+
proxyBypassRules: "<-loopback>"
151155
}, resolve)
152156

153157
open: (browserName, url, options = {}, automation) ->

packages/server/lib/util/ci_provider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,11 @@ const commitDefaults = function (existingInfo) {
408408
debug(existingInfo)
409409

410410
const providerName = provider()
411+
411412
debug('detected provider name: %s', providerName)
412413

413414
let commitParamsObj = commitParams()
415+
414416
if (!commitParamsObj) {
415417
debug('could not get commit param object, using empty one')
416418
commitParamsObj = {}

packages/server/test/e2e/4_window_open_spec.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe.skip "e2e window.open", ->
55

66
## skipping this for now due to
77
## snap-shot-it monkey patching
8-
## .only causing test failures
8+
## causing test failures
99
# it "passes", ->
1010
# e2e.exec(@, {
1111
# spec: "window_open_spec.coffee"

packages/server/test/unit/browsers/chrome_spec.coffee

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,24 @@ describe "lib/browsers/chrome", ->
139139
disabledRootLayerScrolling("66", true)
140140
disabledRootLayerScrolling("67", true)
141141
disabledRootLayerScrolling("68", false)
142+
143+
## https://github.com/cypress-io/cypress/issues/1872
144+
it "adds <-loopback> proxy bypass rule in version 72+", ->
145+
arg = "--proxy-bypass-list=<-loopback>"
146+
147+
chromeVersionHasLoopback = (version, bool) ->
148+
args = chrome._getArgs({
149+
browser: {
150+
majorVersion: version
151+
}
152+
})
153+
154+
if bool
155+
expect(args).to.include(arg)
156+
else
157+
expect(args).not.to.include(arg)
158+
159+
chromeVersionHasLoopback("71", false)
160+
chromeVersionHasLoopback("72", true)
161+
chromeVersionHasLoopback("73", true)
162+

packages/server/test/unit/browsers/electron_spec.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,5 @@ describe "lib/browsers/electron", ->
351351
.then ->
352352
expect(webContents.session.setProxy).to.be.calledWith({
353353
proxyRules: "proxy rules"
354+
proxyBypassRules: "<-loopback>"
354355
})

0 commit comments

Comments
 (0)