diff options
| author | Fredrik Bonander | 2013-02-06 10:30:40 +0100 | 
|---|---|---|
| committer | Igor Minar | 2013-02-07 02:36:25 -0800 | 
| commit | 7090924515214752b919b0c5630b3ea5e7c77223 (patch) | |
| tree | 9c46fcda873253e04d7e2ea88aa07a9ad793f796 /test/ng/browserSpecs.js | |
| parent | df744f3af46fc227a934f16cb63c7a6038e7133b (diff) | |
| download | angular.js-7090924515214752b919b0c5630b3ea5e7c77223.tar.bz2 | |
fix($cookies): set cookies on Safari&IE when base[href] is undefined
Safari and IE don't like being told to store cookies with path set to
undefined. This change ensures that if base[href] (from which cookie path
is derived) is undefined then the cookie path defaults to ''.
The test verifies that the cookie is set instead of checking that cookie has correct path,
this is due to that cookie meta information is not avabile once the cookie is set.
Closes #1190, #1191
Diffstat (limited to 'test/ng/browserSpecs.js')
| -rw-r--r-- | test/ng/browserSpecs.js | 16 | 
1 files changed, 14 insertions, 2 deletions
| diff --git a/test/ng/browserSpecs.js b/test/ng/browserSpecs.js index 53ca2642..e989330b 100644 --- a/test/ng/browserSpecs.js +++ b/test/ng/browserSpecs.js @@ -279,6 +279,18 @@ describe('browser', function() {        });      }); +    describe('put via cookies(cookieName, string), if no <base href> ', function () { +      beforeEach(function () { +        fakeDocument.basePath = undefined; +      }); + +      it('should default path in cookie to "" (empty string)', function () { +        browser.cookies('cookie', 'bender'); +        // This only fails in Safari and IE when cookiePath returns undefined +        // Where it now succeeds since baseHref return '' instead of undefined          +        expect(document.cookie).toEqual('cookie=bender'); +      }); +    });      describe('get via cookies()[cookieName]', function() { @@ -555,9 +567,9 @@ describe('browser', function() {        expect(browser.baseHref()).toEqual('/base/path/');      }); -    it('should return undefined if no <base href>', function() { +    it('should return \'\' (empty string) if no <base href>', function() {        fakeDocument.basePath = undefined; -      expect(browser.baseHref()).toBeUndefined(); +      expect(browser.baseHref()).toEqual('');      });      it('should remove domain from <base href>', function() { | 
