dom/mobilemessage/tests/test_mms_service.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial