services/sync/tests/tps/test_sync.js

branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
equal deleted inserted replaced
-1:000000000000 0:23fd2c364571
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /*
5 * The list of phases mapped to their corresponding profiles. The object
6 * here must be in strict JSON format, as it will get parsed by the Python
7 * testrunner (no single quotes, extra comma's, etc).
8 */
9
10 var phases = { "phase1": "profile1",
11 "phase2": "profile2",
12 "phase3": "profile1",
13 "phase4": "profile2" };
14
15 /*
16 * Bookmark asset lists: these define bookmarks that are used during the test
17 */
18
19 // the initial list of bookmarks to be added to the browser
20 var bookmarks_initial = {
21 "menu": [
22 { uri: "http://www.google.com",
23 loadInSidebar: true,
24 tags: ["google", "computers", "internet", "www"],
25 changes: {
26 title: "Google",
27 loadInSidebar: false,
28 tags: ["google", "computers", "misc"],
29 }
30 },
31 { uri: "http://bugzilla.mozilla.org/show_bug.cgi?id=%s",
32 title: "Bugzilla",
33 keyword: "bz",
34 changes: {
35 keyword: "bugzilla"
36 }
37 },
38 { folder: "foldera" },
39 { uri: "http://www.mozilla.com" },
40 { separator: true },
41 { folder: "folderb" },
42 ],
43 "menu/foldera": [
44 { uri: "http://www.yahoo.com",
45 title: "testing Yahoo",
46 changes: {
47 location: "menu/folderb"
48 }
49 },
50 { uri: "http://www.cnn.com",
51 description: "This is a description of the site a at www.cnn.com",
52 changes: {
53 uri: "http://money.cnn.com",
54 description: "new description",
55 }
56 },
57 { livemark: "Livemark1",
58 feedUri: "http://rss.wunderground.com/blog/JeffMasters/rss.xml",
59 siteUri: "http://www.wunderground.com/blog/JeffMasters/show.html",
60 changes: {
61 livemark: "LivemarkOne"
62 }
63 },
64 ],
65 "menu/folderb": [
66 { uri: "http://www.apple.com",
67 tags: ["apple", "mac"],
68 changes: {
69 uri: "http://www.apple.com/iphone/",
70 title: "iPhone",
71 location: "menu",
72 position: "Google",
73 tags: []
74 }
75 }
76 ],
77 toolbar: [
78 { uri: "place:queryType=0&sort=8&maxResults=10&beginTimeRef=1&beginTime=0",
79 title: "Visited Today"
80 }
81 ]
82 };
83
84 // the state of bookmarks after the first 'modify' action has been performed
85 // on them
86 var bookmarks_after_first_modify = {
87 "menu": [
88 { uri: "http://www.apple.com/iphone/",
89 title: "iPhone",
90 before: "Google",
91 tags: []
92 },
93 { uri: "http://www.google.com",
94 title: "Google",
95 loadInSidebar: false,
96 tags: [ "google", "computers", "misc"]
97 },
98 { uri: "http://bugzilla.mozilla.org/show_bug.cgi?id=%s",
99 title: "Bugzilla",
100 keyword: "bugzilla"
101 },
102 { folder: "foldera" },
103 { uri: "http://www.mozilla.com" },
104 { separator: true },
105 { folder: "folderb",
106 changes: {
107 location: "menu/foldera",
108 folder: "Folder B",
109 description: "folder description"
110 }
111 }
112 ],
113 "menu/foldera": [
114 { uri: "http://money.cnn.com",
115 title: "http://www.cnn.com",
116 description: "new description"
117 },
118 { livemark: "LivemarkOne",
119 feedUri: "http://rss.wunderground.com/blog/JeffMasters/rss.xml",
120 siteUri: "http://www.wunderground.com/blog/JeffMasters/show.html"
121 }
122 ],
123 "menu/folderb": [
124 { uri: "http://www.yahoo.com",
125 title: "testing Yahoo"
126 }
127 ],
128 "toolbar": [
129 { uri: "place:queryType=0&sort=8&maxResults=10&beginTimeRef=1&beginTime=0",
130 title: "Visited Today"
131 }
132 ]
133 };
134
135 // a list of bookmarks to delete during a 'delete' action
136 var bookmarks_to_delete = {
137 "menu": [
138 { uri: "http://www.google.com",
139 title: "Google",
140 loadInSidebar: false,
141 tags: [ "google", "computers", "misc" ]
142 }
143 ]
144 };
145
146 // the state of bookmarks after the second 'modify' action has been performed
147 // on them
148 var bookmarks_after_second_modify = {
149 "menu": [
150 { uri: "http://www.apple.com/iphone/",
151 title: "iPhone"
152 },
153 { uri: "http://bugzilla.mozilla.org/show_bug.cgi?id=%s",
154 title: "Bugzilla",
155 keyword: "bugzilla"
156 },
157 { folder: "foldera" },
158 { uri: "http://www.mozilla.com" },
159 { separator: true },
160 ],
161 "menu/foldera": [
162 { uri: "http://money.cnn.com",
163 title: "http://www.cnn.com",
164 description: "new description"
165 },
166 { livemark: "LivemarkOne",
167 feedUri: "http://rss.wunderground.com/blog/JeffMasters/rss.xml",
168 siteUri: "http://www.wunderground.com/blog/JeffMasters/show.html"
169 },
170 { folder: "Folder B",
171 description: "folder description"
172 }
173 ],
174 "menu/foldera/Folder B": [
175 { uri: "http://www.yahoo.com",
176 title: "testing Yahoo"
177 }
178 ]
179 };
180
181 // a list of bookmarks which should not be present after the last
182 // 'delete' and 'modify' actions
183 var bookmarks_absent = {
184 "menu": [
185 { uri: "http://www.google.com",
186 title: "Google"
187 },
188 { folder: "folderb" },
189 { folder: "Folder B" }
190 ]
191 };
192
193 /*
194 * History asset lists: these define history entries that are used during
195 * the test
196 */
197
198 // the initial list of history items to add to the browser
199 var history_initial = [
200 { uri: "http://www.google.com/",
201 title: "Google",
202 visits: [
203 { type: 1, date: 0 },
204 { type: 2, date: -1 }
205 ]
206 },
207 { uri: "http://www.cnn.com/",
208 title: "CNN",
209 visits: [
210 { type: 1, date: -1 },
211 { type: 2, date: -36 }
212 ]
213 },
214 { uri: "http://www.google.com/language_tools?hl=en",
215 title: "Language Tools",
216 visits: [
217 { type: 1, date: 0 },
218 { type: 2, date: -40 }
219 ]
220 },
221 { uri: "http://www.mozilla.com/",
222 title: "Mozilla",
223 visits: [
224 { type: 1, date: 0 },
225 { type: 1, date: -1 },
226 { type: 1, date: -20 },
227 { type: 2, date: -36 }
228 ]
229 }
230 ];
231
232 // a list of history entries to delete during a 'delete' action
233 var history_to_delete = [
234 { uri: "http://www.cnn.com/" },
235 { begin: -24,
236 end: -1 },
237 { host: "www.google.com" }
238 ];
239
240 // the expected history entries after the first 'delete' action
241 var history_after_delete = [
242 { uri: "http://www.mozilla.com/",
243 title: "Mozilla",
244 visits: [
245 { type: 1,
246 date: 0
247 },
248 { type: 2,
249 date: -36
250 }
251 ]
252 }
253 ];
254
255 // history entries expected to not exist after a 'delete' action
256 var history_absent = [
257 { uri: "http://www.google.com/",
258 title: "Google",
259 visits: [
260 { type: 1,
261 date: 0
262 },
263 { type: 2,
264 date: -1
265 }
266 ]
267 },
268 { uri: "http://www.cnn.com/",
269 title: "CNN",
270 visits: [
271 { type: 1,
272 date: -1
273 },
274 { type: 2,
275 date: -36
276 }
277 ]
278 },
279 { uri: "http://www.google.com/language_tools?hl=en",
280 title: "Language Tools",
281 visits: [
282 { type: 1,
283 date: 0
284 },
285 { type: 2,
286 date: -40
287 }
288 ]
289 },
290 { uri: "http://www.mozilla.com/",
291 title: "Mozilla",
292 visits: [
293 { type: 1,
294 date: -1
295 },
296 { type: 1,
297 date: -20
298 }
299 ]
300 }
301 ];
302
303 /*
304 * Password asset lists: these define password entries that are used during
305 * the test
306 */
307
308 // the initial list of passwords to add to the browser
309 var passwords_initial = [
310 { hostname: "http://www.example.com",
311 submitURL: "http://login.example.com",
312 username: "joe",
313 password: "SeCrEt123",
314 usernameField: "uname",
315 passwordField: "pword",
316 changes: {
317 password: "zippity-do-dah"
318 }
319 },
320 { hostname: "http://www.example.com",
321 realm: "login",
322 username: "joe",
323 password: "secretlogin"
324 }
325 ];
326
327 // the expected state of passwords after the first 'modify' action
328 var passwords_after_first_modify = [
329 { hostname: "http://www.example.com",
330 submitURL: "http://login.example.com",
331 username: "joe",
332 password: "zippity-do-dah",
333 usernameField: "uname",
334 passwordField: "pword"
335 },
336 { hostname: "http://www.example.com",
337 realm: "login",
338 username: "joe",
339 password: "secretlogin"
340 }
341 ];
342
343 // a list of passwords to delete during a 'delete' action
344 var passwords_to_delete = [
345 { hostname: "http://www.example.com",
346 realm: "login",
347 username: "joe",
348 password: "secretlogin"
349 }
350 ];
351
352 // a list of passwords expected to be absent after 'delete' and 'modify'
353 // actions
354 var passwords_absent = [
355 { hostname: "http://www.example.com",
356 realm: "login",
357 username: "joe",
358 password: "secretlogin"
359 }
360 ];
361
362 // the expected state of passwords after the seconds 'modify' action
363 var passwords_after_second_modify = [
364 { hostname: "http://www.example.com",
365 submitURL: "http://login.example.com",
366 username: "joe",
367 password: "zippity-do-dah",
368 usernameField: "uname",
369 passwordField: "pword"
370 }
371 ];
372
373 /*
374 * Test phases
375 */
376
377 Phase('phase1', [
378 [Bookmarks.add, bookmarks_initial],
379 [Passwords.add, passwords_initial],
380 [History.add, history_initial],
381 [Sync],
382 ]);
383
384 Phase('phase2', [
385 [Sync],
386 [Bookmarks.verify, bookmarks_initial],
387 [Passwords.verify, passwords_initial],
388 [History.verify, history_initial],
389 [Bookmarks.modify, bookmarks_initial],
390 [Passwords.modify, passwords_initial],
391 [History.delete, history_to_delete],
392 [Bookmarks.verify, bookmarks_after_first_modify],
393 [Passwords.verify, passwords_after_first_modify],
394 [History.verify, history_after_delete],
395 [History.verifyNot, history_absent],
396 [Sync],
397 ]);
398
399 Phase('phase3', [
400 [Sync],
401 [Bookmarks.verify, bookmarks_after_first_modify],
402 [Passwords.verify, passwords_after_first_modify],
403 [History.verify, history_after_delete],
404 [Bookmarks.modify, bookmarks_after_first_modify],
405 [Passwords.modify, passwords_after_first_modify],
406 [Bookmarks.delete, bookmarks_to_delete],
407 [Passwords.delete, passwords_to_delete],
408 [Bookmarks.verify, bookmarks_after_second_modify],
409 [Passwords.verify, passwords_after_second_modify],
410 [Bookmarks.verifyNot, bookmarks_absent],
411 [Passwords.verifyNot, passwords_absent],
412 [Sync],
413 ]);
414
415 Phase('phase4', [
416 [Sync],
417 [Bookmarks.verify, bookmarks_after_second_modify],
418 [Passwords.verify, passwords_after_second_modify],
419 [Bookmarks.verifyNot, bookmarks_absent],
420 [Passwords.verifyNot, passwords_absent],
421 [History.verifyNot, history_absent],
422 ]);
423
424

mercurial