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/angular-mocks.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'test/angular-mocks.js') diff --git a/test/angular-mocks.js b/test/angular-mocks.js index b02fabaf..1a73a542 100644 --- a/test/angular-mocks.js +++ b/test/angular-mocks.js @@ -75,6 +75,7 @@ function MockBrowser() { }; self.cookieHash = {}; + self.lastCookieHash = {}; } MockBrowser.prototype = { @@ -103,12 +104,17 @@ MockBrowser.prototype = { if (value == undefined) { delete this.cookieHash[name]; } else { - if (isString(value)) { + if (isString(value) && //strings only + value.length <= 4096) { //strict cookie storage limits this.cookieHash[name] = value; } } } else { - return copy(this.cookieHash); + if (!equals(this.cookieHash, this.lastCookieHash)) { + this.lastCookieHash = copy(this.cookieHash); + this.cookieHash = copy(this.cookieHash); + } + return this.cookieHash; } } -- cgit v1.2.3