From 090cbcb3fd228fa33883fd26faf10621419ebd18 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Fri, 31 May 2019 10:15:12 -0400 Subject: [PATCH 1/5] upgrade to electron 3.1.8 and node 10.2.1 --- .gitignore | 6 +- .node-version | 2 +- appveyor.yml | 2 +- circle.yml | 2 +- cli/package.json | 2 +- package.json | 2 +- packages/electron/package.json | 2 +- packages/example/gulpfile.js | 50 +++--- packages/example/package.json | 5 +- .../https-proxy/test/helpers/proxy.coffee | 10 +- .../test/integration/proxy_spec.coffee | 2 +- packages/network/test/unit/agent_spec.ts | 4 +- ...caught_uncaught_hook_errors_spec.coffee.js | 1 - .../__snapshots__/2_config_spec.coffee.js | 1 - .../2_form_submissions_spec.coffee.js | 1 - .../__snapshots__/3_issue_173_spec.coffee.js | 1 - .../__snapshots__/3_plugins_spec.coffee.js | 1 + .../__snapshots__/4_promises_spec.coffee.js | 1 - .../__snapshots__/4_request_spec.coffee.js | 5 - .../5_spec_isolation_spec.coffee.js | 40 ++--- .../__snapshots__/5_stdout_spec.coffee.js | 2 - .../5_task_not_registered_spec.coffee.js | 1 - .../__snapshots__/6_task_spec.coffee.js | 7 +- .../__snapshots__/6_visit_spec.coffee.js | 14 -- .../__snapshots__/run_plugins_spec.coffee.js | 26 +-- packages/server/index.js | 6 - packages/server/lib/logger.coffee | 8 +- packages/server/lib/open_project.coffee | 2 +- packages/server/lib/plugins/child/index.js | 5 - packages/server/lib/plugins/index.coffee | 14 +- packages/server/lib/server.coffee | 31 +--- .../test/integration/server_spec.coffee | 1 - .../test/integration/websockets_spec.coffee | 12 +- packages/server/test/unit/request_spec.coffee | 2 +- packages/server/test/unit/timers_spec.coffee | 112 ------------ packages/server/timers/child.js | 22 --- packages/server/timers/parent.js | 166 ------------------ scripts/run-docker-local.sh | 4 +- 38 files changed, 109 insertions(+), 466 deletions(-) delete mode 100644 packages/server/test/unit/timers_spec.coffee delete mode 100644 packages/server/timers/child.js delete mode 100644 packages/server/timers/parent.js diff --git a/.gitignore b/.gitignore index 10dd2b4a9bf2..312e2cfd336a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,9 @@ packages/desktop-gui/src/jsconfig.json # from driver packages/driver/test/cypress/videos +# from reporter +packages/reporter/test/cypress/videos + # from example packages/example/app packages/example/build @@ -36,9 +39,6 @@ packages/example/cypress/videos packages/example/cypress/fixtures/profile.json packages/example/cypress/fixtures/users.json -# from driver -packages/driver/test/cypress/videos - # from server packages/server/.cy packages/server/.projects diff --git a/.node-version b/.node-version index 22333f1ec56f..26ee5b054e1a 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -8.9.3 +10.2.1 diff --git a/appveyor.yml b/appveyor.yml index 9ee35188cfca..e784ed744dde 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ branches: # https://www.appveyor.com/docs/lang/nodejs-iojs/ environment: # use matching version of Node.js - nodejs_version: "8.9.3" + nodejs_version: "10.2.1" # encode secure variables which will NOT be used # in pull requests # https://www.appveyor.com/docs/build-configuration/#secure-variables diff --git a/circle.yml b/circle.yml index 0e606089f041..57c737385f9d 100644 --- a/circle.yml +++ b/circle.yml @@ -23,7 +23,7 @@ executors: # the Docker image with Cypress dependencies and Chrome browser cy-doc: docker: - - image: cypress/browsers:node8.9.3-chrome73 + - image: cypress/browsers:node10.2.1-chrome74 environment: PLATFORM: linux diff --git a/cli/package.json b/cli/package.json index b9cab9ff7ec2..77a48b3c7f88 100644 --- a/cli/package.json +++ b/cli/package.json @@ -108,4 +108,4 @@ "index.js", "types/**/*.d.ts" ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index ec646369eb27..79d0d0db975a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "Cypress.io end to end testing tool", "private": true, "engines": { - "node": ">=8.9.3" + "node": ">=10.2.1" }, "scripts": { "prestart": "npm run check-deps-pre", diff --git a/packages/electron/package.json b/packages/electron/package.json index 76cd65552f17..54e60c939a93 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -1,7 +1,7 @@ { "name": "@packages/electron", "version": "0.0.0", - "electronVersion": "2.0.18", + "electronVersion": "3.1.8", "private": true, "main": "index.js", "scripts": { diff --git a/packages/example/gulpfile.js b/packages/example/gulpfile.js index 02b676bde882..d0db94ca50c7 100644 --- a/packages/example/gulpfile.js +++ b/packages/example/gulpfile.js @@ -1,11 +1,10 @@ -let gulp = require('gulp') -let ghPages = require('gulp-gh-pages-will') -let clean = require('gulp-clean') -let RevAll = require('gulp-rev-all') -let runSequence = require('run-sequence') - -gulp.task('assets', function () { - let revAllOpts = { +const gulp = require('gulp') +const ghPages = require('gulp-gh-pages-will') +const gulpClean = require('gulp-clean') +const RevAll = require('gulp-rev-all') + +const assets = () => { + const revAllOpts = { dontGlobal: ['.ico', 'fira.css', 'javascript-logo.png'], dontRenameFile: ['.ico', '.html', /fonts/], dontSearchFile: ['.js'], @@ -15,32 +14,25 @@ gulp.task('assets', function () { return gulp.src('./app/**/*') .pipe(RevAll.revision(revAllOpts)) .pipe(gulp.dest('build')) -}) - -gulp.task('cname', function () { - return gulp.src('CNAME') - .pipe(gulp.dest('build')) -}) +} -gulp.task('gitignore', function () { - return gulp.src('.gitignore') +const cname = () => { + return gulp.src('CNAME', { allowEmpty: true }) .pipe(gulp.dest('build')) -}) +} -gulp.task('clean', function () { - return gulp.src('./build') - .pipe(clean()) -}) +const clean = () => { + return gulp.src('./build', { allowEmpty: true }) + .pipe(gulpClean()) +} -gulp.task('push-gh-pages', function () { +const pushGhPages = () => { return gulp.src('build/**/*') .pipe(ghPages()) -}) +} + +const build = gulp.series(clean, gulp.parallel(assets, cname)) -gulp.task('build', function (cb) { - return runSequence('clean', ['assets', 'cname', 'gitignore'], cb) -}) +exports.build = build -gulp.task('deploy', function (cb) { - return runSequence('build', 'push-gh-pages', cb) -}) +exports.deploy = gulp.series(build, pushGhPages) diff --git a/packages/example/package.json b/packages/example/package.json index 48fa73146fd7..cd3d81a4eeec 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -30,12 +30,11 @@ "chai": "3.5.0", "cross-env": "5.2.0", "cypress-example-kitchensink": "1.5.3", - "gulp": "3.9.1", + "gulp": "4.0.2", "gulp-clean": "0.4.0", "gulp-gh-pages-will": "0.5.5", - "gulp-rev-all": "0.9.8", + "gulp-rev-all": "1.0.0", "mocha": "2.5.3", - "run-sequence": "1.2.2", "shelljs": "0.8.3" } } diff --git a/packages/https-proxy/test/helpers/proxy.coffee b/packages/https-proxy/test/helpers/proxy.coffee index fcc2078793cc..1289eb3bf865 100644 --- a/packages/https-proxy/test/helpers/proxy.coffee +++ b/packages/https-proxy/test/helpers/proxy.coffee @@ -1,3 +1,4 @@ +allowDestroy = require("server-destroy-vvo") http = require("http") path = require("path") httpsProxy = require("../../lib/proxy") @@ -28,6 +29,8 @@ module.exports = { start: (port) -> prx = http.createServer() + allowDestroy(prx) + dir = path.join(process.cwd(), "ca") httpsProxy.create(dir, port, { @@ -60,8 +63,7 @@ module.exports = { resolve(proxy) stop: -> - new Promise (resolve) -> - prx.close(resolve) - .then -> - prx.proxy.close() + ## close all open connections and force quit + prx.destroy() + prx.proxy.close() } diff --git a/packages/https-proxy/test/integration/proxy_spec.coffee b/packages/https-proxy/test/integration/proxy_spec.coffee index d3c5f3111827..2c3589b288ce 100644 --- a/packages/https-proxy/test/integration/proxy_spec.coffee +++ b/packages/https-proxy/test/integration/proxy_spec.coffee @@ -256,7 +256,7 @@ describe "Proxy", -> }) .then => throw new Error('should not succeed') - .catch { message: 'Error: socket hang up' }, => + .catch { message: 'Error: Client network socket disconnected before secure TLS connection was established' }, => expect(createProxyConn).to.not.be.called expect(createSocket).to.be.calledWith({ port: @proxy._sniPort diff --git a/packages/network/test/unit/agent_spec.ts b/packages/network/test/unit/agent_spec.ts index 687c53d1f398..b2fe52436b6a 100644 --- a/packages/network/test/unit/agent_spec.ts +++ b/packages/network/test/unit/agent_spec.ts @@ -1,6 +1,6 @@ import Bluebird from 'bluebird' import chai from 'chai' -import { EventEmitter } from 'events' +import * as addDestroy from 'server-destroy-vvo' import http from 'http' import https from 'https' import net from 'net' @@ -264,7 +264,7 @@ describe('lib/agent', function() { .catch((e) => { expect(e.message).to.eq('Error: A connection to the upstream proxy could not be established: The upstream proxy closed the socket after connecting but before sending a response.') - return proxy.closeAsync() + proxy.close() }) }) }) diff --git a/packages/server/__snapshots__/1_caught_uncaught_hook_errors_spec.coffee.js b/packages/server/__snapshots__/1_caught_uncaught_hook_errors_spec.coffee.js index ae3b6add2118..ebddd0bc50fc 100644 --- a/packages/server/__snapshots__/1_caught_uncaught_hook_errors_spec.coffee.js +++ b/packages/server/__snapshots__/1_caught_uncaught_hook_errors_spec.coffee.js @@ -56,7 +56,6 @@ Because this error occurred during a 'before each' hook we are skipping the rema at stack trace line at stack trace line at stack trace line - at stack trace line 2) s3a "before all" hook for "t8a": Error: s3a before hook failed diff --git a/packages/server/__snapshots__/2_config_spec.coffee.js b/packages/server/__snapshots__/2_config_spec.coffee.js index 4fa3114c5629..18edb1944186 100644 --- a/packages/server/__snapshots__/2_config_spec.coffee.js +++ b/packages/server/__snapshots__/2_config_spec.coffee.js @@ -104,7 +104,6 @@ exports['e2e config fails 1'] = ` at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/2_form_submissions_spec.coffee.js b/packages/server/__snapshots__/2_form_submissions_spec.coffee.js index a7d21c781fc1..bffcf83f9916 100644 --- a/packages/server/__snapshots__/2_form_submissions_spec.coffee.js +++ b/packages/server/__snapshots__/2_form_submissions_spec.coffee.js @@ -176,7 +176,6 @@ exports['e2e forms submissions with jquery XHR POST failing 1'] = ` at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/3_issue_173_spec.coffee.js b/packages/server/__snapshots__/3_issue_173_spec.coffee.js index 5815ca18250d..a2d83f60c984 100644 --- a/packages/server/__snapshots__/3_issue_173_spec.coffee.js +++ b/packages/server/__snapshots__/3_issue_173_spec.coffee.js @@ -38,7 +38,6 @@ exports['e2e issue 173 failing 1'] = ` at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/3_plugins_spec.coffee.js b/packages/server/__snapshots__/3_plugins_spec.coffee.js index 163ee4f41137..3ea813e0b80d 100644 --- a/packages/server/__snapshots__/3_plugins_spec.coffee.js +++ b/packages/server/__snapshots__/3_plugins_spec.coffee.js @@ -23,6 +23,7 @@ Error: Async error from plugins file at stack trace line at stack trace line at stack trace line + at stack trace line (Results) diff --git a/packages/server/__snapshots__/4_promises_spec.coffee.js b/packages/server/__snapshots__/4_promises_spec.coffee.js index 65c8945760ab..7fbf62e89be3 100644 --- a/packages/server/__snapshots__/4_promises_spec.coffee.js +++ b/packages/server/__snapshots__/4_promises_spec.coffee.js @@ -30,7 +30,6 @@ exports['e2e promises failing1 1'] = ` 2) catches promise errors and calls done with err even when async: Error: foo at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/4_request_spec.coffee.js b/packages/server/__snapshots__/4_request_spec.coffee.js index 62723ff4db6d..47b5dd4bf139 100644 --- a/packages/server/__snapshots__/4_request_spec.coffee.js +++ b/packages/server/__snapshots__/4_request_spec.coffee.js @@ -136,9 +136,6 @@ RequestError: Error: connect ECONNREFUSED 127.0.0.1:16795 at stack trace line at stack trace line at stack trace line - at stack trace line - at stack trace line - at stack trace line at stack trace line at stack trace line @@ -155,7 +152,6 @@ RequestError: Error: connect ECONNREFUSED 127.0.0.1:16795 at stack trace line at stack trace line at stack trace line - at stack trace line @@ -279,7 +275,6 @@ Body: Service Unavailable at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/5_spec_isolation_spec.coffee.js b/packages/server/__snapshots__/5_spec_isolation_spec.coffee.js index 2519db703d25..0ece8d0d9714 100644 --- a/packages/server/__snapshots__/5_spec_isolation_spec.coffee.js +++ b/packages/server/__snapshots__/5_spec_isolation_spec.coffee.js @@ -39,7 +39,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"before each\" hook" ], - "body": "function () {\n throw new Error(\"fail1\");\n }" + "body": "function() {\n throw new Error(\"fail1\");\n }" }, { "hookId": "h2", @@ -47,7 +47,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"after each\" hook" ], - "body": "function () {\n throw new Error(\"fail2\");\n }" + "body": "function() {\n throw new Error(\"fail2\");\n }" }, { "hookId": "h3", @@ -55,7 +55,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"after all\" hook" ], - "body": "function () {\n throw new Error(\"fail3\");\n }" + "body": "function() {\n throw new Error(\"fail3\");\n }" } ], "tests": [ @@ -67,7 +67,7 @@ exports['e2e spec_isolation failing 1'] = { "never gets here" ], "state": "failed", - "body": "function () {}", + "body": "function() {}", "stack": "Error: fail1\n\nBecause this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'beforeEach hooks'\n at stack trace line", "error": "fail1\n\nBecause this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'beforeEach hooks'", "timings": { @@ -110,7 +110,7 @@ exports['e2e spec_isolation failing 1'] = { "runs this" ], "state": "failed", - "body": "function () {}", + "body": "function() {}", "stack": "Error: fail2\n\nBecause this error occurred during a 'after each' hook we are skipping the remaining tests in the current suite: 'afterEach hooks'\n at stack trace line", "error": "fail2\n\nBecause this error occurred during a 'after each' hook we are skipping the remaining tests in the current suite: 'afterEach hooks'", "timings": { @@ -140,7 +140,7 @@ exports['e2e spec_isolation failing 1'] = { "does not run this" ], "state": "skipped", - "body": "function () {}", + "body": "function() {}", "stack": null, "error": null, "timings": null, @@ -157,7 +157,7 @@ exports['e2e spec_isolation failing 1'] = { "runs this" ], "state": "passed", - "body": "function () {}", + "body": "function() {}", "stack": null, "error": null, "timings": { @@ -180,7 +180,7 @@ exports['e2e spec_isolation failing 1'] = { "fails on this" ], "state": "failed", - "body": "function () {}", + "body": "function() {}", "stack": "Error: fail3\n\nBecause this error occurred during a 'after all' hook we are skipping the remaining tests in the current suite: 'after hooks'\n at stack trace line", "error": "fail3\n\nBecause this error occurred during a 'after all' hook we are skipping the remaining tests in the current suite: 'after hooks'", "timings": { @@ -273,8 +273,8 @@ exports['e2e spec_isolation failing 1'] = { "fails1" ], "state": "failed", - "body": "function () {\n return cy.wrap(true, {\n timeout: 100\n }).should(\"be.false\");\n }", - "stack": "CypressError: Timed out retrying: expected true to be false\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line", + "body": "function() {\n return cy.wrap(true, {\n timeout: 100\n }).should(\"be.false\");\n }", + "stack": "CypressError: Timed out retrying: expected true to be false\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line\n at stack trace line", "error": "Timed out retrying: expected true to be false", "timings": { "lifecycle": 100, @@ -295,7 +295,7 @@ exports['e2e spec_isolation failing 1'] = { "fails2" ], "state": "failed", - "body": "function () {\n throw new Error(\"fails2\");\n }", + "body": "function() {\n throw new Error(\"fails2\");\n }", "stack": "Error: fails2\n at stack trace line", "error": "fails2", "timings": { @@ -370,7 +370,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"before all\" hook" ], - "body": "function () {\n return cy.wait(100);\n }" + "body": "function() {\n return cy.wait(100);\n }" }, { "hookId": "h2", @@ -378,7 +378,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"before each\" hook" ], - "body": "function () {\n return cy.wait(200);\n }" + "body": "function() {\n return cy.wait(200);\n }" }, { "hookId": "h3", @@ -386,7 +386,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"after each\" hook" ], - "body": "function () {\n return cy.wait(200);\n }" + "body": "function() {\n return cy.wait(200);\n }" }, { "hookId": "h4", @@ -394,7 +394,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"after all\" hook" ], - "body": "function () {\n return cy.wait(100);\n }" + "body": "function() {\n return cy.wait(100);\n }" } ], "tests": [ @@ -405,7 +405,7 @@ exports['e2e spec_isolation failing 1'] = { "t1" ], "state": "passed", - "body": "function () {\n return cy.wrap(\"t1\").should(\"eq\", \"t1\");\n }", + "body": "function() {\n return cy.wrap(\"t1\").should(\"eq\", \"t1\");\n }", "stack": null, "error": null, "timings": { @@ -448,7 +448,7 @@ exports['e2e spec_isolation failing 1'] = { "t2" ], "state": "passed", - "body": "function () {\n return cy.wrap(\"t2\").should(\"eq\", \"t2\");\n }", + "body": "function() {\n return cy.wrap(\"t2\").should(\"eq\", \"t2\");\n }", "stack": null, "error": null, "timings": { @@ -484,7 +484,7 @@ exports['e2e spec_isolation failing 1'] = { "t3" ], "state": "passed", - "body": "function () {\n return cy.wrap(\"t3\").should(\"eq\", \"t3\");\n }", + "body": "function() {\n return cy.wrap(\"t3\").should(\"eq\", \"t3\");\n }", "stack": null, "error": null, "timings": { @@ -561,7 +561,7 @@ exports['e2e spec_isolation failing 1'] = { "title": [ "\"before each\" hook" ], - "body": "function () {\n return cy.wait(1000);\n }" + "body": "function() {\n return cy.wait(1000);\n }" } ], "tests": [ @@ -572,7 +572,7 @@ exports['e2e spec_isolation failing 1'] = { "passes" ], "state": "passed", - "body": "function () {\n return cy.wrap(true).should(\"be.true\");\n }", + "body": "function() {\n return cy.wrap(true).should(\"be.true\");\n }", "stack": null, "error": null, "timings": { diff --git a/packages/server/__snapshots__/5_stdout_spec.coffee.js b/packages/server/__snapshots__/5_stdout_spec.coffee.js index e4e946fe82c0..10d962841251 100644 --- a/packages/server/__snapshots__/5_stdout_spec.coffee.js +++ b/packages/server/__snapshots__/5_stdout_spec.coffee.js @@ -62,7 +62,6 @@ Because this error occurred during a 'before each' hook we are skipping the rema at stack trace line at stack trace line at stack trace line - at stack trace line 3) stdout_failing_spec passing hook is failing: CypressError: cy.visit() failed trying to load: @@ -90,7 +89,6 @@ The internal Cypress web server responded with: at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/5_task_not_registered_spec.coffee.js b/packages/server/__snapshots__/5_task_not_registered_spec.coffee.js index f9135f634900..aec838fb7c37 100644 --- a/packages/server/__snapshots__/5_task_not_registered_spec.coffee.js +++ b/packages/server/__snapshots__/5_task_not_registered_spec.coffee.js @@ -43,7 +43,6 @@ https://on.cypress.io/api/task at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/6_task_spec.coffee.js b/packages/server/__snapshots__/6_task_spec.coffee.js index 87373537a423..3392b42d1271 100644 --- a/packages/server/__snapshots__/6_task_spec.coffee.js +++ b/packages/server/__snapshots__/6_task_spec.coffee.js @@ -90,7 +90,7 @@ The task 'returns:undefined' returned undefined. You must return a promise, a va The task handler was: -returns:undefined() {} +'returns:undefined' () {} Fix this in your plugins file here: /foo/bar/.projects/e2e/cypress/plugins/index.js @@ -108,7 +108,6 @@ https://on.cypress.io/api/task at stack trace line at stack trace line at stack trace line - at stack trace line 2) includes stack trace in error: CypressError: cy.task('errors') failed with the following error: @@ -127,9 +126,6 @@ https://on.cypress.io/api/task at stack trace line at stack trace line at stack trace line - at stack trace line - at stack trace line - at stack trace line at stack trace line at stack trace line @@ -144,7 +140,6 @@ https://on.cypress.io/api/task at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/6_visit_spec.coffee.js b/packages/server/__snapshots__/6_visit_spec.coffee.js index 30aa55b179e5..b8b76c7c4075 100644 --- a/packages/server/__snapshots__/6_visit_spec.coffee.js +++ b/packages/server/__snapshots__/6_visit_spec.coffee.js @@ -119,8 +119,6 @@ Common situations why this would fail: The stack trace for this error is: Error: connect ECONNREFUSED 127.0.0.1:16795 - at stack trace line - at stack trace line at stack trace line at stack trace line @@ -137,7 +135,6 @@ Error: connect ECONNREFUSED 127.0.0.1:16795 at stack trace line at stack trace line at stack trace line - at stack trace line @@ -234,7 +231,6 @@ If you do not want status codes to cause failures pass the option: 'failOnStatus at stack trace line at stack trace line at stack trace line - at stack trace line @@ -331,7 +327,6 @@ The internal Cypress web server responded with: at stack trace line at stack trace line at stack trace line - at stack trace line @@ -430,7 +425,6 @@ cy.request() will automatically get and set cookies and enable you to parse resp at stack trace line at stack trace line at stack trace line - at stack trace line @@ -527,7 +521,6 @@ When this 'load' event occurs, Cypress will continue running commands. at stack trace line at stack trace line at stack trace line - at stack trace line 2) when visit times out fails timeout exceeds timeout option: CypressError: Timed out after waiting '500ms' for your remote page to load. @@ -554,7 +547,6 @@ When this 'load' event occurs, Cypress will continue running commands. at stack trace line at stack trace line at stack trace line - at stack trace line @@ -658,7 +650,6 @@ Error: ESOCKETTIMEDOUT at stack trace line at stack trace line at stack trace line - at stack trace line at stack trace line at stack trace line @@ -675,7 +666,6 @@ Error: ESOCKETTIMEDOUT at stack trace line at stack trace line at stack trace line - at stack trace line 2) response timeouts result in an error handles no response errors when not initially visiting: CypressError: cy.visit() failed trying to load: @@ -707,7 +697,6 @@ Error: ESOCKETTIMEDOUT at stack trace line at stack trace line at stack trace line - at stack trace line at stack trace line at stack trace line @@ -724,7 +713,6 @@ Error: ESOCKETTIMEDOUT at stack trace line at stack trace line at stack trace line - at stack trace line 3) response timeouts result in an error fails after reducing the responseTimeout option: CypressError: cy.visit() failed trying to load: @@ -756,7 +744,6 @@ Error: ESOCKETTIMEDOUT at stack trace line at stack trace line at stack trace line - at stack trace line at stack trace line at stack trace line @@ -773,7 +760,6 @@ Error: ESOCKETTIMEDOUT at stack trace line at stack trace line at stack trace line - at stack trace line diff --git a/packages/server/__snapshots__/run_plugins_spec.coffee.js b/packages/server/__snapshots__/run_plugins_spec.coffee.js index 091c350559b2..604b213e85fd 100644 --- a/packages/server/__snapshots__/run_plugins_spec.coffee.js +++ b/packages/server/__snapshots__/run_plugins_spec.coffee.js @@ -1,10 +1,10 @@ exports['lib/plugins/child/run_plugins sends error message if pluginsFile is missing 1'] = ` Error: Cannot find module '/does/not/exist.coffee' - at Function.Module._resolveFilename module.js - at Module._load module.js + at Function.Module._resolveFilename loader.js + at Module._load loader.js at Function.hookedLoader [as _load] mockery.js - at Module.require module.js - at require module.js + at Module.require loader.js + at require helpers.js at module.exports run_plugins.js at Context. run_plugins_spec.coffee at callFn runnable.js @@ -19,10 +19,10 @@ Error: Cannot find module '/does/not/exist.coffee' at callFn runnable.js at Hook.Runnable.run runnable.js at next runner.js - at Immediate. runner.js + at Immediate._onImmediate runner.js at runCallback timers.js at tryOnImmediate timers.js - at processImmediate [as _immediateCallback] timers.js + at processImmediate timers.js ` @@ -30,14 +30,14 @@ exports['lib/plugins/child/run_plugins sends error message if requiring pluginsF Error: error thrown by pluginsFile at Object. throws_error.coffee at Object. throws_error.coffee - at Module._compile module.js + at Module._compile loader.js at Object.loadFile register.js at Module.load register.js - at tryModuleLoad module.js - at Module._load module.js + at tryModuleLoad loader.js + at Module._load loader.js at Function.hookedLoader [as _load] mockery.js - at Module.require module.js - at require module.js + at Module.require loader.js + at require helpers.js at module.exports run_plugins.js at Context. run_plugins_spec.coffee at callFn runnable.js @@ -52,10 +52,10 @@ Error: error thrown by pluginsFile at callFn runnable.js at Hook.Runnable.run runnable.js at next runner.js - at Immediate. runner.js + at Immediate._onImmediate runner.js at runCallback timers.js at tryOnImmediate timers.js - at processImmediate [as _immediateCallback] timers.js + at processImmediate timers.js ` diff --git a/packages/server/index.js b/packages/server/index.js index 283e80622b28..5eb0509688fd 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -1,12 +1,6 @@ // override tty if we're being forced to require('./lib/util/tty').override() -// if we are running in electron -// we must hack around busted timers -if (process.versions.electron) { - require('./timers/parent').fix() -} - if (process.env.CY_NET_PROFILE && process.env.CYPRESS_ENV) { const netProfiler = require('./lib/util/net_profiler')() diff --git a/packages/server/lib/logger.coffee b/packages/server/lib/logger.coffee index 487c46af221e..48c6fd3ba7a9 100644 --- a/packages/server/lib/logger.coffee +++ b/packages/server/lib/logger.coffee @@ -66,11 +66,9 @@ logger.defaultErrorHandler = (err) -> exit() else - ## instead of console'ing these we should - ## think about chalking them so they are - ## formatted and displayed - console.log(err) - console.log(err.stack) + console.log(chalk.red.underline("Uncaught Error:")) + console.log() + console.log(chalk.red(err?.stack or err?.message or err)) exit() logger.createException(err).then(handleErr).catch(handleErr) diff --git a/packages/server/lib/open_project.coffee b/packages/server/lib/open_project.coffee index 12f4ad210a83..47d0b13e37f8 100644 --- a/packages/server/lib/open_project.coffee +++ b/packages/server/lib/open_project.coffee @@ -178,7 +178,7 @@ create = -> closeOpenProjectAndBrowsers: -> Promise.all([ @closeBrowser() - openProject.close() if openProject + openProject?.close() ]) .then -> reset() diff --git a/packages/server/lib/plugins/child/index.js b/packages/server/lib/plugins/child/index.js index 6de9649b0b4d..34b755b7e6f1 100644 --- a/packages/server/lib/plugins/child/index.js +++ b/packages/server/lib/plugins/child/index.js @@ -1,8 +1,3 @@ -// if we are running in electron -// we must hack around busted timers -if (process.versions.electron) { - require('../../timers/parent').fix() -} require('graceful-fs').gracefulify(require('fs')) require('@packages/coffee/register') require && require.extensions && delete require.extensions['.litcoffee'] diff --git a/packages/server/lib/plugins/index.coffee b/packages/server/lib/plugins/index.coffee index 78e77b6a33c1..6a086949cb3b 100644 --- a/packages/server/lib/plugins/index.coffee +++ b/packages/server/lib/plugins/index.coffee @@ -76,7 +76,19 @@ module.exports = { pluginsProcess.on("error", handleError) ipc.on("error", handleError) - ## see timers/parent.js line #93 for why this is necessary + ## In linux apparently the child process is never + ## exiting which causes cypress to hang indefinitely. + ## It would **SEEM** as if we... + ## 1. dont need to manually kill our child process + ## because it should naturally exit. + ## (but of course it doesn't in linux) + ## 2. use our restore function already defined above. + ## however when using the restore function above + ## the 'child' reference is null. how is it null? + ## it makes no sense. there must be a rip in the + ## space time continuum, obviously. that or the + ## child reference as the rest of the matter of + ## the universe has succumbed to entropy. process.on("exit", killPluginsProcess) register: register diff --git a/packages/server/lib/server.coffee b/packages/server/lib/server.coffee index 760686cff864..c2c41ece0047 100644 --- a/packages/server/lib/server.coffee +++ b/packages/server/lib/server.coffee @@ -440,7 +440,7 @@ class Server ## this will allow us to listen to `str`'s `end` event by putting it in flowing mode responseBuffer = stream.PassThrough({ ## buffer forever - node's default is only to buffer 16kB - highWaterMark: Infinity + highWaterMark: Number.MAX_SAFE_INTEGER }) str.pipe(responseBuffer) @@ -612,30 +612,17 @@ class Server {hostname} = url.parse("http://#{host}") onProxyErr = (err, req, res) -> - ## by default http-proxy will call socket.end - ## with no data, so we need to override the end - ## function and write our own response + ## http-proxy will handle ending the connection for us ## https://github.com/nodejitsu/node-http-proxy/blob/master/lib/http-proxy/passes/ws-incoming.js#L159 - end = socket.end - socket.end = -> - socket.end = end - response = [ - "HTTP/#{req.httpVersion} 502 #{statusCode.getText(502)}" - "X-Cypress-Proxy-Error-Message: #{err.message}" - "X-Cypress-Proxy-Error-Code: #{err.code}" - ].join("\r\n") + "\r\n\r\n" + proxiedUrl = "#{protocol}//#{hostname}:#{port}" - proxiedUrl = "#{protocol}//#{hostname}:#{port}" - - debug( - "Got ERROR proxying websocket connection to url: '%s' received error: '%s' with code '%s'", - proxiedUrl, - err.toString() - err.code - ) - - socket.end(response) + debug( + "Got ERROR proxying websocket connection to url: '%s' received error: '%s' with code '%s'", + proxiedUrl, + err.toString() + err.code + ) proxy.ws(req, socket, head, { secure: false diff --git a/packages/server/test/integration/server_spec.coffee b/packages/server/test/integration/server_spec.coffee index 07538845f833..27f49a51e3be 100644 --- a/packages/server/test/integration/server_spec.coffee +++ b/packages/server/test/integration/server_spec.coffee @@ -606,7 +606,6 @@ describe "Server", -> @server._onResolveUrl("http://localhost:64646", {}, @automationRequest) .catch (err) -> expect(err.message).to.eq("connect ECONNREFUSED 127.0.0.1:64646") - expect(err.stack).to.include("._errnoException") expect(err.port).to.eq(64646) expect(err.code).to.eq("ECONNREFUSED") diff --git a/packages/server/test/integration/websockets_spec.coffee b/packages/server/test/integration/websockets_spec.coffee index 7668c5df4dcf..2d687fdb90f8 100644 --- a/packages/server/test/integration/websockets_spec.coffee +++ b/packages/server/test/integration/websockets_spec.coffee @@ -14,7 +14,7 @@ Automation = require("#{root}lib/automation") Fixtures = require("#{root}/test/support/helpers/fixtures") cyPort = 12345 -otherPort = 5555 +otherPort = 5556 wsPort = 20000 wssPort = 8443 @@ -59,7 +59,7 @@ describe "Web Sockets", -> expect(err.code).to.eq("ECONNRESET") done() - it "sends back 502 Bad Gateway when error upgrading", (done) -> + it "socket hangs up when error upgrading", (done) -> agent = new httpsAgent("http://localhost:#{cyPort}") @server._onDomainSet("http://localhost:#{otherPort}") @@ -68,12 +68,8 @@ describe "Web Sockets", -> agent: agent }) - client.on "unexpected-response", (req, res) -> - expect(res.statusCode).to.eq(502) - expect(res.statusMessage).to.eq("Bad Gateway") - expect(res.headers).to.have.property("x-cypress-proxy-error-message") - expect(res.headers).to.have.property("x-cypress-proxy-error-code") - + client.on "error", (err) -> + expect(err.message).to.eq("socket hang up") done() it "proxies https messages", (done) -> diff --git a/packages/server/test/unit/request_spec.coffee b/packages/server/test/unit/request_spec.coffee index e6a177568c5a..9dd0a26ce820 100644 --- a/packages/server/test/unit/request_spec.coffee +++ b/packages/server/test/unit/request_spec.coffee @@ -781,7 +781,7 @@ describe "lib/request", -> .then -> throw new Error("should have failed") .catch (err) -> - expect(err.message).to.eq "TypeError: The header content contains invalid characters" + expect(err.message).to.eq "TypeError [ERR_INVALID_CHAR]: Invalid character in header content [\"x-text\"]" it "handles weird content in the body just fine", -> request.sendPromise({}, @fn, { diff --git a/packages/server/test/unit/timers_spec.coffee b/packages/server/test/unit/timers_spec.coffee deleted file mode 100644 index a3a93bf88db2..000000000000 --- a/packages/server/test/unit/timers_spec.coffee +++ /dev/null @@ -1,112 +0,0 @@ -require("../spec_helper") - -_ = require("lodash") - -parent = require("#{root}timers/parent") - -describe "timers/parent", -> - context ".fix", -> - beforeEach -> - parent.restore() - @timer = parent.fix() - - describe "setTimeout", -> - it "returns timer object", (done) -> - obj = setTimeout(done, 10) - - expect(obj.id).to.eq(1) - expect(obj.ref).to.be.a("function") - expect(obj.unref).to.be.a("function") - - it "increments timer id", (done) -> - fn = _.after(2, done) - - obj1 = setTimeout(fn, 10) - obj2 = setTimeout(fn, 10) - - expect(obj2.id).to.eq(2) - - it "slices out of queue once cb is invoked", (done) -> - fn = => - expect(@timer.queue).to.deep.eq({}) - done() - - setTimeout(fn, 10) - - expect(@timer.queue[1].cb).to.eq(fn) - - describe "clearTimeout", -> - it "does not explode when passing null", -> - clearTimeout(null) - - it "can clear the timeout and prevent the cb from being invoked", (done) -> - fn = => - done(new Error("should not have been invoked")) - - timer = setTimeout(fn, 10) - - expect(@timer.queue[1].cb).to.eq(fn) - - clearTimeout(timer) - - expect(@timer.queue).to.deep.eq({}) - - setTimeout -> - done() - , 20 - - describe "setInterval", -> - it "returns timer object", (done) -> - obj = setInterval -> - clearInterval(obj) - - done() - , 10 - - expect(obj.id).to.eq(1) - expect(obj.ref).to.be.a("function") - expect(obj.unref).to.be.a("function") - - it "increments timer id", (done) -> - fn = _.after 2, -> - clearInterval(obj1) - clearInterval(obj2) - done() - - obj1 = setInterval(fn, 10) - obj2 = setInterval(fn, 10000) - - expect(obj2.id).to.eq(2) - - it "continuously polls until cleared", (done) -> - poller = _.after 3, => - clearInterval(t) - - setTimeout -> - expect(fn).to.be.calledThrice - done() - , 100 - - fn = sinon.spy(poller) - - t = setInterval(fn, 10) - - describe "clearInterval", -> - it "does not explode when passing null", -> - clearInterval(null) - - it "can clear the interval and prevent the cb from being invoked", (done) -> - fn = => - done(new Error("should not have been invoked")) - - timer = setInterval(fn, 10) - - expect(@timer.queue[1].cb).to.exist - - clearInterval(timer) - - expect(@timer.queue).to.deep.eq({}) - - setTimeout -> - done() - , 20 diff --git a/packages/server/timers/child.js b/packages/server/timers/child.js deleted file mode 100644 index f57b0d5a64d5..000000000000 --- a/packages/server/timers/child.js +++ /dev/null @@ -1,22 +0,0 @@ -const log = require('debug')('cypress:server:timers') - -process.on('message', (obj = {}) => { - const { id, ms } = obj - - log('child received timer id %d', id) - - setTimeout(() => { - try { - log('child sending timer id %d', id) - - // process.send could throw if - // parent process has already exited - process.send({ - id, - ms, - }) - } catch (err) { - // eslint-disable no-empty - } - }, ms) -}) diff --git a/packages/server/timers/parent.js b/packages/server/timers/parent.js deleted file mode 100644 index bd44be74672e..000000000000 --- a/packages/server/timers/parent.js +++ /dev/null @@ -1,166 +0,0 @@ -// electron has completely busted timers resulting in -// all kinds of bizarre timeouts and unresponsive UI -// https://github.com/electron/electron/issues/7079 -// -// this fixes this problem by replacing all the global -// timers and implementing a lightweight queuing mechanism -// involving a forked process - -const cp = require('child_process') -const path = require('path') -const log = require('debug')('cypress:server:timers') - -const st = global.setTimeout -const si = global.setInterval -const ct = global.clearTimeout -const ci = global.clearInterval - -let child = null - -function noop () {} - -function restore () { - // restore - global.setTimeout = st - global.setInterval = si - global.clearTimeout = ct - global.clearInterval = ci - - if (child) { - child.kill() - } - - child = null -} - -function fix () { - const queue = {} - let idCounter = 0 - - function sendAndQueue (id, cb, ms, args) { - // const started = Date.now() - log('queuing timer id %d after %d ms', id, ms) - - queue[id] = { - // started, - args, - ms, - cb, - } - - child.send({ - id, - ms, - }) - - // return the timer object - return { - id, - ref: noop, - unref: noop, - } - } - - function clear (id) { - log('clearing timer id %d from queue %o', id, queue) - - delete queue[id] - } - - // fork the child process - let child = cp.fork(path.join(__dirname, 'child.js'), [], { - stdio: 'inherit', - }) - .on('message', (obj = {}) => { - const { id } = obj - - const msg = queue[id] - - // if we didn't get a msg - // that means we must have - // cleared the timeout already - if (!msg) { - return - } - - const { cb, args } = msg - - clear(id) - - cb(...args) - }) - - // In linux apparently the child process is never - // exiting which causes cypress to hang indefinitely. - // It would **SEEM** as if we... - // 1. dont need to manually kill our child process - // because it should naturally exit. - // (but of course it doesn't in linux) - // 2. use our restore function already defined above. - // however when using the restore function above - // the 'child' reference is null. how is it null? - // it makes no sense. there must be a rip in the - // space time continuum, obviously. that or the - // child reference as the rest of the matter of - // the universe has succumbed to entropy. - process.on('exit', () => { - child && child.kill() - - restore() - }) - - global.setTimeout = function (cb, ms, ...args) { - idCounter += 1 - - return sendAndQueue(idCounter, cb, ms, args) - } - - global.clearTimeout = function (timer) { - if (!timer) { - return - } - - // return undefined per the spec - clear(timer.id) - } - - global.clearInterval = function (timer) { - if (!timer) { - return - } - - // return undefined per the spec - clear(timer.id) - } - - global.setInterval = function (fn, ms, ...args) { - const permId = idCounter += 1 - - function cb () { - // we want to immediately poll again - // because our permId was just cleared - // from the queue stack - poll() - - fn() - } - - function poll () { - return sendAndQueue(permId, cb, ms, args) - } - - return poll() - } - - return { - child, - - queue, - } -} - -module.exports = { - restore, - - fix, -} diff --git a/scripts/run-docker-local.sh b/scripts/run-docker-local.sh index b94204839d2c..e41aa7a782c7 100755 --- a/scripts/run-docker-local.sh +++ b/scripts/run-docker-local.sh @@ -2,10 +2,10 @@ set e+x echo "This script should be run from cypress's root" -name=cypress/browsers:node8.9.3-chrome73 +name=cypress/browsers:node10.2.1-chrome74 echo "Pulling CI container $name" -docker pull $name +# docker pull $name echo "Starting Docker image with cypress volume attached" echo "You should be able to edit files locally" From c33d3606c04e54b179b844ad75ec1fd29ccd7b3b Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Fri, 31 May 2019 12:14:49 -0400 Subject: [PATCH 2/5] fix specs --- packages/server/__snapshots__/4_return_value_spec.coffee.js | 1 - packages/server/test/unit/logger_spec.coffee | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/server/__snapshots__/4_return_value_spec.coffee.js b/packages/server/__snapshots__/4_return_value_spec.coffee.js index 845bded7fca1..6f8b01d7a261 100644 --- a/packages/server/__snapshots__/4_return_value_spec.coffee.js +++ b/packages/server/__snapshots__/4_return_value_spec.coffee.js @@ -84,7 +84,6 @@ https://on.cypress.io/returning-value-and-commands-in-custom-command at stack trace line at stack trace line at stack trace line - at stack trace line 3) errors when not invoking commands, invoking done callback, and returning a promise: Cypress detected that you returned a promise in a test, but also invoked a done callback. Return a promise -or- invoke a done callback, not both. diff --git a/packages/server/test/unit/logger_spec.coffee b/packages/server/test/unit/logger_spec.coffee index 1a7ad3471175..71d4a02a2ee3 100644 --- a/packages/server/test/unit/logger_spec.coffee +++ b/packages/server/test/unit/logger_spec.coffee @@ -109,17 +109,20 @@ describe "lib/logger", -> context "handleErr", -> it "is called after resolving", -> + logger.setErrorHandler -> true logger.defaultErrorHandler(@err) Promise.delay(50).then => expect(@exit).to.be.called it "is called after rejecting", -> + logger.setErrorHandler -> true @create.rejects(new Error()) logger.defaultErrorHandler(@err) Promise.delay(50).then => expect(@exit).to.be.called it "calls process.exit(1)", -> + logger.setErrorHandler -> true logger.defaultErrorHandler(@err) Promise.delay(50).then => expect(@exit).to.be.calledWith(1) From 1e1a2d1ea87ee9e0170b8beb4513e818e1c92c32 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Mon, 15 Jul 2019 12:04:18 -0400 Subject: [PATCH 3/5] use debugger protocol for cookie handling in electron --- packages/electron/lib/electron.coffee | 4 +- packages/extension/gulpfile.js | 95 +++++++++++++++++++ packages/server/lib/automation/cookies.coffee | 4 +- packages/server/lib/browsers/electron.coffee | 77 ++++++++++++--- 4 files changed, 164 insertions(+), 16 deletions(-) create mode 100644 packages/extension/gulpfile.js diff --git a/packages/electron/lib/electron.coffee b/packages/electron/lib/electron.coffee index c8476a29ec19..9d938b476532 100644 --- a/packages/electron/lib/electron.coffee +++ b/packages/electron/lib/electron.coffee @@ -77,8 +77,8 @@ module.exports = { argv.push("--enable-logging") cp.spawn(execPath, argv, {stdio: "inherit"}) - .on "close", (code) -> - debug("electron closing with code", code) + .on "close", (code, errCode) -> + debug("electron closing with code: %s, error code: %s", code, errCode) if code debug("original command was") diff --git a/packages/extension/gulpfile.js b/packages/extension/gulpfile.js new file mode 100644 index 000000000000..57fc40f3d6fb --- /dev/null +++ b/packages/extension/gulpfile.js @@ -0,0 +1,95 @@ +const fs = require('fs-extra') +const pkg = require('./package.json') +const gulp = require('gulp') +const gulpClean = require('gulp-clean') +const source = require('vinyl-source-stream') +const coffeeify = require('coffeeify') +const browserify = require('browserify') +const cypressIcons = require('@cypress/icons') + +const copySocketClient = () => { + return gulp.src(require('../socket').getPathToClientSource()) + .pipe(gulp.dest('dist')) +} + +const clean = () => { + return gulp.src('dist') + .pipe(gulpClean()) +} + +const manifest = (done) => { + gulp.src('app/manifest.json') + .pipe(gulp.dest('dist')) + .on('end', () => { + return fs.readJson('dist/manifest.json', function (err, json) { + json.version = pkg.version + + return fs.writeJson('dist/manifest.json', json, { spaces: 2 }, done) + }) + }) + + return null +} + +const background = () => { + return browserify({ + entries: 'app/background.coffee', + transform: coffeeify, + }) + .bundle() + .pipe(source('background.js')) + .pipe(gulp.dest('dist')) +} + +const html = () => { + return gulp.src('app/**/*.html') + .pipe(gulp.dest('dist')) +} + +const css = () => { + return gulp.src('app/**/*.css') + .pipe(gulp.dest('dist')) +} + +const icons = () => { + return gulp.src([ + cypressIcons.getPathToIcon('icon_16x16.png'), + cypressIcons.getPathToIcon('icon_19x19.png'), + cypressIcons.getPathToIcon('icon_38x38.png'), + cypressIcons.getPathToIcon('icon_48x48.png'), + cypressIcons.getPathToIcon('icon_128x128.png'), + ]) + .pipe(gulp.dest('dist/icons')) +} + +const logos = () => { + return gulp.src([ + cypressIcons.getPathToLogo('cypress-bw.png'), + ]) + .pipe(gulp.dest('dist/logos')) +} + +const build = gulp.series( + clean, + gulp.parallel( + copySocketClient, + icons, + logos, + manifest, + background, + html, + css + ) +) + +const watchBuild = () => { + return gulp.watch('app/**/*', build) +} + +const watch = gulp.series(build, watchBuild) + +module.exports = { + build, + clean, + watch, +} diff --git a/packages/server/lib/automation/cookies.coffee b/packages/server/lib/automation/cookies.coffee index 1ffcc43a94de..1f7aa97d0226 100644 --- a/packages/server/lib/automation/cookies.coffee +++ b/packages/server/lib/automation/cookies.coffee @@ -145,10 +145,10 @@ cookies = (cyNamespace, cookieNamespace) -> clearCookies: (data, automate) -> cookies = _.reject(normalizeCookies(data), isNamespaced) - debug("clear:cookies %o", data) + debug("clear:cookies %o", cookies) clear = (cookie) -> - automate("clear:cookie", { name: cookie.name }) + automate("clear:cookie", { name: cookie.name, domain: cookie.domain }) .then(normalizeCookieProps) Promise.map(cookies, clear) diff --git a/packages/server/lib/browsers/electron.coffee b/packages/server/lib/browsers/electron.coffee index 4c477532daec..60480c25681a 100644 --- a/packages/server/lib/browsers/electron.coffee +++ b/packages/server/lib/browsers/electron.coffee @@ -87,11 +87,9 @@ module.exports = { if options.show menu.set({withDevTools: true}) - Promise - .try => - if options.show is false - @_attachDebugger(win.webContents) - + Promise.try => + @_attachDebugger(win.webContents) + .then => if ua = options.userAgent @_setUserAgent(win.webContents, ua) @@ -105,9 +103,29 @@ module.exports = { ) .then -> win.loadURL(url) + .then => + ## enabling can only happen once the window has loaded + @_enableDebugger(win.webContents) .return(win) _attachDebugger: (webContents) -> + ## this method doesn't like Promise.promisify because when there's + ## only one argument it can't be called with 2 arguments + the callback + webContents.debugger.sendCommandAsync = (message, data) -> + new Promise (resolve, reject) -> + debug("debugger: sendCommand(%s, %o)", message, data) + callback = (err, result) -> + if err + debug("debugger: sendCommand(%s, %o) error: %o", message, err) + reject(err) + else + resolve(result) + + if data + webContents.debugger.sendCommand(message, data, callback) + else + webContents.debugger.sendCommand(message, callback) + try webContents.debugger.attach() debug("debugger attached") @@ -121,7 +139,12 @@ module.exports = { if method is "Console.messageAdded" debug("console message: %o", params.message) - webContents.debugger.sendCommand("Console.enable") + _enableDebugger: (webContents) -> + debug("debugger: enable Console and Network") + Promise.join( + webContents.debugger.sendCommandAsync("Console.enable"), + webContents.debugger.sendCommandAsync("Network.enable") + ) _getPartition: (options) -> if options.isTextTerminal @@ -148,7 +171,7 @@ module.exports = { new Promise (resolve) -> webContents.session.setProxy({ proxyRules: proxyServer - ## this should really only be necessary when + ## this should really only be necessary when ## running Chromium versions >= 72 ## https://github.com/cypress-io/cypress/issues/1872 proxyBypassRules: "<-loopback>" @@ -201,19 +224,49 @@ module.exports = { tryToCall win, -> a[method](data) + invokeViaDebugger = (message, data) -> + tryToCall win, -> + win.webContents.debugger.sendCommandAsync(message, data) + + normalizeGetCookieProps = (cookie) -> + cookie.expirationDate = cookie.expires ? -1 + delete cookie.expires + return cookie + + normalizeGetCookies = (cookies) -> + _.map(cookies, normalizeGetCookieProps) + + normalizeSetCookieProps = (cookie) -> + cookie.name or= "" ## name can't be undefined/null + cookie.expiry = cookie.expirationDate + delete cookie.expirationDate + return cookie + + getCookies = -> + invokeViaDebugger("Network.getAllCookies") + .then (result) -> + normalizeGetCookies(result.cookies) + + getCookie = (data) -> + getCookies().then (cookies) -> + _.find(cookies, { name: data.name }) or null + automation.use({ onRequest: (message, data) -> switch message when "get:cookies" - invoke("getCookies", data) + getCookies() when "get:cookie" - invoke("getCookie", data) + getCookie(data) when "set:cookie" - invoke("setCookie", data) + data = normalizeSetCookieProps(data) + invokeViaDebugger("Network.setCookie", data).then -> + getCookie(data) when "clear:cookies" - invoke("clearCookies", data) + invokeViaDebugger("Network.clearBrowserCookies").return(null) when "clear:cookie" - invoke("clearCookie", data) + data = normalizeSetCookieProps(data) + invokeViaDebugger("Network.deleteCookies", data).return(null) when "is:automation:client:connected" invoke("isAutomationConnected", data) when "take:screenshot" From d5fba18571a88bc3a95b4107aed35c02472deff0 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Mon, 15 Jul 2019 12:15:23 -0400 Subject: [PATCH 4/5] use latest gulp --- packages/extension/package.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/extension/package.json b/packages/extension/package.json index e12a4ba5c879..0005098b9715 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -35,13 +35,11 @@ "cross-env": "5.2.0", "eol": "0.9.1", "fs-extra": "0.30.0", - "gulp": "3.9.1", + "gulp": "4.0.2", "gulp-clean": "0.4.0", - "gulp-rename": "1.4.0", - "run-sequence": "1.2.2", "sinon": "1.17.7", "sinon-chai": "3.3.0", - "vinyl-source-stream": "1.1.2" + "vinyl-source-stream": "2.0.0" }, "dependencies": { "bluebird": "3.5.3", From f9e620584fd81cca2d05b1ec6e16ee16176eb266 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Mon, 15 Jul 2019 12:27:06 -0400 Subject: [PATCH 5/5] use rimraf instead of gulp-clean --- packages/extension/gulpfile.js | 7 +++---- packages/extension/package.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/extension/gulpfile.js b/packages/extension/gulpfile.js index 57fc40f3d6fb..9ff79ae5c98a 100644 --- a/packages/extension/gulpfile.js +++ b/packages/extension/gulpfile.js @@ -1,7 +1,7 @@ const fs = require('fs-extra') const pkg = require('./package.json') const gulp = require('gulp') -const gulpClean = require('gulp-clean') +const rimraf = require('rimraf') const source = require('vinyl-source-stream') const coffeeify = require('coffeeify') const browserify = require('browserify') @@ -12,9 +12,8 @@ const copySocketClient = () => { .pipe(gulp.dest('dist')) } -const clean = () => { - return gulp.src('dist') - .pipe(gulpClean()) +const clean = (done) => { + rimraf('dist', done) } const manifest = (done) => { diff --git a/packages/extension/package.json b/packages/extension/package.json index 0005098b9715..75409dffc98b 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -36,7 +36,7 @@ "eol": "0.9.1", "fs-extra": "0.30.0", "gulp": "4.0.2", - "gulp-clean": "0.4.0", + "rimraf": "2.6.3", "sinon": "1.17.7", "sinon-chai": "3.3.0", "vinyl-source-stream": "2.0.0"