Skip to content

Commit

Permalink
Merge pull request #818 from OpenGeoscience/browser-test-improvements
Browse files Browse the repository at this point in the history
Use Firefox headless where appropriate.
  • Loading branch information
manthey authored May 17, 2018
2 parents 4879f75 + 808dfee commit e32c8c8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 25 deletions.
83 changes: 63 additions & 20 deletions karma-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,50 @@ var osmtiles_middleware = function (config) {
};
};

/* Reduce the number of external connections Chrome makes. */
var ChromeFlags = [
'--no-sandbox', // necessary to run tests in a docker
'--no-pings', // no auditing pings
'--disable-background-networking',
'--disable-component-extensions-with-background-pages'
];

/* By default, when Firefox starts it makes many connections to sites like
* mozilla.org, yahoo.com, google.com, etc. This limits these connections (but
* doesn't eliminate them completely, especially when accessing the 2d canvas).
* See
* https://support.mozilla.org/en-US/kb/how-stop-firefox-making-automatic-connections
*/
var FirefoxPrefs = {
'browser.aboutHomeSnippets.updateUrl': '',
'browser.casting.enabled': false,
'browser.library.activity-stream.enabled': false,
'browser.newtabpage.activity-stream.enabled': false,
'browser.search.geoip.url': '',
'browser.selfsupport.enabled': false,
'browser.selfsupport.url': '',
'browser.startup.homepage_override.mstone': 'ignore',
'extensions.getAddons.cache.enabled': false,
'extensions.pocket.enabled': false,
'extensions.update.enabled': false,
'network.captive-portal-service.enabled': false,
'network.dns.disablePrefetch': true,
'network.http.speculative-parallel-limit': 0,
'network.prefetch-next': false,
// these further limit firefox connections
'browser.safebrowsing.provider.mozilla.gethashURL': '',
'browser.safebrowsing.provider.mozilla.updateURL': '',
'browser.safebrowsing.provider.google.gethashURL': '',
'browser.safebrowsing.provider.google.updateURL': '',
'browser.safebrowsing.provider.google4.dataSharingURL': '',
'browser.safebrowsing.provider.google4.gethashURL': '',
'browser.safebrowsing.provider.google4.updateURL': '',
'datareporting.healthreport.uploadEnabled': false,
'datareporting.policy.dataSubmissionEnabled': false,
'media.gmp-gmpopenh264.autoupdate': false,
'media.gmp-manager.url': ''
};

module.exports = function (config) {
var newConfig = {
autoWatch: false,
Expand Down Expand Up @@ -231,51 +275,50 @@ module.exports = function (config) {
customLaunchers: {
ChromeHeadlessTouch: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox', // necessary to run tests in a docker
'--no-pings', // no auditing pings
flags: ChromeFlags.concat([
'--touch-events'
]
])
},
ChromeFull: {
base: 'Chrome',
flags: [
'--no-sandbox', // necessary to run tests in a docker
'--no-pings', // no auditing pings
flags: ChromeFlags.concat([
'--device-scale-factor=1',
'--window-position=0,0',
'--start-fullscreen',
'--kiosk',
'--incognito'
]
])
},
ChromeWithProxy: {
// inheriting from ChromeFull ignores the flags in this entry, so we
// need to inherit from Chrome
base: 'Chrome',
flags: [
'--no-sandbox', // necessary to run tests in a docker
'--no-pings', // no auditing pings
flags: ChromeFlags.concat([
'--device-scale-factor=1',
'--window-position=0,0',
'--start-fullscreen',
'--kiosk',
'--incognito',
'--translate-script-url=""',
'--proxy-pac-url=' + config.protocol + '//' + config.hostname + ':' + config.port + '/testdata/proxy-for-tests.pac'
]
])
},
FirefoxTouch: {
base: 'Firefox',
prefs: {
FirefoxHeadlessTouch: {
base: 'FirefoxHeadless',
prefs: Object.assign({
// enable touch
'dom.w3c_touch_events.enabled': 1
}
}, FirefoxPrefs)
},
FirefoxWithProxy: {
base: 'FirefoxTouch',
prefs: {
base: 'Firefox',
prefs: Object.assign({
// enable proxy
'network.proxy.type': 2,
'network.proxy.autoconfig_url': config.protocol + '//' + config.hostname + ':' + config.port + '/testdata/proxy-for-tests.pac'
}
'network.proxy.autoconfig_url': config.protocol + '//' + config.hostname + ':' + config.port + '/testdata/proxy-for-tests.pac',
// enable touch
'dom.w3c_touch_events.enabled': 1
}, FirefoxPrefs)
}
},
browserNoActivityTimeout: 30000,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"karma": "^0.13.22",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.0.0",
"karma-firefox-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.1.0",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.0",
"karma-phantomjs-launcher": "^1.0.0",
Expand Down Expand Up @@ -97,15 +97,15 @@
"build-website-tutorials": "node tutorials/build-website.js && webpack --config webpack-website-tutorials.config.js",
"lint": "eslint --cache .",
"puglint": "pug-lint src examples",
"test": "GEOJS_TEST_CASE=tests/test-unit.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch,PhantomJS",
"test-all": "GEOJS_TEST_CASE=tests/test-unit.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch,PhantomJS",
"test": "GEOJS_TEST_CASE=tests/test-unit.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxHeadlessTouch,PhantomJS",
"test-all": "GEOJS_TEST_CASE=tests/test-unit.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxHeadlessTouch,PhantomJS",
"start": "karma start karma.conf.js",
"glci": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch",
"glci-all": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch",
"glci-all": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxHeadlessTouch",
"headedci": "GEOJS_TEST_CASE=tests/test-headed.js karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy",
"headedci-all": "GEOJS_TEST_CASE=tests/test-headed.js karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy,FirefoxWithProxy",
"tutorialsci": "GEOJS_TEST_CASE=tests/tutorials.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,PhantomJS",
"tutorialsci-all": "GEOJS_TEST_CASE=tests/tutorials.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch,PhantomJS",
"tutorialsci-all": "GEOJS_TEST_CASE=tests/tutorials.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxHeadlessTouch,PhantomJS",
"test-webgl": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch",
"test-headed": "GEOJS_TEST_CASE=tests/test-headed.js xvfb-run -s '-ac -screen 0 1280x1024x24' karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy",
"codecov": "codecov",
Expand Down

0 comments on commit e32c8c8

Please sign in to comment.