Skip to content

Commit

Permalink
add firefox driver integration tests in ci, fix no bypass localhost f…
Browse files Browse the repository at this point in the history
…or proxy in firefox
  • Loading branch information
kuceb committed Aug 30, 2019
1 parent f8931b1 commit 38338d8
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 140 deletions.
41 changes: 34 additions & 7 deletions 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:node8.9.3-npm6.10.1-chrome75
- image: cypress/browsers:node8.9.3-npm6.10.1-chrome76-ff68
environment:
PLATFORM: linux

Expand Down Expand Up @@ -307,8 +307,8 @@ jobs:
path: /tmp/cypress

"server-performance-tests":
<<: *defaults
steps:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
Expand Down Expand Up @@ -396,8 +396,8 @@ jobs:
path: /tmp/cypress

"server-e2e-tests-8":
<<: *defaults
steps:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
Expand All @@ -406,7 +406,7 @@ jobs:
- store_test_results:
path: /tmp/cypress

"driver-integration-tests-3x":
"driver-integration-tests-chrome-3x":
<<: *defaults
parallelism: 3
steps:
Expand All @@ -430,6 +430,30 @@ jobs:
- store_artifacts:
path: /tmp/artifacts

"driver-integration-tests-firefox-3x":
<<: *defaults
parallelism: 3
steps:
- attach_workspace:
at: ~/
- run:
command: npm start
background: true
working_directory: packages/driver
- run:
command: $(npm bin)/wait-on http://localhost:3500
working_directory: packages/driver
- run:
command: |
CYPRESS_KONFIG_ENV=production \
CYPRESS_RECORD_KEY=$PACKAGES_RECORD_KEY \
npm run cypress:run -- --record --parallel --group 3x-driver-firefox --browser firefox
working_directory: packages/driver
- store_test_results:
path: /tmp/cypress
- store_artifacts:
path: /tmp/artifacts

"desktop-gui-integration-tests-2x":
<<: *defaults
parallelism: 2
Expand Down Expand Up @@ -796,7 +820,10 @@ linux-workflow: &linux-workflow
- server-e2e-tests-8:
requires:
- build
- driver-integration-tests-3x:
- driver-integration-tests-chrome-3x:
requires:
- build
- driver-integration-tests-firefox-3x:
requires:
- build
- desktop-gui-integration-tests-2x:
Expand Down
2 changes: 2 additions & 0 deletions packages/extension/app/background.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
browser = require('webextension-polyfill')
map = require("lodash/map")
pick = require("lodash/pick")
once = require("lodash/once")
Expand All @@ -6,6 +7,7 @@ client = require("./client")

httpRe = /^http/

debugger
firstOrNull = (cookies) ->
## normalize into null when empty array
cookies[0] ? null
Expand Down
116 changes: 0 additions & 116 deletions packages/extension/app/browser-polyfill.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/extension/app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"background": {
"scripts": [
"browser-polyfill.js",
"background.js"
]
},
Expand Down
6 changes: 0 additions & 6 deletions packages/extension/lib/extension.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
fs = require("fs")
path = require("path")
Promise = require("bluebird")
background = require("../app/background")

fs = Promise.promisifyAll(fs)

Expand All @@ -26,9 +25,4 @@ module.exports = {
.replace("CHANGE_ME_HOST", host)
.replace("CHANGE_ME_PATH", path)

getCookieUrl: background.getUrl

connect: background.connect

app: background
}
3 changes: 2 additions & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"run-sequence": "1.2.2",
"sinon": "7.3.2",
"sinon-chai": "3.3.0",
"vinyl-source-stream": "2.0.0"
"vinyl-source-stream": "2.0.0",
"webextension-polyfill": "0.4.0"
},
"files": [
"app",
Expand Down
19 changes: 17 additions & 2 deletions packages/server/lib/browsers/chrome.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ module.exports = {

_removeRootExtension

_writeExtension: (browser, isTextTerminal, proxyUrl, socketIoRoute) ->
## get the string bytes for the final extension file
extension.setHostAndPath(proxyUrl, socketIoRoute)
.then (str) ->
extensionDest = utils.getExtensionDir(browser, isTextTerminal)
extensionBg = path.join(extensionDest, "background.js")

## copy the extension src to the extension dist
utils.copyExtension(pathToExtension, extensionDest)
.then ->
## and overwrite background.js with the final string bytes
fs.writeFileAsync(extensionBg, str)
.return(extensionDest)

_getArgs: (options = {}) ->
_.defaults(options, {
browser: {}
Expand Down Expand Up @@ -160,7 +174,7 @@ module.exports = {
## https://github.com/cypress-io/cypress/issues/2223
{ majorVersion } = options.browser
if majorVersion in CHROME_VERSIONS_WITH_BUGGY_ROOT_LAYER_SCROLLING
args.push("--disable-blink-features=RootLayerScrolling")
args.push("--disable-blink-features=RootLayerScrolling")

## https://chromium.googlesource.com/chromium/src/+/da790f920bbc169a6805a4fb83b4c2ab09532d91
## https://github.com/cypress-io/cypress/issues/1872
Expand All @@ -187,7 +201,8 @@ module.exports = {
])
.spread (cacheDir, args) =>
Promise.all([
utils.writeExtension(
# utils.writeExtension(
@_writeExtension(
browser,
isTextTerminal,
options.proxyUrl,
Expand Down
3 changes: 3 additions & 0 deletions packages/server/lib/browsers/firefox-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Marionette = require('marionette-client')
const Exception = require('marionette-client/lib/marionette/error')
const Command = require('marionette-client/lib/marionette/message.js').Command
const Promise = require('bluebird')
const debug = require('debug')('cypress:server:browsers')

const promisify = (fn) => {
return (...args) => {
Expand Down Expand Up @@ -31,6 +32,8 @@ module.exports = {
send,

setup (extensions, url) {
debug('firefox: navigating page with webdriver')

return connect()
.then(() => {
return send({
Expand Down
8 changes: 5 additions & 3 deletions packages/server/lib/browsers/firefox.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ module.exports = {
preferences = _.extend({}, defaultPreferences)
extensions = []

debug('firefox open', options)
if ps = options.proxyServer
{hostname, port, protocol} = urlUtil.parse(ps)
port ?= if protocol is "https:" then 443 else 80
port = parseFloat(port)

_.extend(preferences, {
"network.proxy.allow_hijacking_localhost": true
"network.proxy.http": hostname
"network.proxy.ssl": hostname
"network.proxy.http_port": port
Expand All @@ -134,7 +136,7 @@ module.exports = {
.then ->
Promise.all([
utils.ensureCleanCache(browserName)
utils.writeExtension(options.browser, options.isTextTerminal, options.proxyUrl, options.socketIoRoute)
utils.writeExtension(options.browser, options.visTextTerminal, options.proxyUrl, options.socketIoRoute)
utils.ensureCleanCache(browserName)
])
.spread (cacheDir, extensionDest, profileDir) ->
Expand Down Expand Up @@ -163,8 +165,8 @@ module.exports = {
utils.launch(browserName, null, args)
.then (browserInstance) ->
firefoxUtil.setup(extensions, url)
# .then ->
# return browserInstance
.then ->
return browserInstance
.catch (err) ->
debug("launch error:", err.stack)
throw err
Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/browsers/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ module.exports = {
debug("browser opened")
## TODO: bind to process.exit here
## or move this functionality into cypress-core-launder

instance = i

debug('instance', instance)
## TODO: normalizing opening and closing / exiting
## so that there is a default for each browser but
## enable the browser to configure the interface
Expand Down
5 changes: 3 additions & 2 deletions packages/server/lib/browsers/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fs = require("../util/fs")
extension = require("@packages/extension")
appData = require("../util/app_data")
profileCleaner = require("../util/profile_cleaner")

debug = require('debug')('cypress:server:browsers')
PATH_TO_BROWSERS = appData.path("browsers")

getBrowserPath = (browser) ->
Expand Down Expand Up @@ -88,7 +88,7 @@ module.exports = {
launch: launcher.launch

writeExtension: (browser, isTextTerminal, proxyUrl, socketIoRoute) ->
require('debug')('cypress:server:browsers')(browser, isTextTerminal, proxyUrl)
debug('writing extension')
# debug('writing extension to chrome browser')
## get the string bytes for the final extension file
extension.setHostAndPath(proxyUrl, socketIoRoute)
Expand All @@ -99,6 +99,7 @@ module.exports = {
## copy the extension src to the extension dist
copyExtension(pathToExtension, extensionDest)
.then ->
debug('copied extension')
## and overwrite background.js with the final string bytes
fs.writeFileAsync(extensionBg, str)
.return(extensionDest)
Expand Down

0 comments on commit 38338d8

Please sign in to comment.