aboutsummaryrefslogtreecommitdiffstats
path: root/test/angular-mocks.js
diff options
context:
space:
mode:
authorIgor Minar2010-09-26 23:45:05 -0700
committerIgor Minar2010-09-27 15:10:05 -0700
commit984acdc6270df1dee5796ed44efebfb9ff6706c7 (patch)
tree770d3f78e3db85740b0c5cf59edf32356060d505 /test/angular-mocks.js
parent3eec8c1a517f8b93a5afd15b7f83b33c5df7e54b (diff)
downloadangular.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/angular-mocks.js')
-rw-r--r--test/angular-mocks.js10
1 files changed, 8 insertions, 2 deletions
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;
}
}