~ubuntu-branches/ubuntu/trusty/enigmail/trusty-updates

« back to all changes in this revision

Viewing changes to services/sync/tests/unit/test_clients_escape.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2011-06-07 14:35:53 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: package-import@ubuntu.com-20110607143553-fbgqhhvh8g8h6j1y
Tags: 2:1.2~a2~cvs20110606t2200-0ubuntu1
* Update to latest trunk snapshot for Thunderbird beta compat

* Remove build/pgo/profileserver.py from debian/clean. The new build
  system has a target depending on this
  - update debian/clean
* Drop debian/patches/autoconf.diff, just generate this at build time
* Refresh debian/patches/build_system_dont_link_libxul.diff
* libipc seems to be renamed to libipc-pipe. Fix genxpi and chrome.manifest
  to fix this 
  - add debian/patches/ipc-pipe_rename.diff
  - update debian/patches/series
* The makefiles in extensions/enigmail/ipc have an incorrect DEPTH
  attribute. Fix this so that they can find the rest of the build system
  - add debian/patches/makefile_depth.diff
  - update debian/patches/series
* Drop debian/patches/makefile-in-empty-xpcom-fix.diff - fixed in the
  current version
* Don't register a class ID multiple times, as this breaks enigmail entirely
  - add debian/patches/dont_register_cids_multiple_times.diff
  - update debian/patches/series
* Look for the Thunderbird 5 SDK
  - update debian/rules
  - update debian/control
* Run autoconf2.13 at build time
  - update debian/rules
  - update debian/control
* Add useless mesa-common-dev build-dep, just to satisfy the build system.
  We should just patch this out entirely really, but that's for another upload
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Cu.import("resource://services-sync/record.js");
 
2
Cu.import("resource://services-sync/engines/clients.js");
 
3
Cu.import("resource://services-sync/identity.js");
 
4
Cu.import("resource://services-sync/util.js");
 
5
Cu.import("resource://services-sync/identity.js");
 
6
 
 
7
function run_test() {
 
8
  _("Set up test fixtures.");
 
9
  ID.set('WeaveID', new Identity('Some Identity', 'foo'));
 
10
  Svc.Prefs.set("clusterURL", "http://fakebase/");
 
11
  let baseUri = "http://fakebase/1.1/foo/storage/";
 
12
  let pubUri = baseUri + "keys/pubkey";
 
13
  let privUri = baseUri + "keys/privkey";
 
14
 
 
15
  let keyBundle = ID.set("WeaveCryptoID",
 
16
                         new SyncKeyBundle(null, "john@example.com", "abcdeabcdeabcdeabcdeabcdea"));
 
17
 
 
18
  try {
 
19
    _("Test that serializing client records results in uploadable ascii");
 
20
    Clients.localID = "ascii";
 
21
    Clients.localName = "wéävê";
 
22
 
 
23
    _("Make sure we have the expected record");
 
24
    let record = Clients._createRecord("ascii");
 
25
    do_check_eq(record.id, "ascii");
 
26
    do_check_eq(record.name, "wéävê");
 
27
 
 
28
    _("Encrypting record...");
 
29
    record.encrypt(keyBundle);
 
30
    _("Encrypted.");
 
31
    
 
32
    let serialized = JSON.stringify(record);
 
33
    let checkCount = 0;
 
34
    _("Checking for all ASCII:", serialized);
 
35
    Array.forEach(serialized, function(ch) {
 
36
      let code = ch.charCodeAt(0);
 
37
      _("Checking asciiness of '", ch, "'=", code);
 
38
      do_check_true(code < 128);
 
39
      checkCount++;
 
40
    });
 
41
 
 
42
    _("Processed", checkCount, "characters out of", serialized.length);
 
43
    do_check_eq(checkCount, serialized.length);
 
44
 
 
45
    _("Making sure the record still looks like it did before");
 
46
    record.decrypt(keyBundle);
 
47
    do_check_eq(record.id, "ascii");
 
48
    do_check_eq(record.name, "wéävê");
 
49
 
 
50
    _("Sanity check that creating the record also gives the same");
 
51
    record = Clients._createRecord("ascii");
 
52
    do_check_eq(record.id, "ascii");
 
53
    do_check_eq(record.name, "wéävê");
 
54
  } finally {
 
55
    Svc.Prefs.resetBranch("");
 
56
  }
 
57
}