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