1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/services/sync/tests/tps/test_sync.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,424 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/* 1.8 + * The list of phases mapped to their corresponding profiles. The object 1.9 + * here must be in strict JSON format, as it will get parsed by the Python 1.10 + * testrunner (no single quotes, extra comma's, etc). 1.11 + */ 1.12 + 1.13 +var phases = { "phase1": "profile1", 1.14 + "phase2": "profile2", 1.15 + "phase3": "profile1", 1.16 + "phase4": "profile2" }; 1.17 + 1.18 +/* 1.19 + * Bookmark asset lists: these define bookmarks that are used during the test 1.20 + */ 1.21 + 1.22 +// the initial list of bookmarks to be added to the browser 1.23 +var bookmarks_initial = { 1.24 + "menu": [ 1.25 + { uri: "http://www.google.com", 1.26 + loadInSidebar: true, 1.27 + tags: ["google", "computers", "internet", "www"], 1.28 + changes: { 1.29 + title: "Google", 1.30 + loadInSidebar: false, 1.31 + tags: ["google", "computers", "misc"], 1.32 + } 1.33 + }, 1.34 + { uri: "http://bugzilla.mozilla.org/show_bug.cgi?id=%s", 1.35 + title: "Bugzilla", 1.36 + keyword: "bz", 1.37 + changes: { 1.38 + keyword: "bugzilla" 1.39 + } 1.40 + }, 1.41 + { folder: "foldera" }, 1.42 + { uri: "http://www.mozilla.com" }, 1.43 + { separator: true }, 1.44 + { folder: "folderb" }, 1.45 + ], 1.46 + "menu/foldera": [ 1.47 + { uri: "http://www.yahoo.com", 1.48 + title: "testing Yahoo", 1.49 + changes: { 1.50 + location: "menu/folderb" 1.51 + } 1.52 + }, 1.53 + { uri: "http://www.cnn.com", 1.54 + description: "This is a description of the site a at www.cnn.com", 1.55 + changes: { 1.56 + uri: "http://money.cnn.com", 1.57 + description: "new description", 1.58 + } 1.59 + }, 1.60 + { livemark: "Livemark1", 1.61 + feedUri: "http://rss.wunderground.com/blog/JeffMasters/rss.xml", 1.62 + siteUri: "http://www.wunderground.com/blog/JeffMasters/show.html", 1.63 + changes: { 1.64 + livemark: "LivemarkOne" 1.65 + } 1.66 + }, 1.67 + ], 1.68 + "menu/folderb": [ 1.69 + { uri: "http://www.apple.com", 1.70 + tags: ["apple", "mac"], 1.71 + changes: { 1.72 + uri: "http://www.apple.com/iphone/", 1.73 + title: "iPhone", 1.74 + location: "menu", 1.75 + position: "Google", 1.76 + tags: [] 1.77 + } 1.78 + } 1.79 + ], 1.80 + toolbar: [ 1.81 + { uri: "place:queryType=0&sort=8&maxResults=10&beginTimeRef=1&beginTime=0", 1.82 + title: "Visited Today" 1.83 + } 1.84 + ] 1.85 +}; 1.86 + 1.87 +// the state of bookmarks after the first 'modify' action has been performed 1.88 +// on them 1.89 +var bookmarks_after_first_modify = { 1.90 + "menu": [ 1.91 + { uri: "http://www.apple.com/iphone/", 1.92 + title: "iPhone", 1.93 + before: "Google", 1.94 + tags: [] 1.95 + }, 1.96 + { uri: "http://www.google.com", 1.97 + title: "Google", 1.98 + loadInSidebar: false, 1.99 + tags: [ "google", "computers", "misc"] 1.100 + }, 1.101 + { uri: "http://bugzilla.mozilla.org/show_bug.cgi?id=%s", 1.102 + title: "Bugzilla", 1.103 + keyword: "bugzilla" 1.104 + }, 1.105 + { folder: "foldera" }, 1.106 + { uri: "http://www.mozilla.com" }, 1.107 + { separator: true }, 1.108 + { folder: "folderb", 1.109 + changes: { 1.110 + location: "menu/foldera", 1.111 + folder: "Folder B", 1.112 + description: "folder description" 1.113 + } 1.114 + } 1.115 + ], 1.116 + "menu/foldera": [ 1.117 + { uri: "http://money.cnn.com", 1.118 + title: "http://www.cnn.com", 1.119 + description: "new description" 1.120 + }, 1.121 + { livemark: "LivemarkOne", 1.122 + feedUri: "http://rss.wunderground.com/blog/JeffMasters/rss.xml", 1.123 + siteUri: "http://www.wunderground.com/blog/JeffMasters/show.html" 1.124 + } 1.125 + ], 1.126 + "menu/folderb": [ 1.127 + { uri: "http://www.yahoo.com", 1.128 + title: "testing Yahoo" 1.129 + } 1.130 + ], 1.131 + "toolbar": [ 1.132 + { uri: "place:queryType=0&sort=8&maxResults=10&beginTimeRef=1&beginTime=0", 1.133 + title: "Visited Today" 1.134 + } 1.135 + ] 1.136 +}; 1.137 + 1.138 +// a list of bookmarks to delete during a 'delete' action 1.139 +var bookmarks_to_delete = { 1.140 + "menu": [ 1.141 + { uri: "http://www.google.com", 1.142 + title: "Google", 1.143 + loadInSidebar: false, 1.144 + tags: [ "google", "computers", "misc" ] 1.145 + } 1.146 + ] 1.147 +}; 1.148 + 1.149 +// the state of bookmarks after the second 'modify' action has been performed 1.150 +// on them 1.151 +var bookmarks_after_second_modify = { 1.152 + "menu": [ 1.153 + { uri: "http://www.apple.com/iphone/", 1.154 + title: "iPhone" 1.155 + }, 1.156 + { uri: "http://bugzilla.mozilla.org/show_bug.cgi?id=%s", 1.157 + title: "Bugzilla", 1.158 + keyword: "bugzilla" 1.159 + }, 1.160 + { folder: "foldera" }, 1.161 + { uri: "http://www.mozilla.com" }, 1.162 + { separator: true }, 1.163 + ], 1.164 + "menu/foldera": [ 1.165 + { uri: "http://money.cnn.com", 1.166 + title: "http://www.cnn.com", 1.167 + description: "new description" 1.168 + }, 1.169 + { livemark: "LivemarkOne", 1.170 + feedUri: "http://rss.wunderground.com/blog/JeffMasters/rss.xml", 1.171 + siteUri: "http://www.wunderground.com/blog/JeffMasters/show.html" 1.172 + }, 1.173 + { folder: "Folder B", 1.174 + description: "folder description" 1.175 + } 1.176 + ], 1.177 + "menu/foldera/Folder B": [ 1.178 + { uri: "http://www.yahoo.com", 1.179 + title: "testing Yahoo" 1.180 + } 1.181 + ] 1.182 +}; 1.183 + 1.184 +// a list of bookmarks which should not be present after the last 1.185 +// 'delete' and 'modify' actions 1.186 +var bookmarks_absent = { 1.187 + "menu": [ 1.188 + { uri: "http://www.google.com", 1.189 + title: "Google" 1.190 + }, 1.191 + { folder: "folderb" }, 1.192 + { folder: "Folder B" } 1.193 + ] 1.194 +}; 1.195 + 1.196 +/* 1.197 + * History asset lists: these define history entries that are used during 1.198 + * the test 1.199 + */ 1.200 + 1.201 +// the initial list of history items to add to the browser 1.202 +var history_initial = [ 1.203 + { uri: "http://www.google.com/", 1.204 + title: "Google", 1.205 + visits: [ 1.206 + { type: 1, date: 0 }, 1.207 + { type: 2, date: -1 } 1.208 + ] 1.209 + }, 1.210 + { uri: "http://www.cnn.com/", 1.211 + title: "CNN", 1.212 + visits: [ 1.213 + { type: 1, date: -1 }, 1.214 + { type: 2, date: -36 } 1.215 + ] 1.216 + }, 1.217 + { uri: "http://www.google.com/language_tools?hl=en", 1.218 + title: "Language Tools", 1.219 + visits: [ 1.220 + { type: 1, date: 0 }, 1.221 + { type: 2, date: -40 } 1.222 + ] 1.223 + }, 1.224 + { uri: "http://www.mozilla.com/", 1.225 + title: "Mozilla", 1.226 + visits: [ 1.227 + { type: 1, date: 0 }, 1.228 + { type: 1, date: -1 }, 1.229 + { type: 1, date: -20 }, 1.230 + { type: 2, date: -36 } 1.231 + ] 1.232 + } 1.233 +]; 1.234 + 1.235 +// a list of history entries to delete during a 'delete' action 1.236 +var history_to_delete = [ 1.237 + { uri: "http://www.cnn.com/" }, 1.238 + { begin: -24, 1.239 + end: -1 }, 1.240 + { host: "www.google.com" } 1.241 +]; 1.242 + 1.243 +// the expected history entries after the first 'delete' action 1.244 +var history_after_delete = [ 1.245 + { uri: "http://www.mozilla.com/", 1.246 + title: "Mozilla", 1.247 + visits: [ 1.248 + { type: 1, 1.249 + date: 0 1.250 + }, 1.251 + { type: 2, 1.252 + date: -36 1.253 + } 1.254 + ] 1.255 + } 1.256 +]; 1.257 + 1.258 +// history entries expected to not exist after a 'delete' action 1.259 +var history_absent = [ 1.260 + { uri: "http://www.google.com/", 1.261 + title: "Google", 1.262 + visits: [ 1.263 + { type: 1, 1.264 + date: 0 1.265 + }, 1.266 + { type: 2, 1.267 + date: -1 1.268 + } 1.269 + ] 1.270 + }, 1.271 + { uri: "http://www.cnn.com/", 1.272 + title: "CNN", 1.273 + visits: [ 1.274 + { type: 1, 1.275 + date: -1 1.276 + }, 1.277 + { type: 2, 1.278 + date: -36 1.279 + } 1.280 + ] 1.281 + }, 1.282 + { uri: "http://www.google.com/language_tools?hl=en", 1.283 + title: "Language Tools", 1.284 + visits: [ 1.285 + { type: 1, 1.286 + date: 0 1.287 + }, 1.288 + { type: 2, 1.289 + date: -40 1.290 + } 1.291 + ] 1.292 + }, 1.293 + { uri: "http://www.mozilla.com/", 1.294 + title: "Mozilla", 1.295 + visits: [ 1.296 + { type: 1, 1.297 + date: -1 1.298 + }, 1.299 + { type: 1, 1.300 + date: -20 1.301 + } 1.302 + ] 1.303 + } 1.304 +]; 1.305 + 1.306 +/* 1.307 + * Password asset lists: these define password entries that are used during 1.308 + * the test 1.309 + */ 1.310 + 1.311 +// the initial list of passwords to add to the browser 1.312 +var passwords_initial = [ 1.313 + { hostname: "http://www.example.com", 1.314 + submitURL: "http://login.example.com", 1.315 + username: "joe", 1.316 + password: "SeCrEt123", 1.317 + usernameField: "uname", 1.318 + passwordField: "pword", 1.319 + changes: { 1.320 + password: "zippity-do-dah" 1.321 + } 1.322 + }, 1.323 + { hostname: "http://www.example.com", 1.324 + realm: "login", 1.325 + username: "joe", 1.326 + password: "secretlogin" 1.327 + } 1.328 +]; 1.329 + 1.330 +// the expected state of passwords after the first 'modify' action 1.331 +var passwords_after_first_modify = [ 1.332 + { hostname: "http://www.example.com", 1.333 + submitURL: "http://login.example.com", 1.334 + username: "joe", 1.335 + password: "zippity-do-dah", 1.336 + usernameField: "uname", 1.337 + passwordField: "pword" 1.338 + }, 1.339 + { hostname: "http://www.example.com", 1.340 + realm: "login", 1.341 + username: "joe", 1.342 + password: "secretlogin" 1.343 + } 1.344 +]; 1.345 + 1.346 +// a list of passwords to delete during a 'delete' action 1.347 +var passwords_to_delete = [ 1.348 + { hostname: "http://www.example.com", 1.349 + realm: "login", 1.350 + username: "joe", 1.351 + password: "secretlogin" 1.352 + } 1.353 +]; 1.354 + 1.355 +// a list of passwords expected to be absent after 'delete' and 'modify' 1.356 +// actions 1.357 +var passwords_absent = [ 1.358 + { hostname: "http://www.example.com", 1.359 + realm: "login", 1.360 + username: "joe", 1.361 + password: "secretlogin" 1.362 + } 1.363 +]; 1.364 + 1.365 +// the expected state of passwords after the seconds 'modify' action 1.366 +var passwords_after_second_modify = [ 1.367 + { hostname: "http://www.example.com", 1.368 + submitURL: "http://login.example.com", 1.369 + username: "joe", 1.370 + password: "zippity-do-dah", 1.371 + usernameField: "uname", 1.372 + passwordField: "pword" 1.373 + } 1.374 +]; 1.375 + 1.376 +/* 1.377 + * Test phases 1.378 + */ 1.379 + 1.380 +Phase('phase1', [ 1.381 + [Bookmarks.add, bookmarks_initial], 1.382 + [Passwords.add, passwords_initial], 1.383 + [History.add, history_initial], 1.384 + [Sync], 1.385 +]); 1.386 + 1.387 +Phase('phase2', [ 1.388 + [Sync], 1.389 + [Bookmarks.verify, bookmarks_initial], 1.390 + [Passwords.verify, passwords_initial], 1.391 + [History.verify, history_initial], 1.392 + [Bookmarks.modify, bookmarks_initial], 1.393 + [Passwords.modify, passwords_initial], 1.394 + [History.delete, history_to_delete], 1.395 + [Bookmarks.verify, bookmarks_after_first_modify], 1.396 + [Passwords.verify, passwords_after_first_modify], 1.397 + [History.verify, history_after_delete], 1.398 + [History.verifyNot, history_absent], 1.399 + [Sync], 1.400 +]); 1.401 + 1.402 +Phase('phase3', [ 1.403 + [Sync], 1.404 + [Bookmarks.verify, bookmarks_after_first_modify], 1.405 + [Passwords.verify, passwords_after_first_modify], 1.406 + [History.verify, history_after_delete], 1.407 + [Bookmarks.modify, bookmarks_after_first_modify], 1.408 + [Passwords.modify, passwords_after_first_modify], 1.409 + [Bookmarks.delete, bookmarks_to_delete], 1.410 + [Passwords.delete, passwords_to_delete], 1.411 + [Bookmarks.verify, bookmarks_after_second_modify], 1.412 + [Passwords.verify, passwords_after_second_modify], 1.413 + [Bookmarks.verifyNot, bookmarks_absent], 1.414 + [Passwords.verifyNot, passwords_absent], 1.415 + [Sync], 1.416 +]); 1.417 + 1.418 +Phase('phase4', [ 1.419 + [Sync], 1.420 + [Bookmarks.verify, bookmarks_after_second_modify], 1.421 + [Passwords.verify, passwords_after_second_modify], 1.422 + [Bookmarks.verifyNot, bookmarks_absent], 1.423 + [Passwords.verifyNot, passwords_absent], 1.424 + [History.verifyNot, history_absent], 1.425 +]); 1.426 + 1.427 +