Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /**
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 var testGenerator = testSteps();
8 function testSteps()
9 {
10 const name = this.window ? window.location.pathname : "Splendid Test";
12 let request = indexedDB.open(name, 1);
13 request.onerror = errorHandler;
14 request.onupgradeneeded = grabEventAndContinueHandler;
15 let event = yield undefined;
17 let db = event.target.result;
18 db.addEventListener("error", function(event) {
19 event.preventDefault();
20 }, false);
22 let objectStore = db.createObjectStore("foo", { autoIncrement: true });
24 request = objectStore.add({});
25 request.onerror = errorHandler;
26 request.onsuccess = grabEventAndContinueHandler;
27 event = yield undefined;
29 let key1 = event.target.result;
31 request = objectStore.put({}, key1);
32 request.onerror = errorHandler;
33 request.onsuccess = grabEventAndContinueHandler;
34 event = yield undefined;
36 is(event.target.result, key1, "put gave the same key back");
38 let key2 = 10;
40 request = objectStore.put({}, key2);
41 request.onerror = errorHandler;
42 request.onsuccess = grabEventAndContinueHandler;
43 event = yield undefined;
45 is(event.target.result, key2, "put gave the same key back");
47 key2 = 100;
49 request = objectStore.add({}, key2);
50 request.onerror = errorHandler;
51 request.onsuccess = grabEventAndContinueHandler;
52 event = yield undefined;
54 is(event.target.result, key2, "put gave the same key back");
56 try {
57 objectStore.put({});
58 ok(true, "put with no key should not throw with autoIncrement!");
59 }
60 catch (e) {
61 ok(false, "put with no key threw with autoIncrement");
62 }
64 try {
65 objectStore.put({});
66 ok(true, "put with no key should not throw with autoIncrement!");
67 }
68 catch (e) {
69 ok(false, "put with no key threw with autoIncrement");
70 }
72 try {
73 objectStore.delete();
74 ok(false, "remove with no key should throw!");
75 }
76 catch (e) {
77 ok(true, "remove with no key threw");
78 }
80 objectStore = db.createObjectStore("bar");
82 try {
83 objectStore.add({});
84 ok(false, "add with no key should throw!");
85 }
86 catch (e) {
87 ok(true, "add with no key threw");
88 }
90 try {
91 objectStore.put({});
92 ok(false, "put with no key should throw!");
93 }
94 catch (e) {
95 ok(true, "put with no key threw");
96 }
98 try {
99 objectStore.put({});
100 ok(false, "put with no key should throw!");
101 }
102 catch (e) {
103 ok(true, "put with no key threw");
104 }
106 try {
107 objectStore.delete();
108 ok(false, "remove with no key should throw!");
109 }
110 catch (e) {
111 ok(true, "remove with no key threw");
112 }
114 objectStore = db.createObjectStore("baz", { keyPath: "id" });
116 try {
117 objectStore.add({});
118 ok(false, "add with no key should throw!");
119 }
120 catch (e) {
121 ok(true, "add with no key threw");
122 }
124 try {
125 objectStore.add({id:5}, 5);
126 ok(false, "add with inline key and passed key should throw!");
127 }
128 catch (e) {
129 ok(true, "add with inline key and passed key threw");
130 }
132 try {
133 objectStore.put({});
134 ok(false, "put with no key should throw!");
135 }
136 catch (e) {
137 ok(true, "put with no key threw");
138 }
140 try {
141 objectStore.put({});
142 ok(false, "put with no key should throw!");
143 }
144 catch (e) {
145 ok(true, "put with no key threw");
146 }
148 try {
149 objectStore.delete();
150 ok(false, "remove with no key should throw!");
151 }
152 catch (e) {
153 ok(true, "remove with no key threw");
154 }
156 key1 = 10;
158 request = objectStore.add({id:key1});
159 request.onerror = errorHandler;
160 request.onsuccess = grabEventAndContinueHandler;
161 event = yield undefined;
163 is(event.target.result, key1, "add gave back the same key");
165 request = objectStore.put({id:10});
166 request.onerror = errorHandler;
167 request.onsuccess = grabEventAndContinueHandler;
168 event = yield undefined;
170 is(event.target.result, key1, "put gave back the same key");
172 request = objectStore.put({id:10});
173 request.onerror = errorHandler;
174 request.onsuccess = grabEventAndContinueHandler;
175 event = yield undefined;
177 is(event.target.result, key1, "put gave back the same key");
179 request = objectStore.add({id:10});
180 request.addEventListener("error", new ExpectError("ConstraintError", true));
181 request.onsuccess = unexpectedSuccessHandler;
182 event = yield undefined;
184 try {
185 objectStore.add({}, null);
186 ok(false, "add with null key should throw!");
187 }
188 catch (e) {
189 ok(true, "add with null key threw");
190 }
192 try {
193 objectStore.put({}, null);
194 ok(false, "put with null key should throw!");
195 }
196 catch (e) {
197 ok(true, "put with null key threw");
198 }
200 try {
201 objectStore.put({}, null);
202 ok(false, "put with null key should throw!");
203 }
204 catch (e) {
205 ok(true, "put with null key threw");
206 }
208 try {
209 objectStore.delete({}, null);
210 ok(false, "remove with null key should throw!");
211 }
212 catch (e) {
213 ok(true, "remove with null key threw");
214 }
216 objectStore = db.createObjectStore("bazing", { keyPath: "id",
217 autoIncrement: true });
219 request = objectStore.add({});
220 request.onerror = errorHandler;
221 request.onsuccess = grabEventAndContinueHandler;
222 event = yield undefined;
224 key1 = event.target.result;
226 request = objectStore.put({id:key1});
227 request.onerror = errorHandler;
228 request.onsuccess = grabEventAndContinueHandler;
229 event = yield undefined;
231 is(event.target.result, key1, "put gave the same key back");
233 key2 = 10;
235 request = objectStore.put({id:key2});
236 request.onerror = errorHandler;
237 request.onsuccess = grabEventAndContinueHandler;
238 event = yield undefined;
240 is(event.target.result, key2, "put gave the same key back");
242 try {
243 objectStore.put({});
244 ok(true, "put with no key should not throw with autoIncrement!");
245 }
246 catch (e) {
247 ok(false, "put with no key threw with autoIncrement");
248 }
250 try {
251 objectStore.put({});
252 ok(true, "put with no key should not throw with autoIncrement!");
253 }
254 catch (e) {
255 ok(false, "put with no key threw with autoIncrement");
256 }
258 try {
259 objectStore.delete();
260 ok(false, "remove with no key should throw!");
261 }
262 catch (e) {
263 ok(true, "remove with no key threw");
264 }
266 try {
267 objectStore.add({id:5}, 5);
268 ok(false, "add with inline key and passed key should throw!");
269 }
270 catch (e) {
271 ok(true, "add with inline key and passed key threw");
272 }
274 request = objectStore.delete(key2);
275 request.onerror = errorHandler;
276 request.onsuccess = grabEventAndContinueHandler;
277 event = yield undefined;
279 finishTest();
280 yield undefined;
281 }