Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: karma @ 4.0.1 .. 4.1.0

CHANGELOG.md

@@ -1,3 +1,16 @@
+<a name="4.1.0"></a>
+# [4.1.0](https://github.com/karma-runner/karma/compare/v4.0.1...v4.1.0) (2019-04-15)
+
+
+### Bug Fixes
+
+* **client:** Enable loading different file types when running in parent mode without iframe ([#3289](https://github.com/karma-runner/karma/issues/3289)) ([7968db6](https://github.com/karma-runner/karma/commit/7968db6))
+* **client:** Only create the funky object if message is not a string ([#3298](https://github.com/karma-runner/karma/issues/3298)) ([ce6825f](https://github.com/karma-runner/karma/commit/ce6825f)), closes [#3296](https://github.com/karma-runner/karma/issues/3296)
+* **launcher:** Log state transitions in debug ([#3294](https://github.com/karma-runner/karma/issues/3294)) ([6556ab4](https://github.com/karma-runner/karma/commit/6556ab4)), closes [#3290](https://github.com/karma-runner/karma/issues/3290)
+* **middleware:** log invalid filetype ([#3292](https://github.com/karma-runner/karma/issues/3292)) ([7eb48c5](https://github.com/karma-runner/karma/commit/7eb48c5)), closes [#3291](https://github.com/karma-runner/karma/issues/3291)
+
+
+
<a name="4.0.1"></a>
## [4.0.1](https://github.com/karma-runner/karma/compare/v4.0.0...v4.0.1) (2019-02-28)

lib/launchers/base.js

@@ -5,12 +5,12 @@
const log = require('../logger').create('launcher')
const helper = require('../helper')
-const BEING_CAPTURED = 1
-const CAPTURED = 2
-const BEING_KILLED = 3
-const FINISHED = 4
-const RESTARTING = 5
-const BEING_FORCE_KILLED = 6
+const BEING_CAPTURED = 'BEING_CAPTURED'
+const CAPTURED = 'CAPTURED'
+const BEING_KILLED = 'BEING_KILLED'
+const FINISHED = 'FINISHED'
+const RESTARTING = 'RESTARTING'
+const BEING_FORCE_KILLED = 'BEING_FORCE_KILLED'
/**
* Base launcher that any custom launcher extends.
@@ -29,7 +29,17 @@
this.emitAsync = KarmaEventEmitter.prototype.emitAsync.bind(this)
this.id = id
- this.state = null
+ this._state = null
+ Object.defineProperty(this, 'state', {
+ get: () => {
+ return this._state
+ },
+ set: (toState) => {
+ log.debug(`${this._state} -> ${toState}`)
+ this._state = toState
+ }
+ })
+
this.error = null
let killingPromise

lib/middleware/karma.js

@@ -175,13 +175,12 @@
common.setNoCacheHeaders(response)
const scriptTags = []
- const scriptUrls = []
for (const file of files.included) {
let filePath = file.path
const fileType = file.type || path.extname(filePath).substring(1)
if (helper.isDefined(fileType) && !FILE_TYPES.includes(fileType)) {
- log.warn('Invalid file type, defaulting to js.', fileType)
+ log.warn(`Invalid file type (${fileType}), defaulting to js.`)
}
if (!file.isUrl) {
@@ -192,8 +191,6 @@
}
}
- scriptUrls.push(filePath)
-
if (fileType === 'css') {
scriptTags.push(`<link type="text/css" href="${filePath}" rel="stylesheet">`)
} else if (fileType === 'dom') {
@@ -207,6 +204,20 @@
}
}
+ const scriptUrls = []
+ // For client_with_context, html elements are not added directly through an iframe.
+ // Instead, scriptTags is stored to window.__karma__.scriptUrls first. Later, the
+ // client will read window.__karma__.scriptUrls and dynamically add them to the DOM
+ // using DOMParser.
+ if (requestUrl === '/client_with_context.html') {
+ for (const script of scriptTags) {
+ scriptUrls.push(
+ // Escape characters with special roles (tags) in HTML. Open angle brackets are parsed as tags
+ // immediately, even if it is within double quotations in browsers
+ script.replace(/</g, '\\x3C').replace(/>/g, '\\x3E'))
+ }
+ }
+
const mappings = data.includes('%MAPPINGS%') ? files.served.map((file) => {
const filePath = filePathToUrlPath(file.path, basePath, urlRoot, proxyPath)
.replace(/\\/g, '\\\\') // Windows paths contain backslashes and generate bad IDs if not escaped

package.json

@@ -32,102 +32,101 @@
"ukasz Usarz <lukasz.usarz@gmail.com>",
"Christian Budde Christensen <budde377@gmail.com>",
"Yaroslav Admin <devoto13@gmail.com>",
- "Wesley Cho <wesley.cho@gmail.com>",
"taichi <ryushi@gmail.com>",
+ "Wesley Cho <wesley.cho@gmail.com>",
"Liam Newman <bitwiseman@gmail.com>",
"lukasz <lukasz.usarz@gmail.com>",
"Michał Gołębiowski-Owczarek <m.goleb@gmail.com>",
"Todd Wolfson <todd@twolfson.com>",
"Mark Trostler <mark@zzo.com>",
"Ciro Nunes <ciroanunes@gmail.com>",
- "Christian Budde Christensen <christi@n-bud.de>",
- "Pawel Kozlowski <pkozlowski.opensource@gmail.com>",
"Tim Cuthbertson <tim@gfxmonk.net>",
- "Shyam Seshadri <shyamseshadri@gmail.com>",
"Robo <hop2deep@gmail.com>",
- "Daniel Compton <desk@danielcompton.net>",
+ "Pawel Kozlowski <pkozlowski.opensource@gmail.com>",
+ "Christian Budde Christensen <christi@n-bud.de>",
+ "Shyam Seshadri <shyamseshadri@gmail.com>",
"Mark Ethan Trostler <mark@zzo.com>",
+ "Daniel Compton <desk@danielcompton.net>",
"Mourad <mourad@elmaouchi.com>",
- "Kim Joar Bekkelund <kjbekkelund@gmail.com>",
- "vivganes <vivek@vivekganesan.com>",
- "Brian Di Palma <offler@gmail.com>",
- "Georgii Dolzhykov <thorn.mailbox@gmail.com>",
"Nick Malaguti <nmalaguti@palantir.com>",
"joshjb84 <joshjb84@hotmail.com>",
- "Andrew Martin <sublimino@gmail.com>",
+ "Georgii Dolzhykov <thorn.mailbox@gmail.com>",
+ "vivganes <vivek@vivekganesan.com>",
+ "Kim Joar Bekkelund <kjbekkelund@gmail.com>",
+ "Brian Di Palma <offler@gmail.com>",
+ "ywong <wongyok@gmail.com>",
"Chris Hunt <chrahunt@gmail.com>",
- "Jake Champion <jakechampion.jake2@googlemail.com>",
+ "Pieter Mees <pietermees@users.noreply.github.com>",
+ "Daniel Aleksandersen <code@daniel.priv.no>",
+ "Marcello Nuccio <marcello.nuccio@gmail.com>",
"Aymeric Beaumet <aymeric@beaumet.me>",
- "sylvain-hamel <sylvainhamel0@gmail.com>",
- "Iristyle <Iristyle@github>",
- "Chris Casola <chriscasola@gmail.com>",
- "Jérémy Judéaux <jeremy.judeaux@volune.net>",
- "ywong <wongyok@gmail.com>",
"Ilya Volodin <ivolodin@vistaprint.com>",
+ "Andrew Martin <sublimino@gmail.com>",
"Jeff Jewiss <jeffjewiss@gmail.com>",
- "pavelgj <pavelgj@gmail.com>",
+ "Iristyle <Iristyle@github>",
"Brian Ford <btford@umich.edu>",
- "Pieter Mees <pietermees@users.noreply.github.com>",
"David Souther <davidsouther@gmail.com>",
- "Daniel Aleksandersen <code@daniel.priv.no>",
- "Marcello Nuccio <marcello.nuccio@gmail.com>",
+ "Jérémy Judéaux <jeremy.judeaux@volune.net>",
+ "pavelgj <pavelgj@gmail.com>",
+ "Chris Casola <chriscasola@gmail.com>",
+ "sylvain-hamel <sylvainhamel0@gmail.com>",
+ "Jake Champion <jakechampion.jake2@googlemail.com>",
"Robin Liang <robin.gnail@gmail.com>",
- "Matt Lewis <matthew.lewis@socialsignin.co.uk>",
+ "David Pärsson <david@parsson.se>",
"rdodev <rubenoz@gmail.com>",
+ "Filipe Guerra <alias.mac@gmail.com>",
"Ruben Bridgewater <ruben.bridgewater@fintura.de>",
+ "Matt Lewis <matthew.lewis@socialsignin.co.uk>",
"Réda Housni Alaoui <reda.housnialaoui@gmail.com>",
- "Aseem Bansal <aseembansal@live.com>",
"ngiebel <ngiebel@starkinvestments.com>",
"Sammy Jelin <sjelin@gmail.com>",
"Jonas Pommerening <jonas.pommerening@aixigo.de>",
"Sergei Startsev <ai@programist.ru>",
+ "Aseem Bansal <aseembansal@live.com>",
"Sergey Simonchik <sergey.simonchik@gmail.com>",
"Jonathan Freeman <freethejazz@gmail.com>",
+ "Shane Russell <shane1337@gmail.com>",
"Josh <joshhunt180@gmail.com>",
"Greenkeeper <support@greenkeeper.io>",
- "Shane Russell <shane1337@gmail.com>",
- "ChangZhuo Chen (陳昌倬) <czchen@gmail.com>",
- "Andrew Morris <voltrevo@gmail.com>",
+ "Cyrus Chan <chan1cyrus2@gmail.com>",
"Stefan Dragnev <dragnev@telerik.com>",
- "KJ Tsanaktsidis <kjtsanaktsidis@gmail.com>",
"Steve Mao <maochenyan@gmail.com>",
"Steve Mao <steve.mao@healthinteract.com.au>",
"Steve Van Opstal <stevevanopstal@gmail.com>",
- "Hugues Malphettes <hmalphettes@gmail.com>",
"Sylvain Hamel <sylvainhamel0@gmail.com>",
- "Igor Minar <igor@angularjs.org>",
+ "KJ Tsanaktsidis <kjtsanaktsidis@gmail.com>",
+ "ChangZhuo Chen (陳昌倬) <czchen@gmail.com>",
+ "Hugues Malphettes <hmalphettes@gmail.com>",
"Terry <zhangwenlp@vip.qq.com>",
- "Igor Minar <iiminar@gmail.com>",
"Thomas Parisot <thomas@oncle-tom.net>",
- "Keen Yee Liau <kyliau@google.com>",
+ "Igor Minar <igor@angularjs.org>",
+ "Igor Minar <iiminar@gmail.com>",
"Tom Erik Støwer <tomerik@getkahoot.com>",
+ "Keen Yee Liau <kyliau@google.com>",
"Kelly Jensen <kellyrayj@gmail.com>",
"Kevin Huang <kevinziwenhuang@gmail.com>",
- "Bryan Smith <bryanrsmith@gmail.com>",
- "Kevin WENNER <kevin.wenner@massmotionmedia.com>",
+ "Andrew Morris <voltrevo@gmail.com>",
"Parashuram <code@r.nparashuram.com>",
"Vivek Ganesan <caliberoviv@gmail.com>",
"Vladimir Starkov <iamstarkov@users.noreply.github.com>",
+ "Kevin WENNER <kevin.wenner@massmotionmedia.com>",
"Pat Tullmann <pt@bebop.co>",
- "Bulat Shakirzyanov <mallluhuct@gmail.com>",
"PatrickJS <github@gdi2290.com>",
"Levi Thomason <me@levithomason.com>",
- "DarthCharles <carlos.darth@gmail.com>",
"James Ford <jford@psyked.co.uk>",
- "David Herges <dherges@users.noreply.github.com>",
+ "comdiv <fagim.sadykov@gmail.com>",
"Luke Page <luke.a.page@gmail.com>",
+ "Bryan Smith <bryanrsmith@gmail.com>",
"James Talmage <james@talmage.io>",
- "comdiv <fagim.sadykov@gmail.com>",
- "Ethan J. Brown <ethan_j_brown@hotmail.com>",
- "Ezra Brooks <ezra.m.brooks@gmail.com>",
+ "DarthCharles <carlos.darth@gmail.com>",
+ "David Herges <dherges@users.noreply.github.com>",
"Richard Harrington <rwharrington87@gmail.com>",
- "Filipe Guerra <alias.mac@gmail.com>",
+ "Ethan J. Brown <ethan_j_brown@hotmail.com>",
"karmarunnerbot <karmarunnerbot@gmail.com>",
"Roarke Gaskill <roarke.gaskill@gmail.com>",
- "David Pärsson <david@parsson.se>",
+ "Ezra Brooks <ezra.m.brooks@gmail.com>",
+ "Bulat Shakirzyanov <mallluhuct@gmail.com>",
"Robert Stein <SteinRobert@users.noreply.github.com>",
- "Jurko Gospodnetić <jurko.gospodnetic@pke.hr>",
- "Justin Ridgewell <jridgewell@users.noreply.github.com>",
"KahWee Teng <t@kw.sg>",
"Karl Lindmark <karl.lindmark@ninetwozero.com>",
"Karol Fabjańczuk <karol.fabjanczuk@lemondemon.pl>",
@@ -317,7 +316,6 @@
"Christian Weiss <cweiss@stripe.com>",
"Christopher Hiller <chiller@badwing.com>",
"Ciro S. Costa <ciro.costa@usp.br>",
- "Cyrus Chan <chan1cyrus2@gmail.com>",
"Daan Stolp <mail@daanstolp.nl>",
"Damien Choizit <damien.choizit@gmail.com>",
"Dan Siwiec <daniel.siwiec@gmail.com>",
@@ -379,7 +377,9 @@
"Jonathan Niles <jniles@users.noreply.github.com>",
"Josh Lory <josh.lory@code.org>",
"João Marcos Duarte <joumd86@gmail.com>",
- "Julian Connor <julian.connor@venmo.com>"
+ "Julian Connor <julian.connor@venmo.com>",
+ "Jurko Gospodnetić <jurko.gospodnetic@pke.hr>",
+ "Justin Ridgewell <jridgewell@users.noreply.github.com>"
],
"dependencies": {
"bluebird": "^3.3.0",
@@ -483,7 +483,7 @@
"engines": {
"node": ">= 8"
},
- "version": "4.0.1",
+ "version": "4.1.0",
"license": "MIT",
"scripts": {
"lint": "eslint . --ext js --ignore-pattern *.tpl.js",

static/karma.js

@@ -72,12 +72,27 @@
childWindow.close()
}
childWindow = opener(url)
- // run context on parent element and dynamically loading scripts
+ // run context on parent element (client_with_context)
+ // using window.__karma__.scriptUrls to get the html element strings and load them dynamically
} else if (url !== 'about:blank') {
var loadScript = function (idx) {
if (idx < window.__karma__.scriptUrls.length) {
- var ele = document.createElement('script')
- ele.src = window.__karma__.scriptUrls[idx]
+ var parser = new DOMParser()
+ // Revert escaped characters with special roles in HTML before parsing
+ var string = window.__karma__.scriptUrls[idx]
+ .replace(/\\x3C/g, '<')
+ .replace(/\\x3E/g, '>')
+ var doc = parser.parseFromString(string, 'text/html')
+ var ele = doc.head.firstChild || doc.body.firstChild
+ // script elements created by DomParser are marked as unexecutable,
+ // create a new script element manually and copy necessary properties
+ // so it is executable
+ if (ele.tagName && ele.tagName.toLowerCase() === 'script') {
+ var tmp = ele
+ ele = document.createElement('script')
+ ele.src = tmp.src
+ ele.crossOrigin = tmp.crossOrigin
+ }
ele.onload = function () {
loadScript(idx + 1)
}
@@ -140,20 +155,22 @@
// error during js file loading (most likely syntax error)
// we are not going to execute at all. `window.onerror` callback.
this.error = function (messageOrEvent, source, lineno, colno, error) {
- var message = messageOrEvent
- var location = getLocation(source, lineno, colno)
+ var message
+ if (typeof messageOrEvent === 'string') {
+ message = messageOrEvent
+ var location = getLocation(source, lineno, colno)
if (location !== '') {
message += '\nat ' + location
}
-
- if (error) {
+ if (error && error.stack) {
message += '\n\n' + error.stack
}
-
- // create an object with the string representation of the message to ensure all its content is properly
- // transferred to the console log
- message = {message: message, str: message.toString()}
+ } else {
+ // create an object with the string representation of the message to
+ // ensure all its content is properly transferred to the console log
+ message = {message: messageOrEvent, str: messageOrEvent.toString()}
+ }
socket.emit('karma_error', message)
this.complete()