Refactor to reduce duplication.
MODIFY
karma-base.js
karma-base.js
@@ -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,
@@ -231,37 +275,25 @@ module.exports = function (config) {
customLaunchers: {
ChromeHeadlessTouch: {
base: 'ChromeHeadless',
- flags: [
- '--no-sandbox', // necessary to run tests in a docker
- '--no-pings', // no auditing pings
- '--disable-background-networking',
- '--disable-component-extensions-with-background-pages',
+ flags: ChromeFlags.concat([
'--touch-events'
- ]
+ ])
},
ChromeFull: {
base: 'Chrome',
- flags: [
- '--no-sandbox', // necessary to run tests in a docker
- '--no-pings', // no auditing pings
- '--disable-background-networking',
- '--disable-component-extensions-with-background-pages',
+ 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
- '--disable-background-networking',
- '--disable-component-extensions-with-background-pages',
+ flags: ChromeFlags.concat([
'--device-scale-factor=1',
'--window-position=0,0',
'--start-fullscreen',
@@ -269,90 +301,24 @@ module.exports = function (config) {
'--incognito',
'--translate-script-url=""',
'--proxy-pac-url=' + config.protocol + '//' + config.hostname + ':' + config.port + '/testdata/proxy-for-tests.pac'
- ]
+ ])
},
FirefoxHeadlessTouch: {
base: 'FirefoxHeadless',
- prefs: {
+ prefs: Object.assign({
// enable touch
- 'dom.w3c_touch_events.enabled': 1,
- /* By default, Firefox makes many connections when it starts 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
- */
- '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': ''
- }
+ 'dom.w3c_touch_events.enabled': 1
+ }, FirefoxPrefs)
},
FirefoxWithProxy: {
base: 'Firefox',
- prefs: {
+ prefs: Object.assign({
// enable proxy
'network.proxy.type': 2,
'network.proxy.autoconfig_url': config.protocol + '//' + config.hostname + ':' + config.port + '/testdata/proxy-for-tests.pac',
// enable touch
- 'dom.w3c_touch_events.enabled': 1,
- /* By default, Firefox makes many connections when it starts 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
- */
- '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': ''
- }
+ 'dom.w3c_touch_events.enabled': 1
+ }, FirefoxPrefs)
}
},
browserNoActivityTimeout: 30000,

Refactor to reduce duplication.