diff --git a/dom/mobilemessage/tests/marionette/manifest.ini b/dom/mobilemessage/tests/marionette/manifest.ini index d6e0b5bc5d90..b61c693de1aa 100644 --- a/dom/mobilemessage/tests/marionette/manifest.ini +++ b/dom/mobilemessage/tests/marionette/manifest.ini @@ -36,4 +36,5 @@ qemu = true [test_invalid_address.js] [test_mmsmessage_attachments.js] [test_getthreads.js] +[test_smsc_address.js] [test_dsds_default_service_id.js] diff --git a/dom/mobilemessage/tests/marionette/test_smsc_address.js b/dom/mobilemessage/tests/marionette/test_smsc_address.js new file mode 100644 index 000000000000..0fe6e3acb558 --- /dev/null +++ b/dom/mobilemessage/tests/marionette/test_smsc_address.js @@ -0,0 +1,78 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 60000; + +SpecialPowers.addPermission("sms", true, document); + +// Expected SMSC addresses of emulator +const SMSC = "\"+123456789\",145"; + +let manager = window.navigator.mozMobileMessage; + +let tasks = { + // List of test fuctions. Each of them should call |tasks.next()| when + // completed or |tasks.finish()| to jump to the last one. + _tasks: [], + _nextTaskIndex: 0, + + push: function push(func) { + this._tasks.push(func); + }, + + next: function next() { + let index = this._nextTaskIndex++; + let task = this._tasks[index]; + try { + task(); + } catch (ex) { + ok(false, "test task[" + index + "] throws: " + ex); + // Run last task as clean up if possible. + if (index != this._tasks.length - 1) { + this.finish(); + } + } + }, + + finish: function finish() { + this._tasks[this._tasks.length - 1](); + }, + + run: function run() { + this.next(); + } +}; + +tasks.push(function init() { + log("Initialize test object."); + ok(manager instanceof MozMobileMessageManager, + "manager is instance of " + manager.constructor); + tasks.next(); +}); + +tasks.push(function readSmscAddress() { + log("read SMSC address"); + + let req = manager.getSmscAddress(); + ok(req, "DOMRequest object for getting smsc address"); + + req.onsuccess = function(e) { + is(e.target.result, SMSC, "SMSC address"); + tasks.next(); + }; + + req.onerror = function(error) { + ok(false, "readSmscAddress(): Received 'onerror'"); + tasks.finish(); + }; +}); + +// WARNING: All tasks should be pushed before this!!! +tasks.push(function cleanUp() { + manager.onreceived = null; + SpecialPowers.removePermission("sms", document); + finish(); +}); + +// Start the test +tasks.run();