dom/mobilemessage/tests/marionette/test_mt_sms_concatenation.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 MARIONETTE_TIMEOUT = 60000;
michael@0 5 MARIONETTE_HEAD_JS = 'head.js';
michael@0 6
michael@0 7 const PDU_SMSC_NONE = "00"; // no SMSC Address
michael@0 8
michael@0 9 const PDU_FIRST_OCTET = "40"; // RP:no, UDHI:yes, SRI:no, MMS:no, MTI:SMS-DELIVER
michael@0 10
michael@0 11 const PDU_SENDER = "0A912143658709"; // +1234567890
michael@0 12 const SENDER = "+1234567890";
michael@0 13
michael@0 14 const PDU_PID_NORMAL = "00";
michael@0 15
michael@0 16 const PDU_DCS_NORMAL_UCS2 = "08";
michael@0 17 const PDU_DCS_CLASS0_UCS2 = "18";
michael@0 18 const PDU_DCS_NORMAL_8BIT = "04";
michael@0 19 const PDU_DCS_CLASS0_8BIT = "14";
michael@0 20
michael@0 21 const PDU_TIMESTAMP = "00101000000000"; // 2000/01/01
michael@0 22
michael@0 23 function byteValueToHexString(aValue) {
michael@0 24 let str = Number(aValue).toString(16).toUpperCase();
michael@0 25 return str.length == 1 ? "0" + str : str;
michael@0 26 }
michael@0 27
michael@0 28 let ref_num = 0;
michael@0 29 function buildTextPdus(aDcs) {
michael@0 30 ref_num++;
michael@0 31
michael@0 32 let IEI_CONCATE_1 = "0003" + byteValueToHexString(ref_num) + "0301";
michael@0 33 let IEI_CONCATE_2 = "0003" + byteValueToHexString(ref_num) + "0302";
michael@0 34 let IEI_CONCATE_3 = "0003" + byteValueToHexString(ref_num) + "0303";
michael@0 35 let PDU_UDL = "08"; // UDHL(1) + UDH(5) + UCS2 Char (2)
michael@0 36 let PDU_UDHL = "05";
michael@0 37
michael@0 38 let PDU_UD_A = "0041"; // "A"
michael@0 39 let PDU_UD_B = "0042"; // "B"
michael@0 40 let PDU_UD_C = "0043"; // "C"
michael@0 41
michael@0 42 let PDU_COMMON = PDU_SMSC_NONE + PDU_FIRST_OCTET + PDU_SENDER +
michael@0 43 PDU_PID_NORMAL + aDcs + PDU_TIMESTAMP + PDU_UDL + PDU_UDHL;
michael@0 44
michael@0 45 return [
michael@0 46 PDU_COMMON + IEI_CONCATE_1 + PDU_UD_A,
michael@0 47 PDU_COMMON + IEI_CONCATE_2 + PDU_UD_B,
michael@0 48 PDU_COMMON + IEI_CONCATE_3 + PDU_UD_C
michael@0 49 ];
michael@0 50 }
michael@0 51
michael@0 52 function buildBinaryPdus(aDcs) {
michael@0 53 ref_num++;
michael@0 54 let IEI_PORT = "05040B8423F0";
michael@0 55
michael@0 56 let PDU_DATA1 = "C106316170706C69636174696F6E2F76" +
michael@0 57 "6E642E7761702E6D6D732D6D65737361" +
michael@0 58 "676500B131302E382E3133302E313800" +
michael@0 59 "AF84B4818C82986B4430595538595347" +
michael@0 60 "77464E446741416B4876736C58303141" +
michael@0 61 "41414141414141008D90890380310096" +
michael@0 62 "05EA4D4D53008A808E02024188058103" +
michael@0 63 "015F9083687474703A2F2F6D6D732E65";
michael@0 64
michael@0 65 let PDU_DATA2 = "6D6F6D652E6E65743A383030322F6B44" +
michael@0 66 "3059553859534777464E446741416B48" +
michael@0 67 "76736C583031414141414141414100";
michael@0 68
michael@0 69 let PDU_COMMON = PDU_SMSC_NONE + PDU_FIRST_OCTET + PDU_SENDER +
michael@0 70 PDU_PID_NORMAL + aDcs + PDU_TIMESTAMP;
michael@0 71
michael@0 72 function construstBinaryUserData(aBinaryData, aSeqNum) {
michael@0 73 let ieiConcat = "0003" + byteValueToHexString(ref_num) + "02" +
michael@0 74 byteValueToHexString(aSeqNum);
michael@0 75
michael@0 76 let udh = IEI_PORT + ieiConcat;
michael@0 77 let udhl = byteValueToHexString(udh.length / 2);
michael@0 78 let ud = udhl + udh + aBinaryData;
michael@0 79 let udl = byteValueToHexString(ud.length / 2);
michael@0 80
michael@0 81 return udl + ud;
michael@0 82 }
michael@0 83
michael@0 84 return [
michael@0 85 PDU_COMMON + construstBinaryUserData(PDU_DATA1, 1),
michael@0 86 PDU_COMMON + construstBinaryUserData(PDU_DATA2, 2)
michael@0 87 ];
michael@0 88 }
michael@0 89
michael@0 90 function verifyTextMessage(aMessage, aMessageClass) {
michael@0 91 is(aMessage.messageClass, aMessageClass, "SmsMessage class");
michael@0 92 is(aMessage.sender, SENDER, "SmsMessage sender");
michael@0 93 is(aMessage.body, "ABC", "SmsMessage body");
michael@0 94 }
michael@0 95
michael@0 96 function verifyBinaryMessage(aMessage) {
michael@0 97 is(aMessage.type, "mms", "MmsMessage type");
michael@0 98 is(aMessage.delivery, "not-downloaded", "MmsMessage delivery");
michael@0 99
michael@0 100 // remove duplicated M-Notification.ind for next test.
michael@0 101 return deleteMessagesById([aMessage.id]);
michael@0 102 }
michael@0 103
michael@0 104 function testText(aDcs, aClass) {
michael@0 105 log("testText(): aDcs = " + aDcs + ", aClass = " + aClass);
michael@0 106 return sendMultipleRawSmsToEmulatorAndWait(buildTextPdus(aDcs))
michael@0 107 .then((results) => verifyTextMessage(results[0].message, aClass));
michael@0 108 }
michael@0 109
michael@0 110 function testBinary(aDcs) {
michael@0 111 log("testBinary(): aDcs = " + aDcs);
michael@0 112 return sendMultipleRawSmsToEmulatorAndWait(buildBinaryPdus(aDcs))
michael@0 113 .then((results) => verifyBinaryMessage(results[0].message));
michael@0 114 }
michael@0 115
michael@0 116 SpecialPowers.pushPrefEnv(
michael@0 117 {"set": [["dom.mms.retrieval_mode", "manual"]]},
michael@0 118 function startTest() {
michael@0 119 startTestCommon(function testCaseMain() {
michael@0 120 return Promise.resolve()
michael@0 121 .then(() => testText(PDU_DCS_NORMAL_UCS2, "normal"))
michael@0 122 .then(() => testText(PDU_DCS_CLASS0_UCS2, "class-0"))
michael@0 123 .then(() => testBinary(PDU_DCS_NORMAL_8BIT))
michael@0 124 .then(() => testBinary(PDU_DCS_CLASS0_8BIT));
michael@0 125 });
michael@0 126 }
michael@0 127 );

mercurial