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

[WIP] Electron 6.0.10 #5193

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ executors:
# the Docker image with Cypress dependencies and Chrome browser
cy-doc:
docker:
- image: cypress/browsers:node12.0.0-chrome73
- image: cypress/browsers:node12.4.0-chrome76
environment:
PLATFORM: linux

Expand Down
2 changes: 1 addition & 1 deletion packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"minimist": "1.2.0"
},
"devDependencies": {
"electron": "5.0.10",
"electron": "6.0.10",
"mocha": "3.5.3"
},
"files": [
Expand Down
2 changes: 0 additions & 2 deletions packages/server/__snapshots__/8_reporters_spec.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,6 @@ Error: this reporter threw an error
at stack trace line
at stack trace line
at stack trace line
at stack trace line
at stack trace line

Learn more at https://on.cypress.io/reporters

Expand Down
40 changes: 20 additions & 20 deletions packages/server/lib/browsers/electron.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ getAutomation = (win) ->
.then ->
cookieToBeCleared
when "is:automation:client:connected"
true
tryToCall(win, 'isDestroyed') == false
when "take:screenshot"
tryToCall(win, 'capturePage')
.then _.partialRight(_.invoke, 'toDataURL')
Expand Down Expand Up @@ -194,16 +194,18 @@ module.exports = {

_attachDebugger: (webContents) ->
originalSendCommand = webContents.debugger.sendCommand

webContents.debugger.sendCommand = (message, data = {}) ->
new Promise (resolve, reject) =>
debug('debugger: sending %s %o', message, data)

originalSendCommand.call webContents.debugger, message, data, (err, result) =>
debug("debugger: received response for %s: %o", message, { err, result })
if _.isEmpty(err)
return resolve(result)
reject(err)
debug('debugger: sending %s %o', message, data)

originalSendCommand
.call(webContents.debugger, message, data)
.then (result) =>
debug("debugger: received response for %s: result: %o", message, result)
result
.catch (err) =>
debug("debugger: received error on %s: result: %o", message, err)
throw err

try
webContents.debugger.attach()
debug("debugger attached")
Expand Down Expand Up @@ -238,8 +240,7 @@ module.exports = {

_clearCache: (webContents) ->
debug("clearing cache")
Promise.fromCallback (cb) =>
webContents.session.clearCache(cb)
webContents.session.clearCache()

_setUserAgent: (webContents, userAgent) ->
debug("setting user agent to:", userAgent)
Expand All @@ -248,14 +249,13 @@ module.exports = {
webContents.session.setUserAgent(userAgent)

_setProxy: (webContents, proxyServer) ->
Promise.fromCallback (cb) =>
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>"
}, cb)
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>"
})

open: (browser, url, options = {}, automation) ->
{ projectRoot, isTextTerminal } = options
Expand Down
9 changes: 3 additions & 6 deletions packages/server/lib/gui/dialog.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ module.exports = {
properties: ["openDirectory"]
}

new Promise (resolve, reject) ->
dialog.showOpenDialog props, (paths = []) ->
process.nextTick ->
## return the first path since there can only ever
## be a single directory selection
resolve(paths[0])
dialog.showOpenDialog(props)
.then ({ filePaths }) ->
return filePaths[0]
}
9 changes: 4 additions & 5 deletions packages/server/lib/gui/windows.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ setWindowProxy = (win) ->
if not process.env.HTTP_PROXY
return

return new Promise (resolve) ->
win.webContents.session.setProxy({
proxyRules: process.env.HTTP_PROXY
proxyBypassRules: process.env.NO_PROXY
}, resolve)
win.webContents.session.setProxy({
proxyRules: process.env.HTTP_PROXY
proxyBypassRules: process.env.NO_PROXY
})

module.exports = {
reset: ->
Expand Down
6 changes: 3 additions & 3 deletions packages/server/test/integration/cypress_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,12 @@ describe "lib/cypress", ->
debugger: {
on: sinon.stub()
attach: sinon.stub()
sendCommand: sinon.stub().callsArg(2)
sendCommand: sinon.stub().resolves()
}
setUserAgent: sinon.stub()
session: {
clearCache: sinon.stub().yieldsAsync()
setProxy: sinon.stub().yieldsAsync()
clearCache: sinon.stub().resolves()
setProxy: sinon.stub().resolves()
setUserAgent: sinon.stub()
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/server/test/unit/browsers/electron_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ describe "lib/browsers/electron", ->
it "sets proxy rules for webContents", ->
webContents = {
session: {
setProxy: sinon.stub().callsArg(1)
setProxy: sinon.stub().resolves()
}
}

Expand All @@ -366,6 +366,8 @@ describe "lib/browsers/electron", ->
@sendCommand.throws()
.withArgs('Browser.getVersion').resolves()

electron._attachDebugger(@win.webContents)

@onRequest = electron._getAutomation(@win).onRequest

describe "get:cookies", ->
Expand Down
6 changes: 4 additions & 2 deletions packages/server/test/unit/gui/auth_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ describe('lib/gui/auth', function () {

it('returns a promise that is fulfilled when openExternal succeeds', function () {
sinon.stub(electron.shell, 'openExternal').resolves()
const sendWarning = sinon.stub()

return auth._launchNativeAuth(REDIRECT_URL)
return auth._launchNativeAuth(REDIRECT_URL, sendWarning)
.then(() => {
expect(electron.shell.openExternal).to.be.calledWithMatch(REDIRECT_URL)
expect(sendWarning).to.not.be.called
})
})

it('is still fulfilled when openExternal fails, but sendWarning is called', function () {
sinon.stub(electron.shell, 'openExternal').rejects()
sinon.stub(electron.shell, 'openExternal').rejects(new Error)
const sendWarning = sinon.stub()

return auth._launchNativeAuth(REDIRECT_URL, sendWarning)
Expand Down
10 changes: 6 additions & 4 deletions packages/server/test/unit/gui/dialog_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Windows = require("#{root}../lib/gui/windows")
describe "gui/dialog", ->
context ".show", ->
beforeEach ->
@showOpenDialog = electron.dialog.showOpenDialog = sinon.stub()
@showOpenDialog = electron.dialog.showOpenDialog = sinon.stub().resolves({
filePaths: []
})

it "calls dialog.showOpenDialog with args", ->
dialog.show()
Expand All @@ -16,13 +18,13 @@ describe "gui/dialog", ->
})

it "resolves with first path", ->
@showOpenDialog.yields(["foo", "bar"])
@showOpenDialog.resolves({
filePaths: ["foo", "bar"]
})

dialog.show().then (ret) ->
expect(ret).to.eq("foo")

it "handles null paths", ->
@showOpenDialog.yields(null)

dialog.show().then (ret) ->
expect(ret).to.eq(undefined)
2 changes: 1 addition & 1 deletion scripts/run-docker-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set e+x

echo "This script should be run from cypress's root"

name=cypress/browsers:node12.0.0-chrome73
name=cypress/browsers:node12.4.0-chrome76
echo "Pulling CI container $name"

docker pull $name
Expand Down