/services/sync/tests/tps/test_client_wipe.js

http://github.com/zpao/v8monkey · JavaScript · 164 lines · 122 code · 15 blank · 27 comment · 0 complexity · 7b12a6943a204fdd08154d0acac1c2f0 MD5 · raw file

  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /*
  4. * The list of phases mapped to their corresponding profiles. The object
  5. * here must be in strict JSON format, as it will get parsed by the Python
  6. * testrunner (no single quotes, extra comma's, etc).
  7. */
  8. var phases = { "phase1": "profile1",
  9. "phase2": "profile2",
  10. "phase3": "profile1"};
  11. /*
  12. * Bookmark lists
  13. */
  14. // the initial list of bookmarks to add to the browser
  15. var bookmarks_initial = {
  16. toolbar: [
  17. { uri: "http://www.google.com",
  18. title: "Google"
  19. },
  20. { uri: "http://www.cnn.com",
  21. title: "CNN",
  22. changes: {
  23. position: "Google"
  24. }
  25. },
  26. { uri: "http://www.mozilla.com",
  27. title: "Mozilla"
  28. },
  29. { uri: "http://www.firefox.com",
  30. title: "Firefox",
  31. changes: {
  32. position: "Mozilla"
  33. }
  34. }
  35. ]
  36. };
  37. var bookmarks_after_move = {
  38. toolbar: [
  39. { uri: "http://www.cnn.com",
  40. title: "CNN"
  41. },
  42. { uri: "http://www.google.com",
  43. title: "Google"
  44. },
  45. { uri: "http://www.firefox.com",
  46. title: "Firefox"
  47. },
  48. { uri: "http://www.mozilla.com",
  49. title: "Mozilla"
  50. }
  51. ]
  52. };
  53. /*
  54. * Password data
  55. */
  56. // Initial password data
  57. var passwords_initial = [
  58. { hostname: "http://www.example.com",
  59. submitURL: "http://login.example.com",
  60. username: "joe",
  61. password: "secret",
  62. usernameField: "uname",
  63. passwordField: "pword",
  64. changes: {
  65. password: "SeCrEt$$$"
  66. }
  67. },
  68. { hostname: "http://www.example.com",
  69. realm: "login",
  70. username: "jack",
  71. password: "secretlogin"
  72. }
  73. ];
  74. // Password after first modify action has been performed
  75. var passwords_after_change = [
  76. { hostname: "http://www.example.com",
  77. submitURL: "http://login.example.com",
  78. username: "joe",
  79. password: "SeCrEt$$$",
  80. usernameField: "uname",
  81. passwordField: "pword",
  82. changes: {
  83. username: "james"
  84. }
  85. },
  86. { hostname: "http://www.example.com",
  87. realm: "login",
  88. username: "jack",
  89. password: "secretlogin"
  90. }
  91. ];
  92. /*
  93. * Prefs to use in the test
  94. */
  95. var prefs1 = [
  96. { name: "browser.startup.homepage",
  97. value: "http://www.getfirefox.com"
  98. },
  99. { name: "browser.urlbar.maxRichResults",
  100. value: 20
  101. },
  102. { name: "browser.tabs.autoHide",
  103. value: true
  104. }
  105. ];
  106. var prefs2 = [
  107. { name: "browser.startup.homepage",
  108. value: "http://www.mozilla.com"
  109. },
  110. { name: "browser.urlbar.maxRichResults",
  111. value: 18
  112. },
  113. { name: "browser.tabs.autoHide",
  114. value: false
  115. }
  116. ];
  117. /*
  118. * Test phases
  119. */
  120. // Add prefs,passwords and bookmarks to profile1 and sync.
  121. Phase('phase1', [
  122. [Passwords.add, passwords_initial],
  123. [Bookmarks.add, bookmarks_initial],
  124. [Prefs.modify, prefs1],
  125. [Prefs.verify, prefs1],
  126. [Sync]
  127. ]);
  128. // Sync profile2 and verify same prefs,passwords and bookmarks are present.
  129. Phase('phase2', [
  130. [Sync],
  131. [Prefs.verify, prefs1],
  132. [Passwords.verify, passwords_initial],
  133. [Bookmarks.verify, bookmarks_initial]
  134. ]);
  135. // Using profile1, change some prefs,bookmarks and pwds, then do another sync with wipe-client.
  136. // Verify that the cloud's settings are restored, and the recent local changes
  137. // discarded.
  138. Phase('phase3', [
  139. [Prefs.modify, prefs2],
  140. [Passwords.modify, passwords_initial],
  141. [Bookmarks.modify, bookmarks_initial],
  142. [Prefs.verify, prefs2],
  143. [Passwords.verify, passwords_after_change],
  144. [Bookmarks.verify, bookmarks_after_move],
  145. [Sync, SYNC_WIPE_CLIENT],
  146. [Prefs.verify, prefs1],
  147. [Passwords.verify, passwords_initial],
  148. [Bookmarks.verify, bookmarks_initial]
  149. ]);