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

Electron upgrade #5849

Merged
merged 25 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1cae916
electron@7.x
flotwig Dec 2, 2019
db2d521
node12.8.1-chrome78-ff70
flotwig Dec 2, 2019
57fe764
Revert "node12.8.1-chrome78-ff70" for now
flotwig Dec 2, 2019
2bef520
update sendCommand to log on all sendcommands
flotwig Dec 2, 2019
27bdd97
promisification in 6.x
flotwig Dec 2, 2019
8097a81
Revert "Revert "node12.8.1-chrome78-ff70" for now"
flotwig Dec 2, 2019
527b203
Merge branch 'decaf-server-lib-automation' into electron-upgrade
flotwig Dec 2, 2019
0282b98
fix sendcommand
flotwig Dec 2, 2019
12e5e48
fix cdp in electron
flotwig Dec 2, 2019
9710805
fix desktop-gui test
flotwig Dec 2, 2019
176b18c
skip tests that will be fixed by #4973
flotwig Dec 2, 2019
3d996ff
bump MAX_ALLOWED_FILE_SIZE :/
flotwig Dec 2, 2019
dc577e9
update electron browser spec
flotwig Dec 2, 2019
50320d8
make new dialog code null-proof
flotwig Dec 2, 2019
226fd6e
add failing e2e test for issue 5475
brian-mann Dec 2, 2019
323bae5
bump electron packager
brian-mann Dec 2, 2019
0850372
add e2e snapshot
brian-mann Dec 2, 2019
bfc9005
Merge branch 'develop' into electron-upgrade
flotwig Dec 2, 2019
0bf8621
update deprecated electron getters/setters
flotwig Dec 4, 2019
77b362e
build and test on Mac
bahmutov Dec 4, 2019
45d3bd5
Merge remote-tracking branch 'origin/develop' into electron-upgrade
flotwig Dec 6, 2019
0044db9
move macbuildfilters to top
flotwig Dec 6, 2019
e6d64b9
7.1.3
flotwig Dec 6, 2019
15ca743
Merge branch 'develop' into electron-upgrade
flotwig Dec 10, 2019
decb35b
electron@7.1.4
flotwig Dec 11, 2019
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
32 changes: 15 additions & 17 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
version: 2.1

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
# so just add your branch to the list here to build and test on Mac
macBuildFilters: &macBuildFilters
filters:
branches:
only:
- develop

defaults: &defaults
parallelism: 1
working_directory: ~/cypress
Expand All @@ -19,11 +28,12 @@ defaults: &defaults
COLUMNS: 100
LINES: 24


executors:
# the Docker image with Cypress dependencies and Chrome browser
cy-doc:
docker:
- image: cypress/browsers:node12.0.0-chrome73
- image: cypress/browsers:node12.8.1-chrome78-ff70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PR updating the Node version? Aren't we using 12.0.0, don't we want to test against that?

Also, if this is a convenience thing - probably highlights why our docker images combinations are problematic for our own users. :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR updates the bundled Node version to 12.8.1 (Electron 5 -> 7). The node version we use in CI needs to match this, since the unit + integrations tests (of Electron code) all run in node in CI, not electron. We could use electron-mocha to eliminate this requirement, but currently that's the way it is.

environment:
PLATFORM: linux

Expand Down Expand Up @@ -1120,20 +1130,14 @@ mac-workflow: &mac-workflow
- build:
name: Mac build
executor: mac
filters:
branches:
only:
- develop
<<: *macBuildFilters

- lint:
name: Mac lint
executor: mac
<<: *macBuildFilters
requires:
- Mac build
filters:
branches:
only:
- develop

# maybe run unit tests?

Expand Down Expand Up @@ -1162,10 +1166,7 @@ mac-workflow: &mac-workflow
name: Mac binary
context: org-global
executor: mac
filters:
branches:
only:
- develop
<<: *macBuildFilters
requires:
- Mac build

Expand All @@ -1183,10 +1184,7 @@ mac-workflow: &mac-workflow
- test-kitchensink:
name: Test Mac Kitchensink
executor: mac
filters:
branches:
only:
- develop
<<: *macBuildFilters
requires:
- Mac build

Expand Down
1 change: 1 addition & 0 deletions packages/desktop-gui/src/specs/specs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $max-nesting-level: 14;
display: flex;
flex-direction: column;
width: 100%;
min-height: 0;

.empty-well code {
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,8 @@ describe "src/cy/commands/navigation", ->

expect(Cookie.get("__cypress.initial")).to.be.undefined

it "does not reset the timeout", (done) ->
## TODO: broken - https://github.com/cypress-io/cypress/issues/4973
it.skip "does not reset the timeout", (done) ->
cy.timeout(1000)

## previously loading would reset the timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ describe "redirection", ->
expect(@logs[2].get("name")).to.eq("page load")
expect(@logs[3].get("name")).to.eq("new url")

context "javascript", ->
## TODO: broken - https://github.com/cypress-io/cypress/issues/4973
context.skip "javascript", ->
it "binds to the new page after a timeout", ->
cy
.visit("/fixtures/js-redirect-timeout.html")
Expand Down
4 changes: 2 additions & 2 deletions packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"@cypress/icons": "0.7.0",
"bluebird": "3.5.3",
"debug": "4.1.1",
"electron-packager": "13.1.1",
"electron-packager": "14.1.1",
"fs-extra": "8.1.0",
"lodash": "4.17.15",
"minimist": "1.2.0"
},
"devDependencies": {
"electron": "5.0.10",
"electron": "7.1.4",
"mocha": "3.5.3"
},
"files": [
Expand Down
109 changes: 109 additions & 0 deletions packages/server/__snapshots__/3_issue_5475_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
exports['e2e issue 5475 history pushState hangs / fails when remote debugging port cannot be connected to'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 2 found (issue_5475_spec_1.js, issue_5475_spec_2.js) │
│ Searched: cypress/integration/issue_5475* │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: issue_5475_spec_1.js (1 of 2)


issue #5475
✓ hangs on next spec after modifying history.pushState


1 passing


(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: issue_5475_spec_1.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/issue_5475_spec_1.js.mp4 (X second)


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: issue_5475_spec_2.js (2 of 2)


issue #5475
1) hangs on next spec after modifying history.pushState


0 passing
1 failing

1) issue #5475 hangs on next spec after modifying history.pushState:
Error: foo
[stack trace lines]




(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 2 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: issue_5475_spec_2.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


(Screenshots)

- /XXX/XXX/XXX/cypress/screenshots/issue_5475_spec_2.js/hangs.png (1000x660)
- /XXX/XXX/XXX/cypress/screenshots/issue_5475_spec_2.js/issue #5475 -- hangs on ne (1280x720)
xt spec after modifying history.pushState (failed).png


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/issue_5475_spec_2.js.mp4 (X second)


====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ issue_5475_spec_1.js XX:XX 1 1 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ✖ issue_5475_spec_2.js XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 2 failed (50%) XX:XX 2 1 1 - -


`
73 changes: 40 additions & 33 deletions packages/server/lib/browsers/electron.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_ = require("lodash")
EE = require("events")
net = require("net")
Promise = require("bluebird")
Bluebird = require("bluebird")
debug = require("debug")("cypress:server:browsers:electron")
{ cors } = require("@packages/network")
menu = require("../gui/menu")
Expand Down Expand Up @@ -32,20 +32,12 @@ tryToCall = (win, method) ->
debug("got error calling window method:", err.stack)

getAutomation = (win) ->
sendDebuggerCommand = (message, data) ->
## wrap in bluebird
tryToCall win, Promise.method ->
debug('debugger: sending %s with params %o', message, data)
win.webContents.debugger.sendCommand(message, data)
.tap (res) ->
if debug.enabled && res.data && res.data.length > 100
res = _.clone(res)
res.data = res.data.slice(0, 100) + ' [truncated]'
debug('debugger: received response to %s: %o', message, res)
.tapCatch (err) ->
debug('debugger: received error on %s: %o', messsage, err)
sendCommand = Bluebird.method (args...) =>
tryToCall win, ->
win.webContents.debugger.sendCommand
.apply(win.webContents.debugger, args)

CdpAutomation(sendDebuggerCommand)
CdpAutomation(sendCommand)

module.exports = {
_defaultOptions: (projectRoot, state, options) ->
Expand Down Expand Up @@ -86,9 +78,11 @@ module.exports = {

_getAutomation: getAutomation

_render: (url, projectRoot, options = {}) ->
_render: (url, projectRoot, automation, options = {}) ->
win = Windows.create(projectRoot, options)

automation.use(getAutomation(win))

@_launch(win, url, options)

_launchChild: (e, url, parent, projectRoot, state, options) ->
Expand Down Expand Up @@ -121,7 +115,7 @@ module.exports = {
win.on e, ->
debug("%s fired on the BrowserWindow %o", e, { browserWindowUrl: url })

Promise.try =>
Bluebird.try =>
@_attachDebugger(win.webContents)
.then =>
if ua = options.userAgent
Expand All @@ -131,7 +125,7 @@ module.exports = {
if ps = options.proxyServer
@_setProxy(win.webContents, ps)

Promise.join(
Bluebird.join(
setProxy(),
@_clearCache(win.webContents)
)
Expand All @@ -148,6 +142,23 @@ module.exports = {
debug("debugger attached")
catch err
debug("debugger attached failed %o", { err })
throw err

originalSendCommand = webContents.debugger.sendCommand
jennifer-shehane marked this conversation as resolved.
Show resolved Hide resolved

webContents.debugger.sendCommand = (message, data) ->
debug('debugger: sending %s with params %o', message, data)

originalSendCommand.call(webContents.debugger, message, data)
.then (res) ->
if debug.enabled && res.data && res.data.length > 100
res = _.clone(res)
res.data = res.data.slice(0, 100) + ' [truncated]'
debug('debugger: received response to %s: %o', message, res)
res
.catch (err) ->
debug('debugger: received error on %s: %o', messsage, err)
throw err

webContents.debugger.sendCommand('Browser.getVersion')

Expand All @@ -160,7 +171,7 @@ module.exports = {

_enableDebugger: (webContents) ->
debug("debugger: enable Console and Network")
Promise.join(
Bluebird.join(
webContents.debugger.sendCommand("Console.enable"),
webContents.debugger.sendCommand("Network.enable")
)
Expand All @@ -177,24 +188,22 @@ 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)
## set both because why not
webContents.setUserAgent(userAgent)
webContents.userAgent = userAgent
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 All @@ -215,7 +224,7 @@ module.exports = {

debug("browser window options %o", _.omitBy(options, _.isFunction))

Promise
Bluebird
.try =>
## bail if we're not registered to this event
return options if not plugins.has("before:browser:launch")
Expand All @@ -230,15 +239,13 @@ module.exports = {
.then (options) =>
debug("launching browser window to url: %s", url)

@_render(url, projectRoot, options)
@_render(url, projectRoot, automation, options)
.then (win) =>
## cause the webview to receive focus so that
## native browser focus + blur events fire correctly
## https://github.com/cypress-io/cypress/issues/1939
tryToCall(win, "focusOnWebView")

automation.use(getAutomation(win))

events = new EE

win.once "closed", ->
Expand Down
Loading