From a8b250cf6a89cf064f67ecb1e2c040cc224d91e9 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 24 Dec 2013 09:51:12 -0800 Subject: [PATCH] fix(client): show error if an adapter is removed Before we would only show the error when this happens in the first run. It's not likely to happen, but if the adapter is removed in a subsequent run, it would throw "null is not a function". --- client/karma.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/karma.js b/client/karma.js index 8d550d901..a71833fa0 100644 --- a/client/karma.js +++ b/client/karma.js @@ -170,6 +170,10 @@ var Karma = function(socket, iframe, opener, navigator, location) { } }; + var UNIMPLEMENTED_START = function() { + this.error('You need to include some adapter that implements __karma__.start method!'); + }; + // all files loaded, let's start the execution this.loaded = function() { // has error -> cancel @@ -178,7 +182,7 @@ var Karma = function(socket, iframe, opener, navigator, location) { } // remove reference to child iframe - this.start = null; + this.start = UNIMPLEMENTED_START; }; this.store = function(key, value) { @@ -199,9 +203,7 @@ var Karma = function(socket, iframe, opener, navigator, location) { // supposed to be overriden by the context // TODO(vojta): support multiple callbacks (queue) - this.start = function() { - this.error('You need to include some adapter that implements __karma__.start method!'); - }; + this.start = UNIMPLEMENTED_START; socket.on('execute', function(cfg) { // reset hasError and reload the iframe