dom/mobilemessage/tests/marionette/test_smsc_address.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 MARIONETTE_TIMEOUT = 60000;
michael@0 5
michael@0 6 SpecialPowers.addPermission("sms", true, document);
michael@0 7
michael@0 8 // Expected SMSC addresses of emulator
michael@0 9 const SMSC = "\"+123456789\",145";
michael@0 10
michael@0 11 let manager = window.navigator.mozMobileMessage;
michael@0 12
michael@0 13 let tasks = {
michael@0 14 // List of test fuctions. Each of them should call |tasks.next()| when
michael@0 15 // completed or |tasks.finish()| to jump to the last one.
michael@0 16 _tasks: [],
michael@0 17 _nextTaskIndex: 0,
michael@0 18
michael@0 19 push: function(func) {
michael@0 20 this._tasks.push(func);
michael@0 21 },
michael@0 22
michael@0 23 next: function() {
michael@0 24 let index = this._nextTaskIndex++;
michael@0 25 let task = this._tasks[index];
michael@0 26 try {
michael@0 27 task();
michael@0 28 } catch (ex) {
michael@0 29 ok(false, "test task[" + index + "] throws: " + ex);
michael@0 30 // Run last task as clean up if possible.
michael@0 31 if (index != this._tasks.length - 1) {
michael@0 32 this.finish();
michael@0 33 }
michael@0 34 }
michael@0 35 },
michael@0 36
michael@0 37 finish: function() {
michael@0 38 this._tasks[this._tasks.length - 1]();
michael@0 39 },
michael@0 40
michael@0 41 run: function() {
michael@0 42 this.next();
michael@0 43 }
michael@0 44 };
michael@0 45
michael@0 46 tasks.push(function init() {
michael@0 47 log("Initialize test object.");
michael@0 48 ok(manager instanceof MozMobileMessageManager,
michael@0 49 "manager is instance of " + manager.constructor);
michael@0 50 tasks.next();
michael@0 51 });
michael@0 52
michael@0 53 tasks.push(function readSmscAddress() {
michael@0 54 log("read SMSC address");
michael@0 55
michael@0 56 let req = manager.getSmscAddress();
michael@0 57 ok(req, "DOMRequest object for getting smsc address");
michael@0 58
michael@0 59 req.onsuccess = function(e) {
michael@0 60 is(e.target.result, SMSC, "SMSC address");
michael@0 61 tasks.next();
michael@0 62 };
michael@0 63
michael@0 64 req.onerror = function(error) {
michael@0 65 ok(false, "readSmscAddress(): Received 'onerror'");
michael@0 66 tasks.finish();
michael@0 67 };
michael@0 68 });
michael@0 69
michael@0 70 // WARNING: All tasks should be pushed before this!!!
michael@0 71 tasks.push(function cleanUp() {
michael@0 72 manager.onreceived = null;
michael@0 73 SpecialPowers.removePermission("sms", document);
michael@0 74 finish();
michael@0 75 });
michael@0 76
michael@0 77 // Start the test
michael@0 78 tasks.run();

mercurial