Skip to content

Commit acfab49

Browse files
First test if the browser can set characters outside ASCII range
1 parent b7e13a5 commit acfab49

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

‎test/tests.js‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,60 @@ test('RFC 6265 - disallowed characters in cookie-name', function () {
369369
Cookies.remove(' ');
370370
});
371371

372+
test('cookie-name - browser processing for 2 bytes characters', function () {
373+
expect(2);
374+
375+
Cookies.set('ã', 'v');
376+
strictEqual(Cookies.get('ã'), 'v', 'should handle the ã character');
377+
strictEqual(document.cookie, '%C3%A3=v', 'should encode the ã character');
378+
Cookies.remove('ã');
379+
});
380+
381+
test('cookie-name - browser processing for 3 bytes characters', function () {
382+
expect(2);
383+
384+
Cookies.set('₯', 'v');
385+
strictEqual(Cookies.get('₯'), 'v', 'should handle the ₯ character');
386+
strictEqual(document.cookie, '%E2%82%AF=v', 'should encode the ₯ character');
387+
Cookies.remove('₯');
388+
});
389+
390+
test('cookie-name - browser processing for 4 bytes characters', function () {
391+
expect(2);
392+
393+
Cookies.set('𩸽', 'v');
394+
strictEqual(Cookies.get('𩸽'), 'v', 'should_handle the 𩸽 character');
395+
strictEqual(document.cookie, '%F0%A9%B8%BD=v', 'should encode the 𩸽 character');
396+
Cookies.remove('𩸽');
397+
});
398+
399+
test('cookie-value - browser processing for 2 bytes characters', function () {
400+
expect(2);
401+
402+
Cookies.set('c', 'ã');
403+
strictEqual(Cookies.get('c'), 'ã', 'should handle the ã character');
404+
strictEqual(document.cookie, 'c=%C3%A3', 'should encode the ã character');
405+
Cookies.remove('c');
406+
});
407+
408+
test('cookie-value - browser processing for 3 bytes characters', function () {
409+
expect(2);
410+
411+
Cookies.set('c', '₯');
412+
strictEqual(Cookies.get('c'), '₯', 'should handle the ₯ character');
413+
strictEqual(document.cookie, 'c=%E2%82%AF', 'should encode the ₯ character');
414+
Cookies.remove('c');
415+
});
416+
417+
test('cookie-value - browser processing for 4 bytes characters', function () {
418+
expect(2);
419+
420+
Cookies.set('c', '𩸽');
421+
strictEqual(Cookies.get('c'), '𩸽', 'should handle the 𩸽 character');
422+
strictEqual(document.cookie, 'c=%F0%A9%B8%BD', 'should encode the 𩸽 character');
423+
Cookies.remove('c');
424+
});
425+
372426
//test('server processing for 2 bytes characters', function () {
373427
// expect(1);
374428
// Cookies.set('ã', 'ã');

0 commit comments

Comments
 (0)