Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: chrome/test/data/extensions/api_test/cookies/events/test.js

Issue 8725019: Move another bunch of extension API tests to manifest_version 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 // These are the cookies we expect to see along the way.
6 var SET_REMOVE_COOKIE = {
7 name: 'testSetRemove',
8 value: '42',
9 domain: 'a.com',
10 hostOnly: true,
11 path: '/',
12 secure: false,
13 httpOnly: false,
14 session: false,
15 expirationDate: 12345678900,
16 storeId: "0"
17 };
18
19 var OVERWRITE_COOKIE_PRE = {
20 name: 'testOverwrite',
21 value: '42',
22 domain: 'a.com',
23 hostOnly: true,
24 path: '/',
25 secure: false,
26 httpOnly: false,
27 session: false,
28 expirationDate: 12345678900,
29 storeId: "0"
30 };
31
32 var OVERWRITE_COOKIE_POST = {
33 name: 'testOverwrite',
34 value: '43',
35 domain: 'a.com',
36 hostOnly: true,
37 path: '/',
38 secure: false,
39 httpOnly: false,
40 session: false,
41 expirationDate: 12345678900,
42 storeId: "0"
43 };
44
45 chrome.test.runTests([
46 function testSet() {
47 var testCompleted = chrome.test.callbackAdded();
48 var listener = function (info) {
49 chrome.test.assertFalse(info.removed);
50 chrome.test.assertEq('explicit', info.cause);
51 chrome.test.assertEq(SET_REMOVE_COOKIE, info.cookie);
52 testCompleted();
53 };
54
55 chrome.cookies.onChanged.addListener(listener);
56 chrome.cookies.set({
57 url: 'http://a.com/path',
58 name: 'testSetRemove',
59 value: '42',
60 expirationDate: 12345678900
61 }, function () {
62 chrome.cookies.onChanged.removeListener(listener);
63 });
64 },
65 function testRemove() {
66 var testCompleted = chrome.test.callbackAdded();
67 var listener = function (info) {
68 chrome.test.assertTrue(info.removed);
69 chrome.test.assertEq('explicit', info.cause);
70 chrome.test.assertEq(SET_REMOVE_COOKIE, info.cookie);
71 testCompleted();
72 };
73
74 chrome.cookies.onChanged.addListener(listener);
75 chrome.cookies.remove({
76 url: 'http://a.com/path',
77 name: 'testSetRemove'
78 }, function () {
79 chrome.cookies.onChanged.removeListener(listener);
80 });
81 },
82 function overwriteFirstSet() {
83 var testCompleted = chrome.test.callbackAdded();
84 var listener = function (info) {
85 chrome.test.assertFalse(info.removed);
86 chrome.test.assertEq('explicit', info.cause);
87 chrome.test.assertEq(OVERWRITE_COOKIE_PRE, info.cookie);
88 testCompleted();
89 };
90
91 chrome.cookies.onChanged.addListener(listener);
92 chrome.cookies.set({
93 url: 'http://a.com/path',
94 name: 'testOverwrite',
95 value: '42',
96 expirationDate: 12345678900
97 }, function () {
98 chrome.cookies.onChanged.removeListener(listener);
99 });
100 },
101 function overwriteSecondSet() {
102 var removeCompleted = chrome.test.callbackAdded();
103 var setCompleted = chrome.test.callbackAdded();
104 var listenerRemove = function (info) {
105 if (info.removed) {
106 chrome.test.assertEq('overwrite', info.cause);
107 chrome.test.assertEq(OVERWRITE_COOKIE_PRE, info.cookie);
108 removeCompleted();
109 }
110 };
111 var listenerSet = function (info) {
112 if (!info.removed) {
113 chrome.test.assertEq('explicit', info.cause);
114 chrome.test.assertEq(OVERWRITE_COOKIE_POST, info.cookie);
115 setCompleted();
116 }
117 };
118 chrome.cookies.onChanged.addListener(listenerRemove);
119 chrome.cookies.onChanged.addListener(listenerSet);
120 chrome.cookies.set({
121 url: 'http://a.com/path',
122 name: 'testOverwrite',
123 value: '43',
124 expirationDate: 12345678900
125 }, function () {
126 chrome.cookies.onChanged.removeListener(listenerRemove);
127 chrome.cookies.onChanged.removeListener(listenerSet);
128 });
129 },
130 function overwriteExpired() {
131 var setCompleted = chrome.test.callbackAdded();
132 var listener = function (info) {
133 chrome.test.assertTrue(info.removed);
134 chrome.test.assertEq('expired_overwrite', info.cause);
135 chrome.test.assertEq(OVERWRITE_COOKIE_POST, info.cookie);
136 setCompleted();
137 };
138 chrome.cookies.onChanged.addListener(listener);
139 chrome.cookies.set({
140 url: 'http://a.com/path',
141 name: 'testOverwrite',
142 value: '43',
143 expirationDate: 1
144 }, function () {
145 chrome.cookies.onChanged.removeListener(listener);
146 });
147 }
148 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698