PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

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