dom/mobilemessage/tests/test_wsp_pdu_helper.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.

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 let WSP = {};
michael@0 5 subscriptLoader.loadSubScript("resource://gre/modules/WspPduHelper.jsm", WSP);
michael@0 6 WSP.debug = do_print;
michael@0 7
michael@0 8 function run_test() {
michael@0 9 run_next_test();
michael@0 10 }
michael@0 11
michael@0 12 //
michael@0 13 // Test target: ensureHeader
michael@0 14 //
michael@0 15
michael@0 16 add_test(function test_ensureHeader() {
michael@0 17 do_check_throws(function() {
michael@0 18 WSP.ensureHeader({}, "no-such-property");
michael@0 19 }, "FatalCodeError"
michael@0 20 );
michael@0 21
michael@0 22 run_next_test();
michael@0 23 });
michael@0 24
michael@0 25 //
michael@0 26 // Test target: skipValue()
michael@0 27 //
michael@0 28
michael@0 29 add_test(function test_skipValue() {
michael@0 30 function func(data) {
michael@0 31 return WSP.skipValue(data);
michael@0 32 }
michael@0 33
michael@0 34 // Test for zero-valued first octet:
michael@0 35 wsp_decode_test_ex(func, [0], null);
michael@0 36 // Test first octet < 31
michael@0 37 wsp_decode_test_ex(func, [1, 2], [2]);
michael@0 38 // Test first octet = 31
michael@0 39 wsp_decode_test_ex(func, [31, 0], null);
michael@0 40 wsp_decode_test_ex(func, [31, 1, 2], [2]);
michael@0 41 // Test first octet <= 127
michael@0 42 wsp_decode_test_ex(func, strToCharCodeArray("Hello world!"), "Hello world!");
michael@0 43 // Test first octet >= 128
michael@0 44 wsp_decode_test_ex(func, [0x80 | 0x01], 0x01);
michael@0 45
michael@0 46 run_next_test();
michael@0 47 });
michael@0 48
michael@0 49 //
michael@0 50 // Test target: Octet
michael@0 51 //
michael@0 52
michael@0 53 //// Octet.decode ////
michael@0 54
michael@0 55 add_test(function test_Octet_decode() {
michael@0 56 wsp_decode_test(WSP.Octet, [1], 1);
michael@0 57 wsp_decode_test(WSP.Octet, [], null, "RangeError");
michael@0 58
michael@0 59 run_next_test();
michael@0 60 });
michael@0 61
michael@0 62 //// Octet.decodeMultiple ////
michael@0 63
michael@0 64 add_test(function test_Octet_decodeMultiple() {
michael@0 65 wsp_decode_test_ex(function(data) {
michael@0 66 return WSP.Octet.decodeMultiple(data, 3);
michael@0 67 }, [0, 1, 2], [0, 1, 2], null
michael@0 68 );
michael@0 69 wsp_decode_test_ex(function(data) {
michael@0 70 return WSP.Octet.decodeMultiple(data, 3);
michael@0 71 }, new Uint8Array([0, 1, 2]), new Uint8Array([0, 1, 2]), null
michael@0 72 );
michael@0 73 wsp_decode_test_ex(function(data) {
michael@0 74 return WSP.Octet.decodeMultiple(data, 4);
michael@0 75 }, [0, 1, 2], null, "RangeError"
michael@0 76 );
michael@0 77
michael@0 78 run_next_test();
michael@0 79 });
michael@0 80
michael@0 81 //// Octet.decodeEqualTo ////
michael@0 82
michael@0 83 add_test(function test_Octet_decodeEqualTo() {
michael@0 84 wsp_decode_test_ex(function(data) {
michael@0 85 return WSP.Octet.decodeEqualTo(data, 1);
michael@0 86 }, [1], 1, null
michael@0 87 );
michael@0 88 wsp_decode_test_ex(function(data) {
michael@0 89 return WSP.Octet.decodeEqualTo(data, 2);
michael@0 90 }, [1], null, "CodeError"
michael@0 91 );
michael@0 92 wsp_decode_test_ex(function(data) {
michael@0 93 return WSP.Octet.decodeEqualTo(data, 2);
michael@0 94 }, [], null, "RangeError"
michael@0 95 );
michael@0 96
michael@0 97 run_next_test();
michael@0 98 });
michael@0 99
michael@0 100 //// Octet.encode ////
michael@0 101
michael@0 102 add_test(function test_Octet_encode() {
michael@0 103 for (let i = 0; i < 256; i++) {
michael@0 104 wsp_encode_test(WSP.Octet, i, [i]);
michael@0 105 }
michael@0 106
michael@0 107 run_next_test();
michael@0 108 });
michael@0 109
michael@0 110 //// Octet.encodeMultiple ////
michael@0 111
michael@0 112 add_test(function test_Octet_encodeMultiple() {
michael@0 113 wsp_encode_test_ex(function(data, input) {
michael@0 114 WSP.Octet.encodeMultiple(data, input);
michael@0 115 return data.array;
michael@0 116 }, [0, 1, 2, 3], [0, 1, 2, 3]);
michael@0 117
michael@0 118 run_next_test();
michael@0 119 });
michael@0 120
michael@0 121 //
michael@0 122 // Test target: Text
michael@0 123 //
michael@0 124
michael@0 125 //// Text.decode ////
michael@0 126
michael@0 127 add_test(function test_Text_decode() {
michael@0 128 for (let i = 0; i < 256; i++) {
michael@0 129 if (i == 0) {
michael@0 130 wsp_decode_test(WSP.Text, [0], null, "NullCharError");
michael@0 131 } else if ((i < WSP.CTLS) || (i == WSP.DEL)) {
michael@0 132 wsp_decode_test(WSP.Text, [i], null, "CodeError");
michael@0 133 } else {
michael@0 134 wsp_decode_test(WSP.Text, [i], String.fromCharCode(i));
michael@0 135 }
michael@0 136 }
michael@0 137 // Test \r\n(SP|HT)* sequence:
michael@0 138 wsp_decode_test(WSP.Text, strToCharCodeArray("\r\n \t \t \t", true), " ");
michael@0 139 wsp_decode_test(WSP.Text, strToCharCodeArray("\r\n \t \t \t"), " ");
michael@0 140 wsp_decode_test(WSP.Text, strToCharCodeArray("\r\n \t \t \tA"), " ");
michael@0 141
michael@0 142 run_next_test();
michael@0 143 });
michael@0 144
michael@0 145 //// Text.encode ////
michael@0 146
michael@0 147 add_test(function test_Text_encode() {
michael@0 148 for (let i = 0; i < 256; i++) {
michael@0 149 if ((i < WSP.CTLS) || (i == WSP.DEL)) {
michael@0 150 wsp_encode_test(WSP.Text, String.fromCharCode(i), null, "CodeError");
michael@0 151 } else {
michael@0 152 wsp_encode_test(WSP.Text, String.fromCharCode(i), [i]);
michael@0 153 }
michael@0 154 }
michael@0 155
michael@0 156 run_next_test();
michael@0 157 });
michael@0 158
michael@0 159 //
michael@0 160 // Test target: NullTerminatedTexts
michael@0 161 //
michael@0 162
michael@0 163 //// NullTerminatedTexts.decode ////
michael@0 164
michael@0 165 add_test(function test_NullTerminatedTexts_decode() {
michael@0 166 // Test incompleted string:
michael@0 167 wsp_decode_test(WSP.NullTerminatedTexts, strToCharCodeArray(" ", true), null, "RangeError");
michael@0 168 // Test control char:
michael@0 169 wsp_decode_test(WSP.NullTerminatedTexts, strToCharCodeArray(" \n"), null, "CodeError");
michael@0 170 // Test normal string:
michael@0 171 wsp_decode_test(WSP.NullTerminatedTexts, strToCharCodeArray(""), "");
michael@0 172 wsp_decode_test(WSP.NullTerminatedTexts, strToCharCodeArray("oops"), "oops");
michael@0 173 // Test \r\n(SP|HT)* sequence:
michael@0 174 wsp_decode_test(WSP.NullTerminatedTexts, strToCharCodeArray("A\r\n \t \t \tB"), "A B");
michael@0 175
michael@0 176 run_next_test();
michael@0 177 });
michael@0 178
michael@0 179 //// NullTerminatedTexts.encode ////
michael@0 180
michael@0 181 add_test(function test_NullTerminatedTexts_encode() {
michael@0 182 wsp_encode_test(WSP.NullTerminatedTexts, "", [0]);
michael@0 183 wsp_encode_test(WSP.NullTerminatedTexts, "Hello, World!",
michael@0 184 strToCharCodeArray("Hello, World!"));
michael@0 185
michael@0 186 run_next_test();
michael@0 187 });
michael@0 188
michael@0 189 //
michael@0 190 // Test target: Token
michael@0 191 //
michael@0 192
michael@0 193 let TOKEN_SEPS = "()<>@,;:\\\"/[]?={} \t";
michael@0 194
michael@0 195 //// Token.decode ////
michael@0 196
michael@0 197 add_test(function test_Token_decode() {
michael@0 198 for (let i = 0; i < 256; i++) {
michael@0 199 if (i == 0) {
michael@0 200 wsp_decode_test(WSP.Token, [i], null, "NullCharError");
michael@0 201 } else if ((i < WSP.CTLS) || (i >= WSP.ASCIIS)
michael@0 202 || (TOKEN_SEPS.indexOf(String.fromCharCode(i)) >= 0)) {
michael@0 203 wsp_decode_test(WSP.Token, [i], null, "CodeError");
michael@0 204 } else {
michael@0 205 wsp_decode_test(WSP.Token, [i], String.fromCharCode(i));
michael@0 206 }
michael@0 207 }
michael@0 208
michael@0 209 run_next_test();
michael@0 210 });
michael@0 211
michael@0 212 //// Token.encode ////
michael@0 213
michael@0 214 add_test(function test_Token_encode() {
michael@0 215 for (let i = 0; i < 256; i++) {
michael@0 216 if ((i < WSP.CTLS) || (i >= WSP.ASCIIS)
michael@0 217 || (TOKEN_SEPS.indexOf(String.fromCharCode(i)) >= 0)) {
michael@0 218 wsp_encode_test(WSP.Token, String.fromCharCode(i), null, "CodeError");
michael@0 219 } else {
michael@0 220 wsp_encode_test(WSP.Token, String.fromCharCode(i), [i]);
michael@0 221 }
michael@0 222 }
michael@0 223
michael@0 224 run_next_test();
michael@0 225 });
michael@0 226
michael@0 227 //
michael@0 228 // Test target: URIC
michael@0 229 //
michael@0 230
michael@0 231 //// URIC.decode ////
michael@0 232
michael@0 233 add_test(function test_URIC_decode() {
michael@0 234 let uric = "!#$%&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMN"
michael@0 235 + "OPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~";
michael@0 236 for (let i = 0; i < 256; i++) {
michael@0 237 if (i == 0) {
michael@0 238 wsp_decode_test(WSP.URIC, [i], null, "NullCharError");
michael@0 239 } else if (uric.indexOf(String.fromCharCode(i)) >= 0) {
michael@0 240 wsp_decode_test(WSP.URIC, [i], String.fromCharCode(i));
michael@0 241 } else {
michael@0 242 wsp_decode_test(WSP.URIC, [i], null, "CodeError");
michael@0 243 }
michael@0 244 }
michael@0 245
michael@0 246 run_next_test();
michael@0 247 });
michael@0 248
michael@0 249 //
michael@0 250 // Test target: TextString
michael@0 251 //
michael@0 252
michael@0 253 //// TextString.decode ////
michael@0 254
michael@0 255 add_test(function test_TextString_decode() {
michael@0 256 // Test quoted string
michael@0 257 wsp_decode_test(WSP.TextString, [127, 128, 0], String.fromCharCode(128));
michael@0 258 // Test illegal quoted string
michael@0 259 wsp_decode_test(WSP.TextString, [127, 32, 0], null, "CodeError");
michael@0 260 // Test illegal unquoted string
michael@0 261 wsp_decode_test(WSP.TextString, [128, 0], null, "CodeError");
michael@0 262 // Test normal string
michael@0 263 wsp_decode_test(WSP.TextString, [32, 0], " ");
michael@0 264
michael@0 265 run_next_test();
michael@0 266 });
michael@0 267
michael@0 268 //// TextString.encode ////
michael@0 269
michael@0 270 add_test(function test_TextString_encode() {
michael@0 271 // Test quoted string
michael@0 272 wsp_encode_test(WSP.TextString, String.fromCharCode(128), [127, 128, 0]);
michael@0 273 // Test normal string
michael@0 274 wsp_encode_test(WSP.TextString, "Mozilla", strToCharCodeArray("Mozilla"));
michael@0 275
michael@0 276 run_next_test();
michael@0 277 });
michael@0 278
michael@0 279 //
michael@0 280 // Test target: TokenText
michael@0 281 //
michael@0 282
michael@0 283 //// TokenText.decode ////
michael@0 284
michael@0 285 add_test(function test_TokenText_decode() {
michael@0 286 wsp_decode_test(WSP.TokenText, [65], null, "RangeError");
michael@0 287 wsp_decode_test(WSP.TokenText, [0], "");
michael@0 288 wsp_decode_test(WSP.TokenText, [65, 0], "A");
michael@0 289
michael@0 290 run_next_test();
michael@0 291 });
michael@0 292
michael@0 293 //// TokenText.encode ////
michael@0 294
michael@0 295 add_test(function test_TokenText_encode() {
michael@0 296 wsp_encode_test(WSP.TokenText, "B2G", strToCharCodeArray("B2G"));
michael@0 297
michael@0 298 run_next_test();
michael@0 299 });
michael@0 300
michael@0 301 //
michael@0 302 // Test target: QuotedString
michael@0 303 //
michael@0 304
michael@0 305 //// QuotedString.decode ////
michael@0 306
michael@0 307 add_test(function test_QuotedString_decode() {
michael@0 308 // Test non-quoted string
michael@0 309 wsp_decode_test(WSP.QuotedString, [32, 0], null, "CodeError");
michael@0 310 // Test incompleted string
michael@0 311 wsp_decode_test(WSP.QuotedString, [34, 32], null, "RangeError");
michael@0 312 wsp_decode_test(WSP.QuotedString, [34, 32, 0], " ");
michael@0 313
michael@0 314 run_next_test();
michael@0 315 });
michael@0 316
michael@0 317 //// QuotedString.encode ////
michael@0 318
michael@0 319 add_test(function test_QuotedString_encode() {
michael@0 320 wsp_encode_test(WSP.QuotedString, "B2G", [34].concat(strToCharCodeArray("B2G")));
michael@0 321
michael@0 322 run_next_test();
michael@0 323 });
michael@0 324
michael@0 325 //
michael@0 326 // Test target: ShortInteger
michael@0 327 //
michael@0 328
michael@0 329 //// ShortInteger.decode ////
michael@0 330
michael@0 331 add_test(function test_ShortInteger_decode() {
michael@0 332 for (let i = 0; i < 256; i++) {
michael@0 333 if (i & 0x80) {
michael@0 334 wsp_decode_test(WSP.ShortInteger, [i], i & 0x7F);
michael@0 335 } else {
michael@0 336 wsp_decode_test(WSP.ShortInteger, [i], null, "CodeError");
michael@0 337 }
michael@0 338 }
michael@0 339
michael@0 340 run_next_test();
michael@0 341 });
michael@0 342
michael@0 343 //// ShortInteger.encode ////
michael@0 344
michael@0 345 add_test(function test_ShortInteger_encode() {
michael@0 346 for (let i = 0; i < 256; i++) {
michael@0 347 if (i & 0x80) {
michael@0 348 wsp_encode_test(WSP.ShortInteger, i, null, "CodeError");
michael@0 349 } else {
michael@0 350 wsp_encode_test(WSP.ShortInteger, i, [0x80 | i]);
michael@0 351 }
michael@0 352 }
michael@0 353
michael@0 354 run_next_test();
michael@0 355 });
michael@0 356
michael@0 357 //
michael@0 358 // Test target: LongInteger
michael@0 359 //
michael@0 360
michael@0 361 //// LongInteger.decode ////
michael@0 362
michael@0 363 function LongInteger_decode_testcases(target) {
michael@0 364 // Test LongInteger of zero octet
michael@0 365 wsp_decode_test(target, [0, 0], null, "CodeError");
michael@0 366 wsp_decode_test(target, [1, 0x80], 0x80);
michael@0 367 wsp_decode_test(target, [2, 0x80, 2], 0x8002);
michael@0 368 wsp_decode_test(target, [3, 0x80, 2, 3], 0x800203);
michael@0 369 wsp_decode_test(target, [4, 0x80, 2, 3, 4], 0x80020304);
michael@0 370 wsp_decode_test(target, [5, 0x80, 2, 3, 4, 5], 0x8002030405);
michael@0 371 wsp_decode_test(target, [6, 0x80, 2, 3, 4, 5, 6], 0x800203040506);
michael@0 372 // Test LongInteger of more than 6 octets
michael@0 373 wsp_decode_test(target, [7, 0x80, 2, 3, 4, 5, 6, 7], [0x80, 2, 3, 4, 5, 6, 7]);
michael@0 374 // Test LongInteger of more than 30 octets
michael@0 375 wsp_decode_test(target, [31], null, "CodeError");
michael@0 376 }
michael@0 377 add_test(function test_LongInteger_decode() {
michael@0 378 LongInteger_decode_testcases(WSP.LongInteger);
michael@0 379
michael@0 380 run_next_test();
michael@0 381 });
michael@0 382
michael@0 383 //// LongInteger.encode ////
michael@0 384
michael@0 385 function LongInteger_encode_testcases(target) {
michael@0 386 wsp_encode_test(target, 0x80, [1, 0x80]);
michael@0 387 wsp_encode_test(target, 0x8002, [2, 0x80, 2]);
michael@0 388 wsp_encode_test(target, 0x800203, [3, 0x80, 2, 3]);
michael@0 389 wsp_encode_test(target, 0x80020304, [4, 0x80, 2, 3, 4]);
michael@0 390 wsp_encode_test(target, 0x8002030405, [5, 0x80, 2, 3, 4, 5]);
michael@0 391 wsp_encode_test(target, 0x800203040506, [6, 0x80, 2, 3, 4, 5, 6]);
michael@0 392 // Test LongInteger of more than 6 octets
michael@0 393 wsp_encode_test(target, 0x1000000000000, null, "CodeError");
michael@0 394 // Test input empty array
michael@0 395 wsp_encode_test(target, [], null, "CodeError");
michael@0 396 // Test input octets array of length 1..30
michael@0 397 let array = [];
michael@0 398 for (let i = 1; i <= 30; i++) {
michael@0 399 array.push(i);
michael@0 400 wsp_encode_test(target, array, [i].concat(array));
michael@0 401 }
michael@0 402 // Test input octets array of 31 elements.
michael@0 403 array.push(31);
michael@0 404 wsp_encode_test(target, array, null, "CodeError");
michael@0 405 }
michael@0 406 add_test(function test_LongInteger_encode() {
michael@0 407 wsp_encode_test(WSP.LongInteger, 0, [1, 0]);
michael@0 408
michael@0 409 LongInteger_encode_testcases(WSP.LongInteger);
michael@0 410
michael@0 411 run_next_test();
michael@0 412 });
michael@0 413
michael@0 414 //
michael@0 415 // Test target: UintVar
michael@0 416 //
michael@0 417
michael@0 418 //// UintVar.decode ////
michael@0 419
michael@0 420 add_test(function test_UintVar_decode() {
michael@0 421 wsp_decode_test(WSP.UintVar, [0x80], null, "RangeError");
michael@0 422 // Test up to max 53 bits integer
michael@0 423 wsp_decode_test(WSP.UintVar, [0x7F], 0x7F);
michael@0 424 wsp_decode_test(WSP.UintVar, [0xFF, 0x7F], 0x3FFF);
michael@0 425 wsp_decode_test(WSP.UintVar, [0xFF, 0xFF, 0x7F], 0x1FFFFF);
michael@0 426 wsp_decode_test(WSP.UintVar, [0xFF, 0xFF, 0xFF, 0x7F], 0xFFFFFFF);
michael@0 427 wsp_decode_test(WSP.UintVar, [0xFF, 0xFF, 0xFF, 0xFF, 0x7F], 0x7FFFFFFFF);
michael@0 428 wsp_decode_test(WSP.UintVar, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F], 0x3FFFFFFFFFF);
michael@0 429 wsp_decode_test(WSP.UintVar, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F], 0x1FFFFFFFFFFFF);
michael@0 430 wsp_decode_test(WSP.UintVar, [0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F], 0x1FFFFFFFFFFFFF);
michael@0 431 wsp_decode_test(WSP.UintVar, [0x01, 0x02], 1);
michael@0 432 wsp_decode_test(WSP.UintVar, [0x80, 0x01, 0x02], 1);
michael@0 433 wsp_decode_test(WSP.UintVar, [0x80, 0x80, 0x80, 0x01, 0x2], 1);
michael@0 434
michael@0 435 run_next_test();
michael@0 436 });
michael@0 437
michael@0 438 //// UintVar.encode ////
michael@0 439
michael@0 440 add_test(function test_UintVar_encode() {
michael@0 441 // Test up to max 53 bits integer
michael@0 442 wsp_encode_test(WSP.UintVar, 0, [0]);
michael@0 443 wsp_encode_test(WSP.UintVar, 0x7F, [0x7F]);
michael@0 444 wsp_encode_test(WSP.UintVar, 0x3FFF, [0xFF, 0x7F]);
michael@0 445 wsp_encode_test(WSP.UintVar, 0x1FFFFF, [0xFF, 0xFF, 0x7F]);
michael@0 446 wsp_encode_test(WSP.UintVar, 0xFFFFFFF, [0xFF, 0xFF, 0xFF, 0x7F]);
michael@0 447 wsp_encode_test(WSP.UintVar, 0x7FFFFFFFF, [0xFF, 0xFF, 0xFF, 0xFF, 0x7F]);
michael@0 448 wsp_encode_test(WSP.UintVar, 0x3FFFFFFFFFF, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F]);
michael@0 449 wsp_encode_test(WSP.UintVar, 0x1FFFFFFFFFFFF, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F]);
michael@0 450 wsp_encode_test(WSP.UintVar, 0x1FFFFFFFFFFFFF, [0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F]);
michael@0 451
michael@0 452 run_next_test();
michael@0 453 });
michael@0 454
michael@0 455 //
michael@0 456 // Test target: ConstrainedEncoding
michael@0 457 //
michael@0 458
michael@0 459 //// ConstrainedEncoding.decode ////
michael@0 460
michael@0 461 add_test(function test_ConstrainedEncoding_decode() {
michael@0 462 wsp_decode_test(WSP.ConstrainedEncoding, [0x80], 0);
michael@0 463 wsp_decode_test(WSP.ConstrainedEncoding, [32, 0], " ");
michael@0 464
michael@0 465 run_next_test();
michael@0 466 });
michael@0 467
michael@0 468 //// ConstrainedEncoding.encode ////
michael@0 469
michael@0 470 add_test(function test_ConstrainedEncoding_encode() {
michael@0 471 wsp_encode_test(WSP.ConstrainedEncoding, 0, [0x80 | 0]);
michael@0 472 wsp_encode_test(WSP.ConstrainedEncoding, "A", [65, 0]);
michael@0 473
michael@0 474 run_next_test();
michael@0 475 });
michael@0 476
michael@0 477 //
michael@0 478 // Test target: ValueLength
michael@0 479 //
michael@0 480
michael@0 481 //// ValueLength.decode ////
michael@0 482
michael@0 483 add_test(function test_ValueLength_decode() {
michael@0 484 for (let i = 0; i < 256; i++) {
michael@0 485 if (i < 31) {
michael@0 486 wsp_decode_test(WSP.ValueLength, [i, 0x8F, 0x7F], i);
michael@0 487 } else if (i == 31) {
michael@0 488 wsp_decode_test(WSP.ValueLength, [i, 0x8F, 0x7F], 0x7FF);
michael@0 489 } else {
michael@0 490 wsp_decode_test(WSP.ValueLength, [i, 0x8F, 0x7F], null, "CodeError");
michael@0 491 }
michael@0 492 }
michael@0 493
michael@0 494 run_next_test();
michael@0 495 });
michael@0 496
michael@0 497 //// ValueLength.encode ////
michael@0 498
michael@0 499 add_test(function test_ValueLength_encode() {
michael@0 500 for (let i = 0; i < 256; i++) {
michael@0 501 if (i < 31) {
michael@0 502 wsp_encode_test(WSP.ValueLength, i, [i]);
michael@0 503 } else if (i < 128) {
michael@0 504 wsp_encode_test(WSP.ValueLength, i, [31, i]);
michael@0 505 } else {
michael@0 506 wsp_encode_test(WSP.ValueLength, i, [31, (0x80 | (i / 128)), i % 128]);
michael@0 507 }
michael@0 508 }
michael@0 509
michael@0 510 run_next_test();
michael@0 511 });
michael@0 512
michael@0 513 //
michael@0 514 // Test target: NoValue
michael@0 515 //
michael@0 516
michael@0 517 //// NoValue.decode ////
michael@0 518
michael@0 519 add_test(function test_NoValue_decode() {
michael@0 520 wsp_decode_test(WSP.NoValue, [0], null);
michael@0 521 for (let i = 1; i < 256; i++) {
michael@0 522 wsp_decode_test(WSP.NoValue, [i], null, "CodeError");
michael@0 523 }
michael@0 524
michael@0 525 run_next_test();
michael@0 526 });
michael@0 527
michael@0 528 //// NoValue.encode ////
michael@0 529
michael@0 530 add_test(function test_NoValue_encode() {
michael@0 531 wsp_encode_test(WSP.NoValue, undefined, [0]);
michael@0 532 wsp_encode_test(WSP.NoValue, null, [0]);
michael@0 533 wsp_encode_test(WSP.NoValue, 0, null, "CodeError");
michael@0 534 wsp_encode_test(WSP.NoValue, "", null, "CodeError");
michael@0 535 wsp_encode_test(WSP.NoValue, [], null, "CodeError");
michael@0 536 wsp_encode_test(WSP.NoValue, {}, null, "CodeError");
michael@0 537
michael@0 538 run_next_test();
michael@0 539 });
michael@0 540
michael@0 541 //
michael@0 542 // Test target: TextValue
michael@0 543 //
michael@0 544
michael@0 545 //// TextValue.decode ////
michael@0 546
michael@0 547 add_test(function test_TextValue_decode() {
michael@0 548 wsp_decode_test(WSP.TextValue, [0], null);
michael@0 549 wsp_decode_test(WSP.TextValue, [65, 0], "A");
michael@0 550 wsp_decode_test(WSP.TextValue, [32, 0], null, "CodeError");
michael@0 551 wsp_decode_test(WSP.TextValue, [34, 32, 0], " ");
michael@0 552
michael@0 553 run_next_test();
michael@0 554 });
michael@0 555
michael@0 556 //// TextValue.encode ////
michael@0 557
michael@0 558 add_test(function test_TextValue_encode() {
michael@0 559 wsp_encode_test(WSP.TextValue, undefined, [0]);
michael@0 560 wsp_encode_test(WSP.TextValue, null, [0]);
michael@0 561 wsp_encode_test(WSP.TextValue, "", [0]);
michael@0 562 wsp_encode_test(WSP.TextValue, "A", [65, 0]);
michael@0 563 wsp_encode_test(WSP.TextValue, "\x80", [34, 128, 0]);
michael@0 564
michael@0 565 run_next_test();
michael@0 566 });
michael@0 567
michael@0 568 //
michael@0 569 // Test target: IntegerValue
michael@0 570 //
michael@0 571
michael@0 572 //// IntegerValue.decode ////
michael@0 573
michael@0 574 add_test(function test_IntegerValue_decode() {
michael@0 575 for (let i = 128; i < 256; i++) {
michael@0 576 wsp_decode_test(WSP.IntegerValue, [i], i & 0x7F);
michael@0 577 }
michael@0 578
michael@0 579 LongInteger_decode_testcases(WSP.IntegerValue);
michael@0 580
michael@0 581 run_next_test();
michael@0 582 });
michael@0 583
michael@0 584 //// IntegerValue.decode ////
michael@0 585
michael@0 586 add_test(function test_IntegerValue_encode() {
michael@0 587 for (let i = 0; i < 128; i++) {
michael@0 588 wsp_encode_test(WSP.IntegerValue, i, [0x80 | i]);
michael@0 589 }
michael@0 590
michael@0 591 LongInteger_encode_testcases(WSP.IntegerValue);
michael@0 592
michael@0 593 run_next_test();
michael@0 594 });
michael@0 595
michael@0 596 //
michael@0 597 // Test target: DateValue
michael@0 598 //
michael@0 599
michael@0 600 //// DateValue.decode ////
michael@0 601
michael@0 602 add_test(function test_DateValue_decode() {
michael@0 603 wsp_decode_test(WSP.DateValue, [0, 0], null, "CodeError");
michael@0 604 wsp_decode_test(WSP.DateValue, [1, 0x80], new Date(0x80 * 1000));
michael@0 605 wsp_decode_test(WSP.DateValue, [31], null, "CodeError");
michael@0 606
michael@0 607 run_next_test();
michael@0 608 });
michael@0 609
michael@0 610 //// DateValue.encode ////
michael@0 611
michael@0 612 add_test(function test_DateValue_encode() {
michael@0 613 wsp_encode_test(WSP.DateValue, new Date(0x80 * 1000), [1, 0x80]);
michael@0 614
michael@0 615 run_next_test();
michael@0 616 });
michael@0 617
michael@0 618 //
michael@0 619 // Test target: DeltaSecondsValue
michael@0 620 //
michael@0 621 // DeltaSecondsValue is only an alias of IntegerValue.
michael@0 622
michael@0 623 //
michael@0 624 // Test target: QValue
michael@0 625 //
michael@0 626
michael@0 627 //// QValue.decode ////
michael@0 628
michael@0 629 add_test(function test_QValue_decode() {
michael@0 630 wsp_decode_test(WSP.QValue, [0], null, "CodeError");
michael@0 631 wsp_decode_test(WSP.QValue, [1], 0);
michael@0 632 wsp_decode_test(WSP.QValue, [100], 0.99);
michael@0 633 wsp_decode_test(WSP.QValue, [101], 0.001);
michael@0 634 wsp_decode_test(WSP.QValue, [0x88, 0x4B], 0.999);
michael@0 635 wsp_decode_test(WSP.QValue, [0x88, 0x4C], null, "CodeError");
michael@0 636
michael@0 637 run_next_test();
michael@0 638 });
michael@0 639
michael@0 640 //// QValue.encode ////
michael@0 641
michael@0 642 add_test(function test_QValue_encode() {
michael@0 643 wsp_encode_test(WSP.QValue, 0, [1]);
michael@0 644 wsp_encode_test(WSP.QValue, 0.99, [100]);
michael@0 645 wsp_encode_test(WSP.QValue, 0.001, [101]);
michael@0 646 wsp_encode_test(WSP.QValue, 0.999, [0x88, 0x4B]);
michael@0 647 wsp_encode_test(WSP.QValue, 1, null, "CodeError");
michael@0 648
michael@0 649 run_next_test();
michael@0 650 });
michael@0 651
michael@0 652 //
michael@0 653 // Test target: VersionValue
michael@0 654 //
michael@0 655
michael@0 656 //// VersionValue.decode ////
michael@0 657
michael@0 658 add_test(function test_VersionValue_decode() {
michael@0 659 for (let major = 1; major < 8; major++) {
michael@0 660 let version = (major << 4) | 0x0F;
michael@0 661 wsp_decode_test(WSP.VersionValue, [0x80 | version], version);
michael@0 662 wsp_decode_test(WSP.VersionValue, [major + 0x30, 0], version);
michael@0 663
michael@0 664 for (let minor = 0; minor < 15; minor++) {
michael@0 665 version = (major << 4) | minor;
michael@0 666 wsp_decode_test(WSP.VersionValue, [0x80 | version], version);
michael@0 667 if (minor >= 10) {
michael@0 668 wsp_decode_test(WSP.VersionValue, [major + 0x30, 0x2E, 0x31, (minor - 10) + 0x30, 0], version);
michael@0 669 } else {
michael@0 670 wsp_decode_test(WSP.VersionValue, [major + 0x30, 0x2E, minor + 0x30, 0], version);
michael@0 671 }
michael@0 672 }
michael@0 673 }
michael@0 674
michael@0 675 run_next_test();
michael@0 676 });
michael@0 677
michael@0 678 //// VersionValue.encode ////
michael@0 679
michael@0 680 add_test(function test_VersionValue_encode() {
michael@0 681 for (let major = 1; major < 8; major++) {
michael@0 682 let version = (major << 4) | 0x0F;
michael@0 683 wsp_encode_test(WSP.VersionValue, version, [0x80 | version]);
michael@0 684
michael@0 685 for (let minor = 0; minor < 15; minor++) {
michael@0 686 version = (major << 4) | minor;
michael@0 687 wsp_encode_test(WSP.VersionValue, version, [0x80 | version]);
michael@0 688 }
michael@0 689 }
michael@0 690
michael@0 691 run_next_test();
michael@0 692 });
michael@0 693
michael@0 694 //
michael@0 695 // Test target: UriValue
michael@0 696 //
michael@0 697
michael@0 698 //// UriValue.decode ////
michael@0 699
michael@0 700 add_test(function test_UriValue_decode() {
michael@0 701 wsp_decode_test(WSP.UriValue, [97], null, "RangeError");
michael@0 702 wsp_decode_test(WSP.UriValue, [0], "");
michael@0 703 wsp_decode_test(WSP.UriValue, [65, 0], "A");
michael@0 704
michael@0 705 run_next_test();
michael@0 706 });
michael@0 707
michael@0 708 //
michael@0 709 // Test target: TypeValue
michael@0 710 //
michael@0 711
michael@0 712 //// TypeValue.decode ////
michael@0 713
michael@0 714 add_test(function test_TypeValue_decode() {
michael@0 715 // Test for string-typed return value from ConstrainedEncoding
michael@0 716 wsp_decode_test(WSP.TypeValue, [65, 0], "a");
michael@0 717 // Test for number-typed return value from ConstrainedEncoding
michael@0 718 wsp_decode_test(WSP.TypeValue, [0x33 | 0x80],
michael@0 719 "application/vnd.wap.multipart.related");
michael@0 720 wsp_decode_test(WSP.TypeValue, [0x1d | 0x80], "image/gif");
michael@0 721 // Test for NotWellKnownEncodingError
michael@0 722 wsp_decode_test(WSP.TypeValue, [0x59 | 0x80], null, "NotWellKnownEncodingError");
michael@0 723
michael@0 724 run_next_test();
michael@0 725 });
michael@0 726
michael@0 727 //// TypeValue.encode ////
michael@0 728
michael@0 729 add_test(function test_TypeValue_encode() {
michael@0 730 wsp_encode_test(WSP.TypeValue, "no/such.type",
michael@0 731 [110, 111, 47, 115, 117, 99, 104, 46, 116, 121, 112, 101, 0]);
michael@0 732 wsp_encode_test(WSP.TypeValue, "application/vnd.wap.multipart.related",
michael@0 733 [0x33 | 0x80]);
michael@0 734 wsp_encode_test(WSP.TypeValue, "image/gif",
michael@0 735 [0x1d | 0x80]);
michael@0 736
michael@0 737 run_next_test();
michael@0 738 });
michael@0 739
michael@0 740 //
michael@0 741 // Test target: Parameter
michael@0 742 //
michael@0 743
michael@0 744 //// Parameter.decodeTypedParameter ////
michael@0 745
michael@0 746 add_test(function test_Parameter_decodeTypedParameter() {
michael@0 747 function func(data) {
michael@0 748 return WSP.Parameter.decodeTypedParameter(data);
michael@0 749 }
michael@0 750
michael@0 751 // Test for array-typed return value from IntegerValue
michael@0 752 wsp_decode_test_ex(func, [7, 0, 0, 0, 0, 0, 0, 0], null, "CodeError");
michael@0 753 // Test for number-typed return value from IntegerValue
michael@0 754 wsp_decode_test_ex(func, [1, 0, 0], {name: "q", value: null});
michael@0 755 // Test for NotWellKnownEncodingError
michael@0 756 wsp_decode_test_ex(func, [1, 0xFF], null, "NotWellKnownEncodingError");
michael@0 757 // Test for parameter specific decoder
michael@0 758 wsp_decode_test_ex(func, [1, 0, 100], {name: "q", value: 0.99});
michael@0 759 // Test for TextValue
michael@0 760 wsp_decode_test_ex(func, [1, 0x10, 48, 46, 57, 57, 0],
michael@0 761 {name: "secure", value: "0.99"});
michael@0 762 // Test for TextString
michael@0 763 wsp_decode_test_ex(func, [1, 0x0A, 60, 115, 109, 105, 108, 62, 0],
michael@0 764 {name: "start", value: "<smil>"});
michael@0 765 // Test for skipValue
michael@0 766 wsp_decode_test_ex(func, [1, 0x0A, 128], null);
michael@0 767
michael@0 768 run_next_test();
michael@0 769 });
michael@0 770
michael@0 771 //// Parameter.decodeUntypedParameter ////
michael@0 772
michael@0 773 add_test(function test_Parameter_decodeUntypedParameter() {
michael@0 774 function func (data) {
michael@0 775 return WSP.Parameter.decodeUntypedParameter(data);
michael@0 776 }
michael@0 777
michael@0 778 wsp_decode_test_ex(func, [1], null, "CodeError");
michael@0 779 wsp_decode_test_ex(func, [65, 0, 0], {name: "a", value: null});
michael@0 780 // Test for IntegerValue
michael@0 781 wsp_decode_test_ex(func, [65, 0, 1, 0], {name: "a", value: 0});
michael@0 782 // Test for TextValue
michael@0 783 wsp_decode_test_ex(func, [65, 0, 66, 0], {name: "a", value: "B"});
michael@0 784
michael@0 785 run_next_test();
michael@0 786 });
michael@0 787
michael@0 788 //// Parameter.decode ////
michael@0 789
michael@0 790 add_test(function test_Parameter_decode() {
michael@0 791 wsp_decode_test(WSP.Parameter, [1, 0x0A, 60, 115, 109, 105, 108, 62, 0],
michael@0 792 {name: "start", value: "<smil>"});
michael@0 793 wsp_decode_test(WSP.Parameter, [65, 0, 66, 0], {name: "a", value: "B"});
michael@0 794
michael@0 795 run_next_test();
michael@0 796 });
michael@0 797
michael@0 798 //// Parameter.decodeMultiple ////
michael@0 799
michael@0 800 add_test(function test_Parameter_decodeMultiple() {
michael@0 801 wsp_decode_test_ex(function(data) {
michael@0 802 return WSP.Parameter.decodeMultiple(data, 13);
michael@0 803 }, [1, 0x0A, 60, 115, 109, 105, 108, 62, 0, 65, 0, 66, 0], {start: "<smil>", a: "B"}
michael@0 804 );
michael@0 805
michael@0 806 run_next_test();
michael@0 807 });
michael@0 808
michael@0 809 //// Parameter.encodeTypedParameter ////
michael@0 810
michael@0 811 add_test(function test_Parameter_encodeTypedParameter() {
michael@0 812 function func(data, input) {
michael@0 813 WSP.Parameter.encodeTypedParameter(data, input);
michael@0 814 return data.array;
michael@0 815 }
michael@0 816
michael@0 817 // Test for NotWellKnownEncodingError
michael@0 818 wsp_encode_test_ex(func, {name: "xxx", value: 0}, null, "NotWellKnownEncodingError");
michael@0 819 wsp_encode_test_ex(func, {name: "q", value: 0}, [0x80, 1]);
michael@0 820 wsp_encode_test_ex(func, {name: "name", value: "A"}, [0x85, 65, 0]);
michael@0 821
michael@0 822 run_next_test();
michael@0 823 });
michael@0 824
michael@0 825 //// Parameter.encodeUntypedParameter ////
michael@0 826
michael@0 827 add_test(function test_Parameter_encodeUntypedParameter() {
michael@0 828 function func(data, input) {
michael@0 829 WSP.Parameter.encodeUntypedParameter(data, input);
michael@0 830 return data.array;
michael@0 831 }
michael@0 832
michael@0 833 wsp_encode_test_ex(func, {name: "q", value: 0}, [113, 0, 0x80]);
michael@0 834 wsp_encode_test_ex(func, {name: "name", value: "A"}, [110, 97, 109, 101, 0, 65, 0]);
michael@0 835
michael@0 836 run_next_test();
michael@0 837 });
michael@0 838
michael@0 839 //// Parameter.encodeMultiple ////
michael@0 840
michael@0 841 add_test(function test_Parameter_encodeMultiple() {
michael@0 842 function func(data, input) {
michael@0 843 WSP.Parameter.encodeMultiple(data, input);
michael@0 844 return data.array;
michael@0 845 }
michael@0 846
michael@0 847 wsp_encode_test_ex(func, {q: 0, n: "A"}, [0x80, 1, 110, 0, 65, 0]);
michael@0 848
michael@0 849 run_next_test();
michael@0 850 });
michael@0 851
michael@0 852 //// Parameter.encode ////
michael@0 853
michael@0 854 add_test(function test_Parameter_encode() {
michael@0 855
michael@0 856 wsp_encode_test(WSP.Parameter, {name: "q", value: 0}, [0x80, 1]);
michael@0 857 wsp_encode_test(WSP.Parameter, {name: "n", value: "A"}, [110, 0, 65, 0]);
michael@0 858
michael@0 859 run_next_test();
michael@0 860 });
michael@0 861
michael@0 862 //
michael@0 863 // Test target: Header
michael@0 864 //
michael@0 865
michael@0 866 //// Header.decode ////
michael@0 867
michael@0 868 add_test(function test_Header_decode() {
michael@0 869 wsp_decode_test(WSP.Header, [0x34 | 0x80, 0x80], {name: "push-flag", value: 0});
michael@0 870 wsp_decode_test(WSP.Header, [65, 0, 66, 0], {name: "a", value: "B"});
michael@0 871
michael@0 872 run_next_test();
michael@0 873 });
michael@0 874
michael@0 875 //
michael@0 876 // Test target: WellKnownHeader
michael@0 877 //
michael@0 878
michael@0 879 //// WellKnownHeader.decode ////
michael@0 880
michael@0 881 add_test(function test_WellKnownHeader_decode() {
michael@0 882 wsp_decode_test(WSP.WellKnownHeader, [0xFF], null, "NotWellKnownEncodingError");
michael@0 883 let (entry = WSP.WSP_HEADER_FIELDS["push-flag"]) {
michael@0 884 // Test for Short-Integer
michael@0 885 wsp_decode_test(WSP.WellKnownHeader, [entry.number | 0x80, 0x80],
michael@0 886 {name: entry.name, value: 0});
michael@0 887 // Test for NoValue
michael@0 888 wsp_decode_test(WSP.WellKnownHeader, [entry.number | 0x80, 0],
michael@0 889 {name: entry.name, value: null});
michael@0 890 // Test for TokenText
michael@0 891 wsp_decode_test(WSP.WellKnownHeader, [entry.number | 0x80, 65, 0],
michael@0 892 {name: entry.name, value: "A"});
michael@0 893 // Test for QuotedString
michael@0 894 wsp_decode_test(WSP.WellKnownHeader, [entry.number | 0x80, 34, 128, 0],
michael@0 895 {name: entry.name, value: String.fromCharCode(128)});
michael@0 896 // Test for skipValue
michael@0 897 wsp_decode_test(WSP.WellKnownHeader, [entry.number | 0x80, 2, 0, 0], null);
michael@0 898 }
michael@0 899
michael@0 900 run_next_test();
michael@0 901 });
michael@0 902
michael@0 903 //
michael@0 904 // Test target: ApplicationHeader
michael@0 905 //
michael@0 906
michael@0 907 //// ApplicationHeader.decode ////
michael@0 908
michael@0 909 add_test(function test_ApplicationHeader_decode() {
michael@0 910 wsp_decode_test(WSP.ApplicationHeader, [5, 0, 66, 0], null, "CodeError");
michael@0 911 wsp_decode_test(WSP.ApplicationHeader, [65, 0, 66, 0], {name: "a", value: "B"});
michael@0 912 // Test for skipValue
michael@0 913 wsp_decode_test(WSP.ApplicationHeader, [65, 0, 2, 0, 0], null);
michael@0 914
michael@0 915 run_next_test();
michael@0 916 });
michael@0 917
michael@0 918 //// ApplicationHeader.encode ////
michael@0 919
michael@0 920 add_test(function test_ApplicationHeader_encode() {
michael@0 921 // Test invalid header name string:
michael@0 922 wsp_encode_test(WSP.ApplicationHeader, {name: undefined, value: "asdf"}, null, "CodeError");
michael@0 923 wsp_encode_test(WSP.ApplicationHeader, {name: null, value: "asdf"}, null, "CodeError");
michael@0 924 wsp_encode_test(WSP.ApplicationHeader, {name: "", value: "asdf"}, null, "CodeError");
michael@0 925 wsp_encode_test(WSP.ApplicationHeader, {name: "a b", value: "asdf"}, null, "CodeError");
michael@0 926 // Test value string:
michael@0 927 wsp_encode_test(WSP.ApplicationHeader, {name: "asdf", value: undefined},
michael@0 928 strToCharCodeArray("asdf").concat([0]));
michael@0 929 wsp_encode_test(WSP.ApplicationHeader, {name: "asdf", value: null},
michael@0 930 strToCharCodeArray("asdf").concat([0]));
michael@0 931 wsp_encode_test(WSP.ApplicationHeader, {name: "asdf", value: ""},
michael@0 932 strToCharCodeArray("asdf").concat([0]));
michael@0 933 wsp_encode_test(WSP.ApplicationHeader, {name: "asdf", value: "fdsa"},
michael@0 934 strToCharCodeArray("asdf").concat(strToCharCodeArray("fdsa")));
michael@0 935
michael@0 936 run_next_test();
michael@0 937 });
michael@0 938
michael@0 939 //
michael@0 940 // Test target: FieldName
michael@0 941 //
michael@0 942
michael@0 943 //// FieldName.decode ////
michael@0 944
michael@0 945 add_test(function test_FieldName_decode() {
michael@0 946 wsp_decode_test(WSP.FieldName, [0], "");
michael@0 947 wsp_decode_test(WSP.FieldName, [65, 0], "a");
michael@0 948 wsp_decode_test(WSP.FieldName, [97, 0], "a");
michael@0 949 let (entry = WSP.WSP_HEADER_FIELDS["content-length"]) {
michael@0 950 wsp_decode_test(WSP.FieldName, [entry.number | 0x80], entry.name);
michael@0 951 }
michael@0 952 wsp_decode_test(WSP.FieldName, [0xFF], null, "NotWellKnownEncodingError");
michael@0 953
michael@0 954 run_next_test();
michael@0 955 });
michael@0 956
michael@0 957 //// FieldName.encode ////
michael@0 958
michael@0 959 add_test(function test_FieldName_encode() {
michael@0 960 wsp_encode_test(WSP.FieldName, "", [0]);
michael@0 961 wsp_encode_test(WSP.FieldName, "date", [0x92]);
michael@0 962
michael@0 963 run_next_test();
michael@0 964 });
michael@0 965
michael@0 966 //
michael@0 967 // Test target: AcceptCharsetValue
michael@0 968 //
michael@0 969
michael@0 970 //// AcceptCharsetValue.decode ////
michael@0 971
michael@0 972 add_test(function test_AcceptCharsetValue_decode() {
michael@0 973 wsp_decode_test(WSP.AcceptCharsetValue, [0xFF], null, "CodeError");
michael@0 974 // Test for Any-Charset
michael@0 975 wsp_decode_test(WSP.AcceptCharsetValue, [128], {charset: "*"});
michael@0 976 // Test for Constrained-Charset
michael@0 977 wsp_decode_test(WSP.AcceptCharsetValue, [65, 0], {charset: "A"});
michael@0 978 let (entry = WSP.WSP_WELL_KNOWN_CHARSETS["utf-8"]) {
michael@0 979 wsp_decode_test(WSP.AcceptCharsetValue, [entry.number | 0x80], {charset: entry.name});
michael@0 980 }
michael@0 981 // Test for Accept-Charset-General-Form
michael@0 982 wsp_decode_test(WSP.AcceptCharsetValue, [1, 128], {charset: "*"});
michael@0 983 let (entry = WSP.WSP_WELL_KNOWN_CHARSETS["utf-8"]) {
michael@0 984 wsp_decode_test(WSP.AcceptCharsetValue, [2, 1, entry.number], {charset: entry.name});
michael@0 985 wsp_decode_test(WSP.AcceptCharsetValue, [1, entry.number | 0x80], {charset: entry.name});
michael@0 986 }
michael@0 987 wsp_decode_test(WSP.AcceptCharsetValue, [3, 65, 0, 100], {charset: "A", q: 0.99});
michael@0 988
michael@0 989 run_next_test();
michael@0 990 });
michael@0 991
michael@0 992 //// AcceptCharsetValue.encodeAnyCharset ////
michael@0 993
michael@0 994 add_test(function test_AcceptCharsetValue_encodeAnyCharset() {
michael@0 995 function func(data, input) {
michael@0 996 WSP.AcceptCharsetValue.encodeAnyCharset(data, input);
michael@0 997 return data.array;
michael@0 998 }
michael@0 999
michael@0 1000 wsp_encode_test_ex(func, null, [0x80]);
michael@0 1001 wsp_encode_test_ex(func, undefined, [0x80]);
michael@0 1002 wsp_encode_test_ex(func, {}, [0x80]);
michael@0 1003 wsp_encode_test_ex(func, {charset: null}, [0x80]);
michael@0 1004 wsp_encode_test_ex(func, {charset: "*"}, [0x80]);
michael@0 1005 wsp_encode_test_ex(func, {charset: "en"}, null, "CodeError");
michael@0 1006
michael@0 1007 run_next_test();
michael@0 1008 });
michael@0 1009
michael@0 1010 //
michael@0 1011 // Test target: WellKnownCharset
michael@0 1012 //
michael@0 1013
michael@0 1014 //// WellKnownCharset.decode ////
michael@0 1015
michael@0 1016 add_test(function test_WellKnownCharset_decode() {
michael@0 1017 wsp_decode_test(WSP.WellKnownCharset, [0xFF], null, "NotWellKnownEncodingError");
michael@0 1018 // Test for Any-Charset
michael@0 1019 wsp_decode_test(WSP.WellKnownCharset, [128], {charset: "*"});
michael@0 1020 // Test for number-typed return value from IntegerValue
michael@0 1021 wsp_decode_test(WSP.WellKnownCharset, [1, 3], {charset: "us-ascii"});
michael@0 1022 wsp_decode_test(WSP.WellKnownCharset, [1, 4], {charset: "iso-8859-1"});
michael@0 1023 wsp_decode_test(WSP.WellKnownCharset, [1, 5], {charset: "iso-8859-2"});
michael@0 1024 wsp_decode_test(WSP.WellKnownCharset, [1, 6], {charset: "iso-8859-3"});
michael@0 1025 wsp_decode_test(WSP.WellKnownCharset, [1, 7], {charset: "iso-8859-4"});
michael@0 1026 wsp_decode_test(WSP.WellKnownCharset, [1, 8], {charset: "iso-8859-5"});
michael@0 1027 wsp_decode_test(WSP.WellKnownCharset, [1, 9], {charset: "iso-8859-6"});
michael@0 1028 wsp_decode_test(WSP.WellKnownCharset, [1, 10], {charset: "iso-8859-7"});
michael@0 1029 wsp_decode_test(WSP.WellKnownCharset, [1, 11], {charset: "iso-8859-8"});
michael@0 1030 wsp_decode_test(WSP.WellKnownCharset, [1, 12], {charset: "iso-8859-9"});
michael@0 1031 wsp_decode_test(WSP.WellKnownCharset, [1, 13], {charset: "iso-8859-10"});
michael@0 1032 wsp_decode_test(WSP.WellKnownCharset, [1, 17], {charset: "shift_jis"});
michael@0 1033 wsp_decode_test(WSP.WellKnownCharset, [1, 18], {charset: "euc-jp"});
michael@0 1034 wsp_decode_test(WSP.WellKnownCharset, [1, 37], {charset: "iso-2022-kr"});
michael@0 1035 wsp_decode_test(WSP.WellKnownCharset, [1, 38], {charset: "euc-kr"});
michael@0 1036 wsp_decode_test(WSP.WellKnownCharset, [1, 39], {charset: "iso-2022-jp"});
michael@0 1037 wsp_decode_test(WSP.WellKnownCharset, [1, 40], {charset: "iso-2022-jp-2"});
michael@0 1038 wsp_decode_test(WSP.WellKnownCharset, [1, 81], {charset: "iso-8859-6-e"});
michael@0 1039 wsp_decode_test(WSP.WellKnownCharset, [1, 82], {charset: "iso-8859-6-i"});
michael@0 1040 wsp_decode_test(WSP.WellKnownCharset, [1, 84], {charset: "iso-8859-8-e"});
michael@0 1041 wsp_decode_test(WSP.WellKnownCharset, [1, 85], {charset: "iso-8859-8-i"});
michael@0 1042 wsp_decode_test(WSP.WellKnownCharset, [1, 1000], {charset: "iso-10646-ucs-2"});
michael@0 1043 wsp_decode_test(WSP.WellKnownCharset, [1, 1015], {charset: "utf-16"});
michael@0 1044 wsp_decode_test(WSP.WellKnownCharset, [1, 2025], {charset: "gb2312"});
michael@0 1045 wsp_decode_test(WSP.WellKnownCharset, [1, 2026], {charset: "big5"});
michael@0 1046 wsp_decode_test(WSP.WellKnownCharset, [1, 2084], {charset: "koi8-r"});
michael@0 1047 wsp_decode_test(WSP.WellKnownCharset, [1, 2252], {charset: "windows-1252"});
michael@0 1048 wsp_decode_test(WSP.WellKnownCharset, [2, 3, 247], {charset: "utf-16"});
michael@0 1049 // Test for array-typed return value from IntegerValue
michael@0 1050 wsp_decode_test(WSP.WellKnownCharset, [7, 0, 0, 0, 0, 0, 0, 0, 3], null, "CodeError");
michael@0 1051
michael@0 1052 run_next_test();
michael@0 1053 });
michael@0 1054
michael@0 1055 //// WellKnownCharset.encode ////
michael@0 1056
michael@0 1057 add_test(function test_WellKnownCharset_encode() {
michael@0 1058 // Test for Any-charset
michael@0 1059 wsp_encode_test(WSP.WellKnownCharset, {charset: "*"}, [0x80]);
michael@0 1060 wsp_encode_test(WSP.WellKnownCharset, {charset: "us-ascii"}, [128 + 3]);
michael@0 1061 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-1"}, [128 + 4]);
michael@0 1062 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-2"}, [128 + 5]);
michael@0 1063 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-3"}, [128 + 6]);
michael@0 1064 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-4"}, [128 + 7]);
michael@0 1065 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-5"}, [128 + 8]);
michael@0 1066 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-6"}, [128 + 9]);
michael@0 1067 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-7"}, [128 + 10]);
michael@0 1068 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-8"}, [128 + 11]);
michael@0 1069 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-9"}, [128 + 12]);
michael@0 1070 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-10"}, [128 + 13]);
michael@0 1071 wsp_encode_test(WSP.WellKnownCharset, {charset: "shift_jis"}, [128 + 17]);
michael@0 1072 wsp_encode_test(WSP.WellKnownCharset, {charset: "euc-jp"}, [128 + 18]);
michael@0 1073 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-2022-kr"}, [128 + 37]);
michael@0 1074 wsp_encode_test(WSP.WellKnownCharset, {charset: "euc-kr"}, [128 + 38]);
michael@0 1075 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-2022-jp"}, [128 + 39]);
michael@0 1076 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-2022-jp-2"}, [128 + 40]);
michael@0 1077 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-6-e"}, [128 + 81]);
michael@0 1078 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-6-i"}, [128 + 82]);
michael@0 1079 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-8-e"}, [128 + 84]);
michael@0 1080 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-8859-8-i"}, [128 + 85]);
michael@0 1081 wsp_encode_test(WSP.WellKnownCharset, {charset: "UTF-8"}, [128 + 106]);
michael@0 1082 wsp_encode_test(WSP.WellKnownCharset, {charset: "iso-10646-ucs-2"}, [2, 0x3, 0xe8]);
michael@0 1083 wsp_encode_test(WSP.WellKnownCharset, {charset: "UTF-16"}, [2, 0x3, 0xf7]);
michael@0 1084 wsp_encode_test(WSP.WellKnownCharset, {charset: "gb2312"}, [2, 0x7, 0xe9]);
michael@0 1085 wsp_encode_test(WSP.WellKnownCharset, {charset: "big5"}, [2, 0x7, 0xea]);
michael@0 1086 wsp_encode_test(WSP.WellKnownCharset, {charset: "koi8-r"}, [2, 0x8, 0x24]);
michael@0 1087 wsp_encode_test(WSP.WellKnownCharset, {charset: "windows-1252"}, [2, 0x8, 0xcc]);
michael@0 1088
michael@0 1089 run_next_test();
michael@0 1090 });
michael@0 1091
michael@0 1092 //
michael@0 1093 // Test target: ContentTypeValue
michael@0 1094 //
michael@0 1095
michael@0 1096 //// ContentTypeValue.decodeConstrainedMedia ////
michael@0 1097
michael@0 1098 add_test(function test_ContentTypeValue_decodeConstrainedMedia() {
michael@0 1099 function func(data) {
michael@0 1100 return WSP.ContentTypeValue.decodeConstrainedMedia(data);
michael@0 1101 }
michael@0 1102
michael@0 1103 // Test for string-typed return value from ConstrainedEncoding
michael@0 1104 wsp_decode_test_ex(func, [65, 0], {media: "a", params: null});
michael@0 1105 // Test for number-typed return value from ConstrainedEncoding
michael@0 1106 for(let ix = 0; ix <WSP.WSP_WELL_KNOWN_CONTENT_TYPES.length ; ++ix){
michael@0 1107 wsp_decode_test_ex(func, [WSP.WSP_WELL_KNOWN_CONTENT_TYPES[ix].number | 0x80],
michael@0 1108 {media: WSP.WSP_WELL_KNOWN_CONTENT_TYPES[ix].value, params: null});
michael@0 1109 }
michael@0 1110 // Test for NotWellKnownEncodingError
michael@0 1111 wsp_decode_test_ex(func, [0x59 | 0x80], null, "NotWellKnownEncodingError");
michael@0 1112
michael@0 1113 run_next_test();
michael@0 1114 });
michael@0 1115
michael@0 1116 //// ContentTypeValue.decodeMedia ////
michael@0 1117
michael@0 1118 add_test(function test_ContentTypeValue_decodeMedia() {
michael@0 1119 function func(data) {
michael@0 1120 return WSP.ContentTypeValue.decodeMedia(data);
michael@0 1121 }
michael@0 1122
michael@0 1123 // Test for NullTerminatedTexts
michael@0 1124 wsp_decode_test_ex(func, [65, 0], "a");
michael@0 1125 // Test for IntegerValue
michael@0 1126 wsp_decode_test_ex(func, [0x3E | 0x80], "application/vnd.wap.mms-message");
michael@0 1127 wsp_decode_test_ex(func, [0x59 | 0x80], null, "NotWellKnownEncodingError");
michael@0 1128
michael@0 1129 run_next_test();
michael@0 1130 });
michael@0 1131
michael@0 1132 //// ContentTypeValue.decodeMediaType ////
michael@0 1133
michael@0 1134 add_test(function test_ContentTypeValue_decodeMediaType() {
michael@0 1135 wsp_decode_test_ex(function(data) {
michael@0 1136 return WSP.ContentTypeValue.decodeMediaType(data, 1);
michael@0 1137 }, [0x3E | 0x80],
michael@0 1138 {media: "application/vnd.wap.mms-message", params: null}
michael@0 1139 );
michael@0 1140 wsp_decode_test_ex(function(data) {
michael@0 1141 return WSP.ContentTypeValue.decodeMediaType(data, 14);
michael@0 1142 }, [0x3E | 0x80, 1, 0x0A, 60, 115, 109, 105, 108, 62, 0, 65, 0, 66, 0],
michael@0 1143 {media: "application/vnd.wap.mms-message", params: {start: "<smil>", a: "B"}}
michael@0 1144 );
michael@0 1145
michael@0 1146 run_next_test();
michael@0 1147 });
michael@0 1148
michael@0 1149 //// ContentTypeValue.decodeContentGeneralForm ////
michael@0 1150
michael@0 1151 add_test(function test_ContentTypeValue_decodeContentGeneralForm() {
michael@0 1152 wsp_decode_test_ex(function(data) {
michael@0 1153 return WSP.ContentTypeValue.decodeContentGeneralForm(data);
michael@0 1154 }, [14, 0x3E | 0x80, 1, 0x0A, 60, 115, 109, 105, 108, 62, 0, 65, 0, 66, 0],
michael@0 1155 {media: "application/vnd.wap.mms-message", params: {start: "<smil>", a: "B"}}
michael@0 1156 );
michael@0 1157
michael@0 1158 run_next_test();
michael@0 1159 });
michael@0 1160
michael@0 1161 //// ContentTypeValue.decode ////
michael@0 1162
michael@0 1163 add_test(function test_ContentTypeValue_decode() {
michael@0 1164 wsp_decode_test(WSP.ContentTypeValue,
michael@0 1165 [14, 0x3E | 0x80, 1, 0x0A, 60, 115, 109, 105, 108, 62, 0, 65, 0, 66, 0],
michael@0 1166 {media: "application/vnd.wap.mms-message", params: {start: "<smil>", a: "B"}}
michael@0 1167 );
michael@0 1168
michael@0 1169 wsp_decode_test(WSP.ContentTypeValue, [0x33 | 0x80],
michael@0 1170 {media: "application/vnd.wap.multipart.related", params: null}
michael@0 1171 );
michael@0 1172
michael@0 1173 run_next_test();
michael@0 1174 });
michael@0 1175
michael@0 1176 //// ContentTypeValue.encodeConstrainedMedia ////
michael@0 1177
michael@0 1178 add_test(function test_ContentTypeValue_encodeConstrainedMedia() {
michael@0 1179 function func(data, input) {
michael@0 1180 WSP.ContentTypeValue.encodeConstrainedMedia(data, input);
michael@0 1181 return data.array;
michael@0 1182 }
michael@0 1183
michael@0 1184 // Test media type with additional parameters.
michael@0 1185 wsp_encode_test_ex(func, {media: "a", params: [{a: "b"}]}, null, "CodeError");
michael@0 1186 wsp_encode_test_ex(func, {media: "no/such.type"},
michael@0 1187 [110, 111, 47, 115, 117, 99, 104, 46, 116, 121, 112, 101, 0]);
michael@0 1188 for(let ix = 0; ix <WSP.WSP_WELL_KNOWN_CONTENT_TYPES.length ; ++ix){
michael@0 1189 wsp_encode_test_ex(func, {media: WSP.WSP_WELL_KNOWN_CONTENT_TYPES[ix].value},
michael@0 1190 [WSP.WSP_WELL_KNOWN_CONTENT_TYPES[ix].number | 0x80]);
michael@0 1191 }
michael@0 1192 wsp_encode_test_ex(func, {media: "TexT/X-hdml"}, [0x04 | 0x80]);
michael@0 1193 wsp_encode_test_ex(func, {media: "appLication/*"}, [0x10 | 0x80]);
michael@0 1194
michael@0 1195 run_next_test();
michael@0 1196 });
michael@0 1197
michael@0 1198 //// ContentTypeValue.encodeMediaType ////
michael@0 1199
michael@0 1200 add_test(function test_ContentTypeValue_encodeMediaType() {
michael@0 1201 function func(data, input) {
michael@0 1202 WSP.ContentTypeValue.encodeMediaType(data, input);
michael@0 1203 return data.array;
michael@0 1204 }
michael@0 1205
michael@0 1206 wsp_encode_test_ex(func, {media: "no/such.type"},
michael@0 1207 [110, 111, 47, 115, 117, 99, 104, 46, 116, 121, 112, 101, 0]);
michael@0 1208 wsp_encode_test_ex(func, {media: "application/vnd.wap.multipart.related"},
michael@0 1209 [0x33 | 0x80]);
michael@0 1210 wsp_encode_test_ex(func, {media: "a", params: {b: "c", q: 0}},
michael@0 1211 [97, 0, 98, 0, 99, 0, 128, 1]);
michael@0 1212
michael@0 1213 run_next_test();
michael@0 1214 });
michael@0 1215
michael@0 1216 //// ContentTypeValue.encodeContentGeneralForm ////
michael@0 1217
michael@0 1218 add_test(function test_ContentTypeValue_encodeContentGeneralForm() {
michael@0 1219 function func(data, input) {
michael@0 1220 WSP.ContentTypeValue.encodeContentGeneralForm(data, input);
michael@0 1221 return data.array;
michael@0 1222 }
michael@0 1223
michael@0 1224 wsp_encode_test_ex(func, {media: "a", params: {b: "c", q: 0}},
michael@0 1225 [8, 97, 0, 98, 0, 99, 0, 128, 1]);
michael@0 1226
michael@0 1227 run_next_test();
michael@0 1228 });
michael@0 1229
michael@0 1230 //// ContentTypeValue.encode ////
michael@0 1231
michael@0 1232 add_test(function test_ContentTypeValue_encode() {
michael@0 1233 wsp_encode_test(WSP.ContentTypeValue, {media: "no/such.type"},
michael@0 1234 [110, 111, 47, 115, 117, 99, 104, 46, 116, 121, 112, 101, 0]);
michael@0 1235 wsp_encode_test(WSP.ContentTypeValue,
michael@0 1236 {media: "application/vnd.wap.multipart.related"},
michael@0 1237 [0x33 | 0x80]);
michael@0 1238 wsp_encode_test(WSP.ContentTypeValue, {media: "a", params: {b: "c", q: 0}},
michael@0 1239 [8, 97, 0, 98, 0, 99, 0, 128, 1]);
michael@0 1240
michael@0 1241 run_next_test();
michael@0 1242 });
michael@0 1243
michael@0 1244 //
michael@0 1245 // Test target: ApplicationIdValue
michael@0 1246 //
michael@0 1247
michael@0 1248 //// ApplicationIdValue.decode ////
michael@0 1249
michael@0 1250 add_test(function test_ApplicationIdValue_decode() {
michael@0 1251 wsp_decode_test(WSP.ApplicationIdValue, [0], "");
michael@0 1252 wsp_decode_test(WSP.ApplicationIdValue, [65, 0], "A");
michael@0 1253 wsp_decode_test(WSP.ApplicationIdValue, [97, 0], "a");
michael@0 1254 let (entry = WSP.OMNA_PUSH_APPLICATION_IDS["x-wap-application:mms.ua"]) {
michael@0 1255 wsp_decode_test(WSP.ApplicationIdValue, [entry.number | 0x80], entry.urn);
michael@0 1256 wsp_decode_test(WSP.ApplicationIdValue, [1, entry.number], entry.urn);
michael@0 1257 }
michael@0 1258 wsp_decode_test(WSP.ApplicationIdValue, [0xFF], null, "NotWellKnownEncodingError");
michael@0 1259
michael@0 1260 run_next_test();
michael@0 1261 });
michael@0 1262
michael@0 1263 //
michael@0 1264 // Test target: PduHelper
michael@0 1265 //
michael@0 1266
michael@0 1267 //// PduHelper.parseHeaders ////
michael@0 1268
michael@0 1269 add_test(function test_PduHelper_parseHeaders() {
michael@0 1270 wsp_decode_test_ex(function(data) {
michael@0 1271 return WSP.PduHelper.parseHeaders(data, data.array.length);
michael@0 1272 }, [0x80 | 0x05, 2, 0x23, 0x28, 0x80 | 0x2F, 0x80 | 0x04],
michael@0 1273 {"age": 9000, "x-wap-application-id": "x-wap-application:mms.ua"}
michael@0 1274 );
michael@0 1275
michael@0 1276 run_next_test();
michael@0 1277 });
michael@0 1278
michael@0 1279 //// PduHelper.decodeStringContent ////
michael@0 1280
michael@0 1281 add_test(function StringContent_decode() {
michael@0 1282 //Test for utf-8
michael@0 1283 let (entry = WSP.WSP_WELL_KNOWN_CHARSETS["utf-8"]) {
michael@0 1284 // "Mozilla" in full width.
michael@0 1285 let str = "\uff2d\uff4f\uff5a\uff49\uff4c\uff4c\uff41";
michael@0 1286
michael@0 1287 let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
michael@0 1288 .createInstance(Ci.nsIScriptableUnicodeConverter);
michael@0 1289 conv.charset = entry.converter;
michael@0 1290
michael@0 1291 let raw = conv.convertToByteArray(str);
michael@0 1292 let data = {array: raw, offset: 0};
michael@0 1293 let octetArray = WSP.Octet.decodeMultiple(data, data.array.length);
michael@0 1294 wsp_decode_test_ex(function(data) {
michael@0 1295 return WSP.PduHelper.decodeStringContent(data.array, "utf-8");
michael@0 1296 }, octetArray, str);
michael@0 1297 }
michael@0 1298
michael@0 1299 let (entry = WSP.WSP_WELL_KNOWN_CHARSETS["utf-16"]) {
michael@0 1300 // "Mozilla" in full width.
michael@0 1301 let str = "\u004d\u006F\u007A\u0069\u006C\u006C\u0061";
michael@0 1302
michael@0 1303 let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
michael@0 1304 .createInstance(Ci.nsIScriptableUnicodeConverter);
michael@0 1305 conv.charset = entry.converter;
michael@0 1306
michael@0 1307 let raw = conv.convertToByteArray(str);
michael@0 1308 let data = {array: raw, offset: 0};
michael@0 1309 let octetArray = WSP.Octet.decodeMultiple(data, data.array.length);
michael@0 1310 wsp_decode_test_ex(function(data) {
michael@0 1311 return WSP.PduHelper.decodeStringContent(data.array, "utf-16");
michael@0 1312 }, raw, str);
michael@0 1313 }
michael@0 1314
michael@0 1315 run_next_test();
michael@0 1316 });
michael@0 1317
michael@0 1318 //// PduHelper.composeMultiPart ////
michael@0 1319
michael@0 1320 add_test(function test_PduHelper_composeMultiPart() {
michael@0 1321 let multiStream = Components.classes["@mozilla.org/io/multiplex-input-stream;1"]
michael@0 1322 .createInstance(Ci.nsIMultiplexInputStream);
michael@0 1323 let uint8Array = new Uint8Array(5);
michael@0 1324 uint8Array[0] = 0x00;
michael@0 1325 uint8Array[1] = 0x01;
michael@0 1326 uint8Array[2] = 0x02;
michael@0 1327 uint8Array[3] = 0x03;
michael@0 1328 uint8Array[4] = 0x04;
michael@0 1329
michael@0 1330 let parts = [
michael@0 1331 {
michael@0 1332 content: "content",
michael@0 1333 headers: {
michael@0 1334 "content-type": {
michael@0 1335 media: "text/plain",
michael@0 1336 params: {}
michael@0 1337 }
michael@0 1338 }
michael@0 1339 },
michael@0 1340 {
michael@0 1341 content: uint8Array,
michael@0 1342 headers: {
michael@0 1343 "content-type": {
michael@0 1344 media: "text/plain",
michael@0 1345 params: {}
michael@0 1346 }
michael@0 1347 }
michael@0 1348 }
michael@0 1349 ];
michael@0 1350
michael@0 1351 let beforeCompose = JSON.stringify(parts);
michael@0 1352 WSP.PduHelper.composeMultiPart(multiStream, parts);
michael@0 1353 let afterCompose = JSON.stringify(parts);
michael@0 1354
michael@0 1355 do_check_eq(beforeCompose, afterCompose);
michael@0 1356 run_next_test();
michael@0 1357 });

mercurial