diff options
| author | Igor Minar | 2010-09-26 23:45:05 -0700 |
|---|---|---|
| committer | Igor Minar | 2010-09-27 15:10:05 -0700 |
| commit | 984acdc6270df1dee5796ed44efebfb9ff6706c7 (patch) | |
| tree | 770d3f78e3db85740b0c5cf59edf32356060d505 /test/servicesSpec.js | |
| parent | 3eec8c1a517f8b93a5afd15b7f83b33c5df7e54b (diff) | |
| download | angular.js-984acdc6270df1dee5796ed44efebfb9ff6706c7.tar.bz2 | |
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.
Diffstat (limited to 'test/servicesSpec.js')
| -rw-r--r-- | test/servicesSpec.js | 24 |
1 files changed, 24 insertions, 0 deletions
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'}); + }); }); |
