From 984acdc6270df1dee5796ed44efebfb9ff6706c7 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 26 Sep 2010 23:45:05 -0700 Subject: Reworked the cookie synchronization between cookie service, $browser and document.cookie. Now we finally correctly handle situations when browser refuses to set a cookie, due to storage quota or other (file:// protocol) limitations. --- test/servicesSpec.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/servicesSpec.js') diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 258af46b..f40b8f5e 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -438,6 +438,7 @@ describe("service", function(){ it('should remove a cookie when a $cookies property is deleted', function() { scope.$cookies.oatmealCookie = 'nom nom'; scope.$eval(); + scope.$browser.poll(); expect(scope.$browser.cookies()). toEqual({'preexisting': 'oldCookie', 'oatmealCookie':'nom nom'}); @@ -446,6 +447,29 @@ describe("service", function(){ expect(scope.$browser.cookies()).toEqual({'preexisting': 'oldCookie'}); }); + + + it('should drop or reset cookies that browser refused to store', function() { + var i, longVal; + + for (i=0; i<5000; i++) { + longVal += '*'; + } + + //drop if no previous value + scope.$cookies.longCookie = longVal; + scope.$eval(); + expect(scope.$cookies).toEqual({'preexisting': 'oldCookie'}); + + + //reset if previous value existed + scope.$cookies.longCookie = 'shortVal'; + scope.$eval(); + expect(scope.$cookies).toEqual({'preexisting': 'oldCookie', 'longCookie': 'shortVal'}); + scope.$cookies.longCookie = longVal; + scope.$eval(); + expect(scope.$cookies).toEqual({'preexisting': 'oldCookie', 'longCookie': 'shortVal'}); + }); }); -- cgit v1.2.3