~ubuntu-branches/ubuntu/trusty/enigmail/trusty-security

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2011-08-12 12:25:06 UTC
  • mfrom: (0.12.4 upstream)
  • Revision ID: package-import@ubuntu.com-20110812122506-zko6c7zfexvyg71q
Tags: 2:1.2.1-0ubuntu1
* New upstream release
* Drop fix_install_rdf_xml_errors.diff - fixed upstream
* Refresh port_to_latest_thunderbird.diff
* Add a proper get-orig-source target which pulls the build system from
  lp:~mozillateam/mozilla-build-system/beta, now that we don't have the old
  build-system.tar.gz from xulrunner

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
_("Make sure various combinations of deferGetSet arguments correctly defer getting/setting properties to another object");
2
 
Cu.import("resource://services-sync/util.js");
3
 
 
4
 
function run_test() {
5
 
  let base = function() {};
6
 
  base.prototype = {
7
 
    dst: {},
8
 
 
9
 
    get a() "a",
10
 
    set b(val) this.dst.b = val + "!!!"
11
 
  };
12
 
  let src = new base();
13
 
 
14
 
  _("get/set a single property");
15
 
  Utils.deferGetSet(base, "dst", "foo");
16
 
  src.foo = "bar";
17
 
  do_check_eq(src.dst.foo, "bar");
18
 
  do_check_eq(src.foo, "bar");
19
 
 
20
 
  _("editing the target also updates the source");
21
 
  src.dst.foo = "baz";
22
 
  do_check_eq(src.dst.foo, "baz");
23
 
  do_check_eq(src.foo, "baz");
24
 
 
25
 
  _("handle multiple properties");
26
 
  Utils.deferGetSet(base, "dst", ["p1", "p2"]);
27
 
  src.p1 = "v1";
28
 
  src.p2 = "v2";
29
 
  do_check_eq(src.p1, "v1");
30
 
  do_check_eq(src.dst.p1, "v1");
31
 
  do_check_eq(src.p2, "v2");
32
 
  do_check_eq(src.dst.p2, "v2");
33
 
 
34
 
  _("make sure existing getter keeps its functionality");
35
 
  Utils.deferGetSet(base, "dst", "a");
36
 
  src.a = "not a";
37
 
  do_check_eq(src.dst.a, "not a");
38
 
  do_check_eq(src.a, "a");
39
 
 
40
 
  _("make sure existing setter keeps its functionality");
41
 
  Utils.deferGetSet(base, "dst", "b");
42
 
  src.b = "b";
43
 
  do_check_eq(src.dst.b, "b!!!");
44
 
  do_check_eq(src.b, "b!!!");
45
 
}