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;
6 SpecialPowers.setBoolPref("dom.sms.enabled", true);
7 SpecialPowers.addPermission("sms", true, document);
9 let manager = window.navigator.mozMobileMessage;
10 // https://developer.mozilla.org/en-US/docs/DOM/SmsManager
11 let maxCharsPerSms = 160;
12 let maxSegments = 10; // 10 message segments concatenated into 1 multipart SMS
14 const REMOTE = "5551234567"; // the remote number
15 const EMULATOR = "15555215554"; // the emulator's number
17 function verifyInitialState() {
18 log("Verifying initial state.");
19 ok(manager instanceof MozMobileMessageManager,
20 "manager is instance of " + manager.constructor);
21 simulateIncomingSms();
22 }
24 function simulateIncomingSms() {
25 let msgText = "";
27 // Build the message text
28 msgText = new Array((maxCharsPerSms * maxSegments) + 1).join('a');
29 log("Simulating incoming multipart SMS (" + msgText.length +
30 " chars total).");
32 manager.onreceived = function onreceived(event) {
33 manager.onreceived = null;
34 log("Received 'onreceived' event.");
36 let incomingSms = event.message;
37 ok(incomingSms, "incoming sms");
38 ok(incomingSms.id, "sms id");
39 log("Received SMS (id: " + incomingSms.id + ").");
40 ok(incomingSms.threadId, "thread id");
41 is(incomingSms.body.length, msgText.length, "msg body length");
42 is(incomingSms.body, msgText, "msg body");
43 is(incomingSms.delivery, "received", "delivery");
44 is(incomingSms.read, false, "read");
45 is(incomingSms.receiver, EMULATOR, "receiver");
46 is(incomingSms.sender, REMOTE, "sender");
47 is(incomingSms.deliveryTimestamp, 0, "deliveryTimestamp is 0");
49 verifySmsExists(incomingSms);
50 };
51 runEmulatorCmd("sms send " + REMOTE + " " + msgText, function(result) {
52 is(result[0], "OK", "emulator output");
53 });
54 }
56 function verifySmsExists(incomingSms) {
57 log("Getting SMS (id: " + incomingSms.id + ").");
58 let requestRet = manager.getMessage(incomingSms.id);
59 ok(requestRet, "smsrequest obj returned");
61 requestRet.onsuccess = function(event) {
62 log("Received 'onsuccess' smsrequest event.");
63 ok(event.target.result, "smsrequest event.target.result");
64 let foundSms = event.target.result;
65 is(foundSms.id, incomingSms.id, "found SMS id matches");
66 is(foundSms.body.length, incomingSms.body.length, "SMS text length");
67 is(foundSms.body, incomingSms.body, "found SMS msg text matches");
68 log("Got SMS (id: " + foundSms.id + ") as expected.");
69 deleteSms(incomingSms);
70 };
72 requestRet.onerror = function(event) {
73 log("Received 'onerror' smsrequest event.");
74 ok(event.target.error, "domerror obj");
75 is(event.target.error.name, "NotFoundError", "error returned");
76 log("Could not get SMS (id: " + incomingSms.id + ") but should have.");
77 ok(false, "SMS was not found");
78 cleanUp();
79 };
80 }
82 function deleteSms(smsMsgObj){
83 log("Deleting SMS (id: " + smsMsgObj.id + ") using smsmsg obj parameter.");
84 let requestRet = manager.delete(smsMsgObj);
85 ok(requestRet, "smsrequest obj returned");
87 requestRet.onsuccess = function(event) {
88 log("Received 'onsuccess' smsrequest event.");
89 if (event.target.result) {
90 cleanUp();
91 } else {
92 log("smsrequest returned false for manager.delete");
93 ok(false, "SMS delete failed");
94 cleanUp();
95 }
96 };
98 requestRet.onerror = function(event) {
99 log("Received 'onerror' smsrequest event.");
100 ok(event.target.error, "domerror obj");
101 ok(false, "manager.delete request returned unexpected error: " +
102 event.target.error.name);
103 cleanUp();
104 };
105 }
107 function cleanUp() {
108 SpecialPowers.removePermission("sms", document);
109 SpecialPowers.clearUserPref("dom.sms.enabled");
110 finish();
111 }
113 // Start the test
114 verifyInitialState();