From d5ccabce600efb10092fdf0ae033c009026bf4cb Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 26 Oct 2011 12:15:07 -0700 Subject: fix(ng:view): ignore stale xhr callbacks A lot of badness happens when we don't ignore stale xhrs. These raceconditions are only apparent when user clicks through the app very quckly without waiting for routes to fully load. Closes #619 --- test/widgetsSpec.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index adbdf94e..4aa36428 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -539,6 +539,26 @@ describe("widget", function() { expect(rootScope.log).toEqual(['parent', 'init', 'child']); }); + + it('should discard pending xhr callbacks if a new route is requested before the current ' + + 'finished loading', function() { + // this is a test for a bad race condition that affected feedback + + $route.when('/foo', {template: 'myUrl1'}); + $route.when('/bar', {template: 'myUrl2'}); + + expect(rootScope.$element.text()).toEqual(''); + + $location.path('/foo'); + $browser.xhr.expectGET('myUrl1').respond('