From 66a0ac6f06a668eda3f7c68ee32095200580afd8 Mon Sep 17 00:00:00 2001 From: basos9 Date: Thu, 13 Dec 2012 14:50:46 +0200 Subject: [PATCH 1/2] ADD abort tests Conflicts: test/unit.js --- test/unit.js | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/test/unit.js b/test/unit.js index 273bc25..51afce7 100644 --- a/test/unit.js +++ b/test/unit.js @@ -121,3 +121,116 @@ test( "stress test", function() { }); } }); + + + +function findHead(url1, url2) { + function rquote(str) { + return str.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); + }; + var t, obj, + reg1 = new RegExp(rquote(url1), "g"), + reg2 = url2 ? new RegExp(rquote(url2), "g") : null, + head = $( "head" )[ 0 ] || document.documentElement, + res = [], + children = head.children; + for (t=0;t Date: Thu, 13 Dec 2012 15:24:50 +0200 Subject: [PATCH 2/2] FIX wrong success for an erronous fetch, after an abort of a legit fetch This bug can be manifested when a pending fetch of a legit resource (200 response) is aborted and afterwards a new fetch that leads to error (e.g. 404) is issued. At the time, the second request finishes the lastValue has the aborted data of the previous fetch (callback is executed even on aborted), YIELDING the second (normally erroneus response) to be signaled as successfull. --- src/jquery.jsonp.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/jquery.jsonp.js b/src/jquery.jsonp.js index 7400751..5024363 100644 --- a/src/jquery.jsonp.js +++ b/src/jquery.jsonp.js @@ -199,6 +199,9 @@ } else { + // reset lastValue (from stale aborts) + lastValue = void 0; + // Install the generic callback // (BEWARE: global namespace pollution ahoy) win[ successCallbackName ] = genericCallback;