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: SpecialPowers.setBoolPref("dom.sms.enabled", true); michael@0: SpecialPowers.addPermission("sms", true, document); 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: // Note: 378 chars and below is fine, but 379 and above will cause the issue. michael@0: // Sending first message works, but second one we get emulator callback but michael@0: // the actual SMS is never received, so script will timeout waiting for the michael@0: // onreceived event. Also note that a single larger message (i.e. 1600 michael@0: // characters) works; so it is not a compounded send limit. michael@0: let fromNumber = "5551110000"; michael@0: let msgLength = 379; michael@0: let msgText = new Array(msgLength + 1).join('a'); michael@0: michael@0: let pendingEmulatorCmdCount = 0; michael@0: function sendSmsToEmulator(from, text) { michael@0: ++pendingEmulatorCmdCount; michael@0: michael@0: let cmd = "sms send " + from + " " + text; michael@0: runEmulatorCmd(cmd, function(result) { michael@0: --pendingEmulatorCmdCount; michael@0: michael@0: is(result[0], "OK", "Emulator response"); michael@0: }); michael@0: } michael@0: michael@0: function firstIncomingSms() { michael@0: simulateIncomingSms(secondIncomingSms); michael@0: } michael@0: michael@0: function secondIncomingSms() { michael@0: simulateIncomingSms(cleanUp); michael@0: } michael@0: michael@0: function simulateIncomingSms(nextFunction) { michael@0: log("Simulating incoming multipart SMS (" + msgText.length michael@0: + " chars total)."); michael@0: michael@0: manager.onreceived = function onreceived(event) { michael@0: log("Received 'onreceived' event."); michael@0: manager.onreceived = null; michael@0: michael@0: let incomingSms = event.message; michael@0: ok(incomingSms, "incoming sms"); michael@0: is(incomingSms.body, msgText, "msg body"); michael@0: michael@0: window.setTimeout(nextFunction, 0); michael@0: }; michael@0: michael@0: sendSmsToEmulator(fromNumber, msgText); michael@0: } michael@0: michael@0: function cleanUp() { michael@0: if (pendingEmulatorCmdCount) { michael@0: window.setTimeout(cleanUp, 100); michael@0: return; michael@0: } michael@0: michael@0: SpecialPowers.removePermission("sms", document); michael@0: SpecialPowers.clearUserPref("dom.sms.enabled"); michael@0: finish(); michael@0: } michael@0: michael@0: // Start the test michael@0: firstIncomingSms();