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.

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

mercurial