dom/mobilemessage/tests/test_mms_service.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 function newMmsTransactionHelper() {
michael@0 5 let MMS_Service = {};
michael@0 6 subscriptLoader.loadSubScript("resource://gre/components/MmsService.js", MMS_Service);
michael@0 7 MMS_Service.debug = do_print;
michael@0 8 return MMS_Service.gMmsTransactionHelper;
michael@0 9 }
michael@0 10 let CallFunc = newMmsTransactionHelper();
michael@0 11 function run_test() {
michael@0 12 run_next_test();
michael@0 13 }
michael@0 14
michael@0 15 //
michael@0 16 // Test target: checkMaxValuesParameters
michael@0 17 //
michael@0 18
michael@0 19 //// Test Long Subject field ////
michael@0 20 //// @see OMA-ETS-MMS_CON-V1_3-20080128-C 5.1.1.1.10 MMS-1.3-con-171 ////
michael@0 21
michael@0 22 add_test(function test_LongSubjectField() {
michael@0 23 let msg = {};
michael@0 24 msg.headers = {};
michael@0 25 // Test for normal TextString
michael@0 26 msg.headers["subject"] = "abcdefghijklmnopqrstuvwxyz0123456789/-+@?";
michael@0 27 do_check_eq(CallFunc.checkMaxValuesParameters(msg), false);
michael@0 28
michael@0 29 run_next_test();
michael@0 30 });
michael@0 31
michael@0 32 //// Test recipient field length
michael@0 33
michael@0 34 add_test(function test_LongRecipientField() {
michael@0 35 let msg = {};
michael@0 36 msg.headers = {};
michael@0 37 msg.headers["to"] = [
michael@0 38 { address:
michael@0 39 "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" +
michael@0 40 "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" +
michael@0 41 "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" +
michael@0 42 "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" +
michael@0 43 "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" +
michael@0 44 "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" +
michael@0 45 "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" +
michael@0 46 "abcdefghijklmnopqrstuvwxyz",
michael@0 47 type: "PLMN" },
michael@0 48 ];
michael@0 49 do_check_eq(CallFunc.checkMaxValuesParameters(msg), false);
michael@0 50
michael@0 51 run_next_test();
michael@0 52 });
michael@0 53
michael@0 54
michael@0 55 add_test(function test_checkMaxValuesParameters() {
michael@0 56 let msg = {};
michael@0 57 msg.headers = {};
michael@0 58 msg.headers["cc"] = [
michael@0 59 { address: "+789", type: "PLMN" },
michael@0 60 { address: "+119", type: "num" },
michael@0 61 { address: "Joe2 User " +
michael@0 62 "<abcdefghijklmnopqrstuvwxyz0123456789" +
michael@0 63 "abcdefghijklmnopqrstuvwxyz0123456789@" +
michael@0 64 "abcdefghijklmnopqrstuvwxyz0123456789" +
michael@0 65 "abcdefghijklmnopqrstuvwxyz0123456789." +
michael@0 66 "abcdefghijklmnopqrstuvwxyz0123456789" +
michael@0 67 "abcdefghijklmnopqrstuvwxyz0123456789" +
michael@0 68 "abcdefghijklmnopqrstuvwxyz0123456789->"
michael@0 69 , type: "email" },
michael@0 70 ];
michael@0 71 do_check_eq(CallFunc.checkMaxValuesParameters(msg), false);
michael@0 72
michael@0 73 run_next_test();
michael@0 74 });
michael@0 75
michael@0 76 //// Test total recipient count over 20
michael@0 77
michael@0 78 add_test(function test_TotalRecipientCount() {
michael@0 79 let msg = {};
michael@0 80 msg.headers = {};
michael@0 81 do_check_eq(CallFunc.checkMaxValuesParameters(msg), false);
michael@0 82
michael@0 83 msg.headers["to"] = [
michael@0 84 { address: "+123", type: "PLMN" },
michael@0 85 { address: "+456", type: "num" },
michael@0 86 { address: "Joe User <joe@user.org>", type: "email" },
michael@0 87 { address: "+123", type: "PLMN" },
michael@0 88 { address: "+456", type: "num" },
michael@0 89 { address: "Joe User <joe@user.org>", type: "email" },
michael@0 90 { address: "+123", type: "PLMN" },
michael@0 91 ];
michael@0 92 msg.headers["cc"] = [
michael@0 93 { address: "+789", type: "PLMN" },
michael@0 94 { address: "+119", type: "num" },
michael@0 95 { address: "Joe2 User <joe2@user.org>", type: "email" },
michael@0 96 { address: "+789", type: "PLMN" },
michael@0 97 { address: "+119", type: "num" },
michael@0 98 { address: "Joe2 User <joe2@user.org>", type: "email" },
michael@0 99 { address: "+789", type: "PLMN" },
michael@0 100 ];
michael@0 101 msg.headers["bcc"] = [
michael@0 102 { address: "+110", type: "num" },
michael@0 103 { address: "Joe3 User <joe2@user.org>", type: "email" },
michael@0 104 { address: "Joe2 User <joe2@user.org>", type: "email" },
michael@0 105 { address: "+789", type: "PLMN" },
michael@0 106 { address: "+119", type: "num" },
michael@0 107 { address: "Joe2 User <joe2@user.org>", type: "email" },
michael@0 108 { address: "+789", type: "PLMN" },
michael@0 109 ];
michael@0 110 do_check_eq(CallFunc.checkMaxValuesParameters(msg), false);
michael@0 111
michael@0 112 run_next_test();
michael@0 113 });
michael@0 114
michael@0 115 ////Test name parameter in content-type field of multi-parts
michael@0 116
michael@0 117 add_test(function test_NameParameterInContentType() {
michael@0 118 let msg = {};
michael@0 119 msg.headers = {};
michael@0 120 msg.headers["to"] = [
michael@0 121 { address: "Joe User <joe@user.org>", type: "email" },
michael@0 122 ];
michael@0 123 let params = {};
michael@0 124 params["name"] = "abcdefghijklmnopqrstuvwxyz0123456789/-+@?";
michael@0 125 let headers = {};
michael@0 126 headers["content-type"] = {
michael@0 127 media: null,
michael@0 128 params: params,
michael@0 129 };
michael@0 130 msg.parts = new Array(1);
michael@0 131 msg.parts[0] = {
michael@0 132 index: 0,
michael@0 133 headers: headers,
michael@0 134 content: null,
michael@0 135 };
michael@0 136 do_check_eq(CallFunc.checkMaxValuesParameters(msg), false);
michael@0 137
michael@0 138 run_next_test();
michael@0 139 });

mercurial