dom/contacts/tests/test_contacts_substringmatchingVE.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE html>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=877302
     5 -->
     6 <head>
     7   <title>Test for Bug 877302 substring matching for WebContacts</title>
     8   <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11 </head>
    12 <body>
    14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=877302">Mozilla Bug 877302</a>
    15 <p id="display"></p>
    16 <div id="content" style="display: none">
    18 </div>
    19 <pre id="test">
    20 <script type="text/javascript;version=1.8" src="http://mochi.test:8888/tests/dom/contacts/tests/shared.js"></script>
    21 <script class="testbody" type="text/javascript">
    22 "use strict";
    24 var prop = {
    25   tel: [{value: "7932012345" }, {value: "7704143727591"}]
    26 };
    28 var prop2 = {
    29   tel: [{value: "7932012345" }, {value: "+58 212 5551212"}]
    30 };
    32 var req;
    33 var steps = [
    34   function () {
    35     ok(true, "Deleting database");
    36     req = mozContacts.clear()
    37     req.onsuccess = function () {
    38       ok(true, "Deleted the database");
    39       next();
    40     }
    41     req.onerror = onFailure;
    42   },
    43   function () {
    44     ok(true, "Adding contact");
    45     createResult1 = new mozContact(prop);
    46     req = navigator.mozContacts.save(createResult1);
    47     req.onsuccess = function () {
    48       ok(createResult1.id, "The contact now has an ID.");
    49       sample_id1 = createResult1.id;
    50       next();
    51     };
    52     req.onerror = onFailure;
    53   },
    54   function () {
    55     ok(true, "Retrieving all contacts");
    56     req = mozContacts.find({});
    57     req.onsuccess = function () {
    58       is(req.result.length, 1, "One contact.");
    59       findResult1 = req.result[0];
    60       next();
    61     };
    62     req.onerror = onFailure;
    63   },
    64   function () {
    65     ok(true, "Retrieving by substring 1");
    66     var length = prop.tel[0].value.length;
    67     var num = "04143727591"
    68     var options = {filterBy: ["tel"],
    69                    filterOp: "match",
    70                    filterValue: num};
    71     req = mozContacts.find(options);
    72     req.onsuccess = function () {
    73       is(req.result.length, 1, "Found exactly 1 contact.");
    74       findResult1 = req.result[0];
    75       ok(findResult1.id == sample_id1, "Same ID");
    76       is(findResult1.tel[1].value, "7704143727591", "Same Value");
    77       next();
    78     };
    79     req.onerror = onFailure;
    80   },
    81   function () {
    82     ok(true, "Adding contact");
    83     createResult1 = new mozContact(prop2);
    84     req = navigator.mozContacts.save(createResult1);
    85     req.onsuccess = function () {
    86       ok(createResult1.id, "The contact now has an ID.");
    87       sample_id1 = createResult1.id;
    88       next();
    89     };
    90     req.onerror = onFailure;
    91   },
    92   function () {
    93     ok(true, "Retrieving by substring 2");
    94     var num = "5551212";
    95     var options = {filterBy: ["tel"],
    96                    filterOp: "match",
    97                    filterValue: num};
    98     req = mozContacts.find(options);
    99     req.onsuccess = function () {
   100       is(req.result.length, 1, "Found exactly 1 contact.");
   101       findResult1 = req.result[0];
   102       ok(findResult1.id == sample_id1, "Same ID");
   103       is(findResult1.tel[1].value, "+58 212 5551212", "Same Value");
   104       next();
   105     };
   106     req.onerror = onFailure;
   107   },
   108   function () {
   109     ok(true, "Deleting database");
   110     req = mozContacts.clear()
   111     req.onsuccess = function () {
   112       ok(true, "Deleted the database");
   113       next();
   114     }
   115     req.onerror = onFailure;
   116   },
   117   function () {
   118     ok(true, "all done!\n");
   119     SimpleTest.finish();
   120   }
   121 ];
   123 SpecialPowers.pushPrefEnv({
   124   set: [
   125     ["dom.phonenumber.substringmatching.VE", 7],
   126     ["ril.lastKnownSimMcc", "734"]
   127   ]
   128 }, start_tests);
   129 </script>
   130 </pre>
   131 </body>
   132 </html>

mercurial