Skip to content

Commit

Permalink
fix: report correct transportName when running inside a new window
Browse files Browse the repository at this point in the history
Since karma-runner/karma@471e3a8 Karma can run the tests in a new window, in which case we need to access the parent window through `window.opener`.
  • Loading branch information
vojtajina committed Dec 7, 2013
1 parent ff96c63 commit ead8a77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ var indexOf = function(collection, item) {

// TODO(vojta): Karma might provide this
var getCurrentTransport = function() {
var location = window.parent.location;
var parentWindow = window.opener || window.parent;
var location = parentWindow.location;
var hostname = location.protocol + '//' + location.host;

// probably running in debug.html (there's no socket.io) or in debug mode with socket io but no socket on this host
if (!window.parent.io || !window.parent.io.sockets[location.protocol + '//' + location.host]) {
// Probably running in debug.html (there's no socket.io),
// or in debug mode with socket.io but no socket on this host.
if (!parentWindow.io || !parentWindow.io.sockets[hostname]) {
return null;
}

return window.parent.io.sockets[location.protocol + '//' + location.host].transport.name;
return parentWindow.io.sockets[hostname].transport.name;
};


Expand Down

0 comments on commit ead8a77

Please sign in to comment.