Skip to content

Commit

Permalink
Added a test to verify that transports that fail to parse responses w…
Browse files Browse the repository at this point in the history
…hile connecting indeed do fall back.

- Also fixed some long polling logic

#2506
  • Loading branch information
NTaylorMullen committed Oct 24, 2013
1 parent f868629 commit 891f599
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
/// <summary>Starts the long polling connection</summary>
/// <param name="connection" type="signalR">The SignalR connection to start</param>
var that = this,
initialConnectedFired = false,
fireConnect = function () {
if (initialConnectedFired) {
return;
}
initialConnectedFired = true;
onSuccess();
tryFailConnect = fireConnect = $.noop;

connection.log("Longpolling connected.");
onSuccess();

// Reset onFailed to null because it shouldn't be called again
onFailed = null;
},
tryFailConnect = function () {
if (onFailed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@

QUnit.module("Response redirection facts");

QUnit.asyncTimeoutTest("Transport connect fails on response redirection causing negotiate to fallback through all transports.", testUtilities.defaultTestTimeout * 4000, function (end, assert, testName) {
var connection = buildRedirectConnection("connect", end, assert, testName, false);

connection.start().done(function () {
// Dont fail if we're long polling, just stop, this is primarily because there's no init message and there's a race to determine if the tranport connected successfully
if (connection.transport.name === "longPolling") {
end();
}

assert.fail("Connection was started successfully.");
end();
}).fail(function () {
assert.comment("Connection start deferred failure was triggered.");
end();
});

// Cleanup
return function () {
connection.stop();
};
});

testUtilities.runWithAllTransports(function (transport) {
QUnit.asyncTimeoutTest(transport + ": Negotiate fails on response redirection.", testUtilities.defaultTestTimeout, function (end, assert, testName) {
var connection = buildRedirectConnection("negotiate", end, assert, testName, false);
Expand Down

0 comments on commit 891f599

Please sign in to comment.