Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
refactor($browser): remove faulty 20+ cookies warning
Browse files Browse the repository at this point in the history
the warning is defunct (and the test is incorrect) so obviously nobody is using
it and it just takes up space.

also the browser behavior varies (ff and chrome allow up to 150 cookies, safari
even more), so it's not very useful.

Closes #1712
  • Loading branch information
IgorMinar committed Jan 8, 2013
1 parent 4cda028 commit afd6771
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
9 changes: 5 additions & 4 deletions src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,15 @@ function Browser(window, document, $log, $sniffer) {
} else {
if (isString(value)) {
cookieLength = (rawDocument.cookie = escape(name) + '=' + escape(value) + ';path=' + cookiePath).length + 1;

// per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:
// - 300 cookies
// - 20 cookies per unique domain
// - 4096 bytes per cookie
if (cookieLength > 4096) {
$log.warn("Cookie '"+ name +"' possibly not set or overflowed because it was too large ("+
cookieLength + " > 4096 bytes)!");
}
if (lastCookies.length > 20) {
$log.warn("Cookie '"+ name +"' possibly not set or overflowed because too many cookies " +
"were already set (" + lastCookies.length + " > 20 )");
}
}
}
} else {
Expand Down
27 changes: 0 additions & 27 deletions test/ng/browserSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,33 +277,6 @@ describe('browser', function() {

expect(browser.cookies().x).toEqual('shortVal');
});

it('should log warnings when 20 cookies per domain storage limit is reached', function() {
var i, str, cookieStr;

for (i=0; i<20; i++) {
str = '' + i;
browser.cookies(str, str);
}

i=0;
for (str in browser.cookies()) {
i++;
}
expect(i).toEqual(20);
expect(logs.warn).toEqual([]);
cookieStr = document.cookie;

browser.cookies('one', 'more');
expect(logs.warn).toEqual([]);

//if browser dropped a cookie (very likely), make sure that the cache is not out of sync
if (document.cookie === cookieStr) {
expect(size(browser.cookies())).toEqual(20);
} else {
expect(size(browser.cookies())).toEqual(21);
}
});
});


Expand Down

0 comments on commit afd6771

Please sign in to comment.