/services/sync/tests/tps/test_history.js

http://github.com/zpao/v8monkey · JavaScript · 167 lines · 133 code · 11 blank · 23 comment · 0 complexity · 20bc5c3581f9fdf0447cc235ba59203c 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. EnableEngines(["history"]);
  9. var phases = { "phase1": "profile1",
  10. "phase2": "profile2" };
  11. /*
  12. * History asset lists: these define history entries that are used during
  13. * the test
  14. */
  15. // the initial list of history items to add to the browser
  16. var history1 = [
  17. { uri: "http://www.google.com/",
  18. title: "Google",
  19. visits: [
  20. { type: 1,
  21. date: 0
  22. },
  23. { type: 2,
  24. date: -1
  25. }
  26. ]
  27. },
  28. { uri: "http://www.cnn.com/",
  29. title: "CNN",
  30. visits: [
  31. { type: 1,
  32. date: -1
  33. },
  34. { type: 2,
  35. date: -36
  36. }
  37. ]
  38. },
  39. { uri: "http://www.google.com/language_tools?hl=en",
  40. title: "Language Tools",
  41. visits: [
  42. { type: 1,
  43. date: 0
  44. },
  45. { type: 2,
  46. date: -40
  47. }
  48. ]
  49. },
  50. { uri: "http://www.mozilla.com/",
  51. title: "Mozilla",
  52. visits: [
  53. { type: 1,
  54. date: 0
  55. },
  56. { type: 1,
  57. date: -1
  58. },
  59. { type: 1,
  60. date: -20
  61. },
  62. { type: 2,
  63. date: -36
  64. }
  65. ]
  66. }
  67. ];
  68. // a list of items to delete from the history
  69. var history_to_delete = [
  70. { uri: "http://www.cnn.com/" },
  71. { begin: -24,
  72. end: -1
  73. },
  74. { host: "www.google.com" }
  75. ];
  76. // a list which reflects items that should be in the history after
  77. // the above items are deleted
  78. var history2 = [
  79. { uri: "http://www.mozilla.com/",
  80. title: "Mozilla",
  81. visits: [
  82. { type: 1,
  83. date: 0
  84. },
  85. { type: 2,
  86. date: -36
  87. }
  88. ]
  89. }
  90. ];
  91. // a list which includes history entries that should not be present
  92. // after deletion of the history_to_delete entries
  93. var history_not = [
  94. { uri: "http://www.google.com/",
  95. title: "Google",
  96. visits: [
  97. { type: 1,
  98. date: 0
  99. },
  100. { type: 2,
  101. date: -1
  102. }
  103. ]
  104. },
  105. { uri: "http://www.cnn.com/",
  106. title: "CNN",
  107. visits: [
  108. { type: 1,
  109. date: -1
  110. },
  111. { type: 2,
  112. date: -36
  113. }
  114. ]
  115. },
  116. { uri: "http://www.google.com/language_tools?hl=en",
  117. title: "Language Tools",
  118. visits: [
  119. { type: 1,
  120. date: 0
  121. },
  122. { type: 2,
  123. date: -40
  124. }
  125. ]
  126. },
  127. { uri: "http://www.mozilla.com/",
  128. title: "Mozilla",
  129. visits: [
  130. { type: 1,
  131. date: -1
  132. },
  133. { type: 1,
  134. date: -20
  135. }
  136. ]
  137. }
  138. ];
  139. /*
  140. * Test phases
  141. * Note: there is no test phase in which deleted history entries are
  142. * synced to other clients. This functionality is not supported by
  143. * Sync, see bug 446517.
  144. */
  145. Phase('phase1', [
  146. [History.add, history1],
  147. [Sync],
  148. ]);
  149. Phase('phase2', [
  150. [Sync],
  151. [History.verify, history1],
  152. [History.delete, history_to_delete],
  153. [History.verify, history2],
  154. [History.verifyNot, history_not],
  155. [Sync]
  156. ]);