michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function newMmsTransactionHelper() { michael@0: let MMS_Service = {}; michael@0: subscriptLoader.loadSubScript("resource://gre/components/MmsService.js", MMS_Service); michael@0: MMS_Service.debug = do_print; michael@0: return MMS_Service.gMmsTransactionHelper; michael@0: } michael@0: let CallFunc = newMmsTransactionHelper(); michael@0: function run_test() { michael@0: run_next_test(); michael@0: } michael@0: michael@0: // michael@0: // Test target: checkMaxValuesParameters michael@0: // michael@0: michael@0: //// Test Long Subject field //// michael@0: //// @see OMA-ETS-MMS_CON-V1_3-20080128-C 5.1.1.1.10 MMS-1.3-con-171 //// michael@0: michael@0: add_test(function test_LongSubjectField() { michael@0: let msg = {}; michael@0: msg.headers = {}; michael@0: // Test for normal TextString michael@0: msg.headers["subject"] = "abcdefghijklmnopqrstuvwxyz0123456789/-+@?"; michael@0: do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: michael@0: //// Test recipient field length michael@0: michael@0: add_test(function test_LongRecipientField() { michael@0: let msg = {}; michael@0: msg.headers = {}; michael@0: msg.headers["to"] = [ michael@0: { address: michael@0: "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + michael@0: "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + michael@0: "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + michael@0: "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + michael@0: "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + michael@0: "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + michael@0: "abcdefghijklmnopqrstuvwxyz0123456789/-+@?" + michael@0: "abcdefghijklmnopqrstuvwxyz", michael@0: type: "PLMN" }, michael@0: ]; michael@0: do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: michael@0: michael@0: add_test(function test_checkMaxValuesParameters() { michael@0: let msg = {}; michael@0: msg.headers = {}; michael@0: msg.headers["cc"] = [ michael@0: { address: "+789", type: "PLMN" }, michael@0: { address: "+119", type: "num" }, michael@0: { address: "Joe2 User " + michael@0: "" michael@0: , type: "email" }, michael@0: ]; michael@0: do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: michael@0: //// Test total recipient count over 20 michael@0: michael@0: add_test(function test_TotalRecipientCount() { michael@0: let msg = {}; michael@0: msg.headers = {}; michael@0: do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); michael@0: michael@0: msg.headers["to"] = [ michael@0: { address: "+123", type: "PLMN" }, michael@0: { address: "+456", type: "num" }, michael@0: { address: "Joe User ", type: "email" }, michael@0: { address: "+123", type: "PLMN" }, michael@0: { address: "+456", type: "num" }, michael@0: { address: "Joe User ", type: "email" }, michael@0: { address: "+123", type: "PLMN" }, michael@0: ]; michael@0: msg.headers["cc"] = [ michael@0: { address: "+789", type: "PLMN" }, michael@0: { address: "+119", type: "num" }, michael@0: { address: "Joe2 User ", type: "email" }, michael@0: { address: "+789", type: "PLMN" }, michael@0: { address: "+119", type: "num" }, michael@0: { address: "Joe2 User ", type: "email" }, michael@0: { address: "+789", type: "PLMN" }, michael@0: ]; michael@0: msg.headers["bcc"] = [ michael@0: { address: "+110", type: "num" }, michael@0: { address: "Joe3 User ", type: "email" }, michael@0: { address: "Joe2 User ", type: "email" }, michael@0: { address: "+789", type: "PLMN" }, michael@0: { address: "+119", type: "num" }, michael@0: { address: "Joe2 User ", type: "email" }, michael@0: { address: "+789", type: "PLMN" }, michael@0: ]; michael@0: do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: michael@0: ////Test name parameter in content-type field of multi-parts michael@0: michael@0: add_test(function test_NameParameterInContentType() { michael@0: let msg = {}; michael@0: msg.headers = {}; michael@0: msg.headers["to"] = [ michael@0: { address: "Joe User ", type: "email" }, michael@0: ]; michael@0: let params = {}; michael@0: params["name"] = "abcdefghijklmnopqrstuvwxyz0123456789/-+@?"; michael@0: let headers = {}; michael@0: headers["content-type"] = { michael@0: media: null, michael@0: params: params, michael@0: }; michael@0: msg.parts = new Array(1); michael@0: msg.parts[0] = { michael@0: index: 0, michael@0: headers: headers, michael@0: content: null, michael@0: }; michael@0: do_check_eq(CallFunc.checkMaxValuesParameters(msg), false); michael@0: michael@0: run_next_test(); michael@0: });