1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // These are the cookies we expect to see along the way.
6 var SET_REMOVE_COOKIE
= {
15 expirationDate
: 12345678900,
19 var OVERWRITE_COOKIE_PRE
= {
20 name
: 'testOverwrite',
28 expirationDate
: 12345678900,
32 var OVERWRITE_COOKIE_POST
= {
33 name
: 'testOverwrite',
41 expirationDate
: 12345678900,
45 chrome
.test
.runTests([
47 chrome
.test
.listenOnce(chrome
.cookies
.onChanged
, function (info
) {
48 chrome
.test
.assertFalse(info
.removed
);
49 chrome
.test
.assertEq('explicit', info
.cause
);
50 chrome
.test
.assertEq(SET_REMOVE_COOKIE
, info
.cookie
);
53 url
: 'http://a.com/path',
54 name
: 'testSetRemove',
56 expirationDate
: 12345678900
59 function testRemove() {
60 chrome
.test
.listenOnce(chrome
.cookies
.onChanged
, function (info
) {
61 chrome
.test
.assertTrue(info
.removed
);
62 chrome
.test
.assertEq('explicit', info
.cause
);
63 chrome
.test
.assertEq(SET_REMOVE_COOKIE
, info
.cookie
);
65 chrome
.cookies
.remove({
66 url
: 'http://a.com/path',
70 function overwriteFirstSet() {
71 chrome
.test
.listenOnce(chrome
.cookies
.onChanged
, function (info
) {
72 chrome
.test
.assertFalse(info
.removed
);
73 chrome
.test
.assertEq('explicit', info
.cause
);
74 chrome
.test
.assertEq(OVERWRITE_COOKIE_PRE
, info
.cookie
);
77 url
: 'http://a.com/path',
78 name
: 'testOverwrite',
80 expirationDate
: 12345678900
83 function overwriteSecondSet() {
84 var haveRemoved
= false;
86 var done
= chrome
.test
.listenForever(chrome
.cookies
.onChanged
,
89 chrome
.test
.assertEq('overwrite', info
.cause
);
90 chrome
.test
.assertEq(OVERWRITE_COOKIE_PRE
, info
.cookie
);
91 chrome
.test
.assertFalse(haveRemoved
);
92 chrome
.test
.assertFalse(haveSet
);
95 chrome
.test
.assertEq('explicit', info
.cause
);
96 chrome
.test
.assertEq(OVERWRITE_COOKIE_POST
, info
.cookie
);
97 chrome
.test
.assertTrue(haveRemoved
);
98 chrome
.test
.assertFalse(haveSet
);
101 if (haveRemoved
&& haveSet
) {
106 url
: 'http://a.com/path',
107 name
: 'testOverwrite',
109 expirationDate
: 12345678900
112 function overwriteExpired() {
113 chrome
.test
.listenOnce(chrome
.cookies
.onChanged
, function (info
) {
114 chrome
.test
.assertTrue(info
.removed
);
115 chrome
.test
.assertEq('expired_overwrite', info
.cause
);
116 chrome
.test
.assertEq(OVERWRITE_COOKIE_POST
, info
.cookie
);
119 url
: 'http://a.com/path',
120 name
: 'testOverwrite',