michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 60000; michael@0: michael@0: const SELF = "5554"; michael@0: michael@0: SpecialPowers.setBoolPref("dom.sms.enabled", true); michael@0: SpecialPowers.addPermission("sms", true, document); michael@0: michael@0: function cleanUp() { michael@0: SpecialPowers.removePermission("sms", document); michael@0: SpecialPowers.clearUserPref("dom.sms.enabled"); michael@0: finish(); michael@0: } michael@0: michael@0: let manager = window.navigator.mozMobileMessage; michael@0: ok(manager instanceof MozMobileMessageManager, michael@0: "manager is instance of " + manager.constructor); michael@0: michael@0: function randomString16() { michael@0: return Math.random().toString(36).substr(2, 16); michael@0: } michael@0: michael@0: function times(str, n) { michael@0: return (new Array(n + 1)).join(str); michael@0: } michael@0: michael@0: function repeat(func, array, oncomplete) { michael@0: (function do_call(index) { michael@0: let next = index < (array.length - 1) ? do_call.bind(null, index + 1) : oncomplete; michael@0: func.apply(null, [array[index], next]); michael@0: })(0); michael@0: } michael@0: michael@0: function doTest(body, callback) { michael@0: manager.addEventListener("received", function onReceived(event) { michael@0: event.target.removeEventListener(event.type, arguments.callee); michael@0: michael@0: let message = event.message; michael@0: is(message.body, body, "message.body"); michael@0: michael@0: window.setTimeout(callback, 0); michael@0: }); michael@0: michael@0: let request = manager.send(SELF, body); michael@0: request.onerror = function onerror() { michael@0: ok(false, "failed to send message '" + body + "' to '" + SELF + "'"); michael@0: }; michael@0: } michael@0: michael@0: repeat(doTest, [ michael@0: // Random alphanumeric string of 16 characters. michael@0: randomString16(), michael@0: // Long long text message for multipart messages. michael@0: times(randomString16(), 100), michael@0: michael@0: // UCS2 string for the first sentence of "The Cooing", Classic of Poetry. michael@0: "\u95dc\u95dc\u96ce\u9ce9\uff0c\u5728\u6cb3\u4e4b\u6d32\u3002", michael@0: // Long long UCS2 text message for multipart messages. michael@0: times("\u95dc\u95dc\u96ce\u9ce9\uff0c\u5728\u6cb3\u4e4b\u6d32\u3002", 100), michael@0: michael@0: // Test case from Bug 809553 michael@0: "zertuuuppzuzyeueieieyeieoeiejeheejrueufjfjfjjfjfkxifjfjfufjjfjfufujdjduxxjdu" michael@0: + "djdjdjdudhdjdhdjdbddhbfjfjxbuwjdjdudjddjdhdhdvdyudusjdudhdjjfjdvdudbddjdbd" michael@0: + "usjfbjdfudjdhdjbzuuzyzehdjjdjwybwudjvwywuxjdbfudsbwuwbwjdjdbwywhdbddudbdjd" michael@0: + "uejdhdudbdduwjdbjddudjdjdjdudjdbdjdhdhdjjdjbxudjdbxufjudbdjhdjdisjsjzusbzh" michael@0: + "xbdudksksuqjgdjdb jeudi jeudis duhebevzcevevsvs DVD suscite eh du d des jv" michael@0: + " y b Dj. Du wh. Hu Deb wh. Du web h w show d DVD h w v. Th\u00e9 \u00e9c" michael@0: + "hec d whdvdj. Wh d'h\u00f4tel DVD. IMAX eusjw ii ce", michael@0: michael@0: // Android Emulator specific problems: michael@0: // 1) wrong default 7Bit alphabet character for "Ň"(U+0147). michael@0: "\u0147", michael@0: // 2) problem in decoding strings encoded with GSM 7Bit Alphabets and michael@0: // containing characters on extension tables. michael@0: "\u20ac****", michael@0: ], cleanUp);