Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 MARIONETTE_TIMEOUT = 60000;
5 MARIONETTE_HEAD_JS = 'mmdb_head.js';
7 const DBNAME = "test_mmdb_foreachmatchedmmsdeliveryinfo:" + newUUID();
9 const PHONE_0 = "+15555215500";
10 const PHONE_1 = "+15555215501";
11 const PHONE_2 = "+15555215502";
12 const PHONE_2_NET = "5555215502";
13 const PHONE_3 = "+15555215503";
14 const PHONE_3_NET = "5555215503";
15 const EMAIL_1 = "foo@bar.com";
16 let deliveryInfo = [
17 { receiver: PHONE_1 },
18 { receiver: PHONE_2 },
19 { receiver: PHONE_1 },
20 { receiver: PHONE_2_NET },
21 { receiver: PHONE_3_NET },
22 { receiver: EMAIL_1 },
23 { receiver: PHONE_3 },
24 ];
26 function clearTraversed(aDeliveryInfo) {
27 for (let element of aDeliveryInfo) {
28 delete element.traversed;
29 }
30 }
32 function doTest(aMmdb, aNeedle, aVerifyFunc, aCount) {
33 log(" '" + aNeedle + "': " + aCount);
35 clearTraversed(deliveryInfo);
37 let count = 0;
38 aMmdb.forEachMatchedMmsDeliveryInfo(deliveryInfo, aNeedle, function(aElement) {
39 ok(true, "checking " + aElement.receiver);
40 ok(!aElement.hasOwnProperty("traversed"), "element.traversed");
41 aVerifyFunc(aElement);
43 aElement.traversed = true;
44 ++count;
45 });
46 is(count, aCount, "matched count");
47 }
49 function testNotFound(aMmdb) {
50 log("Testing unavailable");
52 doTest(aMmdb, PHONE_0, function(aElement) {
53 ok(false, "Should never have a match");
54 }, 0);
55 }
57 function testDirectMatch(aMmdb) {
58 log("Testing direct matching");
60 for (let needle of [PHONE_1, EMAIL_1]) {
61 let count = deliveryInfo.reduce(function(aCount, aElement) {
62 return aElement.receiver == needle ? aCount + 1 : aCount;
63 }, 0);
64 doTest(aMmdb, needle, function(aElement) {
65 is(aElement.receiver, needle, "element.receiver");
66 }, count);
67 }
68 }
70 function testPhoneMatch(aMmdb) {
71 log("Testing phone matching");
73 let verifyFunc = function(aValid, aElement) {
74 ok(aValid.indexOf(aElement.receiver) >= 0, "element.receiver");
75 };
77 let matchingGroups = [
78 [PHONE_2, PHONE_2_NET],
79 [PHONE_3, PHONE_3_NET],
80 ];
81 for (let group of matchingGroups) {
82 for (let item of group) {
83 doTest(aMmdb, item, verifyFunc.bind(null, group), group.length);
84 }
85 }
86 }
88 startTestBase(function testCaseMain() {
89 let mmdb = newMobileMessageDB();
90 return initMobileMessageDB(mmdb, DBNAME, 0)
91 .then(() => testNotFound(mmdb))
92 .then(() => testDirectMatch(mmdb))
93 .then(() => testPhoneMatch(mmdb))
94 .then(() => closeMobileMessageDB(mmdb));
95 });