1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/mobilemessage/tests/test_mms_service.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,139 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function newMmsTransactionHelper() { 1.8 + let MMS_Service = {}; 1.9 + subscriptLoader.loadSubScript("resource://gre/components/MmsService.js", MMS_Service); 1.10 + MMS_Service.debug = do_print; 1.11 + return MMS_Service.gMmsTransactionHelper; 1.12 +} 1.13 +let CallFunc = newMmsTransactionHelper(); 1.14 +function run_test() { 1.15 + run_next_test(); 1.16 +} 1.17 + 1.18 +// 1.19 +// Test target: checkMaxValuesParameters 1.20 +// 1.21 + 1.22 +//// Test Long Subject field //// 1.23 +//// @see OMA-ETS-MMS_CON-V1_3-20080128-C 5.1.1.1.10 MMS-1.3-con-171 //// 1.24 + 1.25 +add_test(function test_LongSubjectField() { 1.26 + let msg = {}; 1.27 + msg.headers = {}; 1.28 + // Test for normal TextString 1.29 + msg.headers["subject"] = "abcdefghijklmnopqrstuvwxyz0123456789/-+@?"; 1.30 + do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); 1.31 + 1.32 + run_next_test(); 1.33 +}); 1.34 + 1.35 +//// Test recipient field length 1.36 + 1.37 +add_test(function test_LongRecipientField() { 1.38 + let msg = {}; 1.39 + msg.headers = {}; 1.40 + msg.headers["to"] = [ 1.41 + { address: 1.42 + "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + 1.43 + "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + 1.44 + "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + 1.45 + "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + 1.46 + "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + 1.47 + "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + 1.48 + "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + 1.49 + "abcdefghijklmnopqrstuvwxyz", 1.50 + type: "PLMN" }, 1.51 + ]; 1.52 + do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); 1.53 + 1.54 + run_next_test(); 1.55 +}); 1.56 + 1.57 + 1.58 +add_test(function test_checkMaxValuesParameters() { 1.59 + let msg = {}; 1.60 + msg.headers = {}; 1.61 + msg.headers["cc"] = [ 1.62 + { address: "+789", type: "PLMN" }, 1.63 + { address: "+119", type: "num" }, 1.64 + { address: "Joe2 User " + 1.65 + "<abcdefghijklmnopqrstuvwxyz0123456789" + 1.66 + "abcdefghijklmnopqrstuvwxyz0123456789@" + 1.67 + "abcdefghijklmnopqrstuvwxyz0123456789" + 1.68 + "abcdefghijklmnopqrstuvwxyz0123456789." + 1.69 + "abcdefghijklmnopqrstuvwxyz0123456789" + 1.70 + "abcdefghijklmnopqrstuvwxyz0123456789" + 1.71 + "abcdefghijklmnopqrstuvwxyz0123456789->" 1.72 + , type: "email" }, 1.73 + ]; 1.74 + do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); 1.75 + 1.76 + run_next_test(); 1.77 +}); 1.78 + 1.79 +//// Test total recipient count over 20 1.80 + 1.81 +add_test(function test_TotalRecipientCount() { 1.82 + let msg = {}; 1.83 + msg.headers = {}; 1.84 + do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); 1.85 + 1.86 + msg.headers["to"] = [ 1.87 + { address: "+123", type: "PLMN" }, 1.88 + { address: "+456", type: "num" }, 1.89 + { address: "Joe User <joe@user.org>", type: "email" }, 1.90 + { address: "+123", type: "PLMN" }, 1.91 + { address: "+456", type: "num" }, 1.92 + { address: "Joe User <joe@user.org>", type: "email" }, 1.93 + { address: "+123", type: "PLMN" }, 1.94 + ]; 1.95 + msg.headers["cc"] = [ 1.96 + { address: "+789", type: "PLMN" }, 1.97 + { address: "+119", type: "num" }, 1.98 + { address: "Joe2 User <joe2@user.org>", type: "email" }, 1.99 + { address: "+789", type: "PLMN" }, 1.100 + { address: "+119", type: "num" }, 1.101 + { address: "Joe2 User <joe2@user.org>", type: "email" }, 1.102 + { address: "+789", type: "PLMN" }, 1.103 + ]; 1.104 + msg.headers["bcc"] = [ 1.105 + { address: "+110", type: "num" }, 1.106 + { address: "Joe3 User <joe2@user.org>", type: "email" }, 1.107 + { address: "Joe2 User <joe2@user.org>", type: "email" }, 1.108 + { address: "+789", type: "PLMN" }, 1.109 + { address: "+119", type: "num" }, 1.110 + { address: "Joe2 User <joe2@user.org>", type: "email" }, 1.111 + { address: "+789", type: "PLMN" }, 1.112 + ]; 1.113 + do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); 1.114 + 1.115 + run_next_test(); 1.116 +}); 1.117 + 1.118 +////Test name parameter in content-type field of multi-parts 1.119 + 1.120 +add_test(function test_NameParameterInContentType() { 1.121 + let msg = {}; 1.122 + msg.headers = {}; 1.123 + msg.headers["to"] = [ 1.124 + { address: "Joe User <joe@user.org>", type: "email" }, 1.125 + ]; 1.126 + let params = {}; 1.127 + params["name"] = "abcdefghijklmnopqrstuvwxyz0123456789/-+@?"; 1.128 + let headers = {}; 1.129 + headers["content-type"] = { 1.130 + media: null, 1.131 + params: params, 1.132 + }; 1.133 + msg.parts = new Array(1); 1.134 + msg.parts[0] = { 1.135 + index: 0, 1.136 + headers: headers, 1.137 + content: null, 1.138 + }; 1.139 + do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); 1.140 + 1.141 + run_next_test(); 1.142 +}); 1.143 \ No newline at end of file