Skip to content

Commit d8dad3c

Browse files
IgorMinarjamessharp
authored andcommitted
refactor($browser): remove faulty 20+ cookies warning
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 angular#1712
1 parent 99f5179 commit d8dad3c

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

src/ng/browser.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,15 @@ function Browser(window, document, $log, $sniffer) {
276276
} else {
277277
if (isString(value)) {
278278
cookieLength = (rawDocument.cookie = escape(name) + '=' + escape(value) + ';path=' + cookiePath).length + 1;
279+
280+
// per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:
281+
// - 300 cookies
282+
// - 20 cookies per unique domain
283+
// - 4096 bytes per cookie
279284
if (cookieLength > 4096) {
280285
$log.warn("Cookie '"+ name +"' possibly not set or overflowed because it was too large ("+
281286
cookieLength + " > 4096 bytes)!");
282287
}
283-
if (lastCookies.length > 20) {
284-
$log.warn("Cookie '"+ name +"' possibly not set or overflowed because too many cookies " +
285-
"were already set (" + lastCookies.length + " > 20 )");
286-
}
287288
}
288289
}
289290
} else {

test/ng/browserSpecs.js

-27
Original file line numberDiff line numberDiff line change
@@ -277,33 +277,6 @@ describe('browser', function() {
277277

278278
expect(browser.cookies().x).toEqual('shortVal');
279279
});
280-
281-
it('should log warnings when 20 cookies per domain storage limit is reached', function() {
282-
var i, str, cookieStr;
283-
284-
for (i=0; i<20; i++) {
285-
str = '' + i;
286-
browser.cookies(str, str);
287-
}
288-
289-
i=0;
290-
for (str in browser.cookies()) {
291-
i++;
292-
}
293-
expect(i).toEqual(20);
294-
expect(logs.warn).toEqual([]);
295-
cookieStr = document.cookie;
296-
297-
browser.cookies('one', 'more');
298-
expect(logs.warn).toEqual([]);
299-
300-
//if browser dropped a cookie (very likely), make sure that the cache is not out of sync
301-
if (document.cookie === cookieStr) {
302-
expect(size(browser.cookies())).toEqual(20);
303-
} else {
304-
expect(size(browser.cookies())).toEqual(21);
305-
}
306-
});
307280
});
308281

309282

0 commit comments

Comments
 (0)