Skip to content

Commit

Permalink
fix: ignore jsVersion configuration property in Firefox 59+
Browse files Browse the repository at this point in the history
Support for specifying JavaScript version was removed in Firefox 59. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1428745 for more details.
From now on Karma will ignore `jsVersion` property in Firefox 59+ and
print deprecation warning if `jsVersion` property is found.

Closes #2957
  • Loading branch information
devoto13 authored and dignifiedquire committed Mar 15, 2018
1 parent f18f728 commit 2694d54
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/config/01-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ sometimes you might want to proxy a url that is already taken by Karma.

If `> 0`, Karma will add a JavaScript version tag to the included JavaScript files.

Note: This will only be applied to the Firefox browser. It is currently the only browser that supports the version tag.
Note: This will only be applied to the Firefox browser up to version 58. Support for JavaScript version was [removed](https://bugzilla.mozilla.org/show_bug.cgi?id=1428745) in Firefox 59. This property is deprecated and will be removed in the next major release of Karma.


[plugins]: plugins.html
Expand Down
10 changes: 9 additions & 1 deletion lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,15 @@ var createKarmaMiddleware = function (

// In case there is a JavaScript version specified and this is a Firefox browser
if (jsVersion && jsVersion > 0 && isFirefox(request)) {
scriptType += ';version=' + jsVersion
var agent = useragent.parse(request.headers['user-agent'])

log.warn('jsVersion configuration property is deprecated and will be removed in the next major release of Karma.')

if (agent.major < 59) {
scriptType += ';version=' + jsVersion
} else {
log.warn('jsVersion is not supported in Firefox 59+ (see https://bugzilla.mozilla.org/show_bug.cgi?id=1428745 for more details). Ignoring.')
}
}

var crossOriginAttribute = includeCrossOriginAttribute ? CROSSORIGIN_ATTRIBUTE : ''
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/support/tag/tag.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-unused-vars */
var isFirefox = function () {
return typeof InstallTrigger !== 'undefined'
var isFirefoxBefore59 = function () {
return typeof InstallTrigger !== 'undefined' && parseFloat(navigator.userAgent.match(/\d+\.\d+$/)) < 59
}

var containsJsTag = function () {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/support/tag/test-with-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals containsJsTag, isFirefox */
/* globals containsJsTag, isFirefoxBefore59 */
describe('JavaScript version tag', function () {
it('should add the version tag, if Firefox is used', function () {
expect(containsJsTag()).toBe(isFirefox())
expect(containsJsTag()).toBe(isFirefoxBefore59())
})
})
2 changes: 1 addition & 1 deletion test/e2e/tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: JavaScript Tag
]
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
.
Firefox
Expand Down

0 comments on commit 2694d54

Please sign in to comment.