dom/sms/tests/test_smsfilter.html
author Bas Schouten <bschouten@mozilla.com>
Fri, 21 Sep 2012 22:12:28 +0000
changeset 107768 259206b2c7b25d08ac11125c814de0ee43ea121a
parent 84690 48725e4f215ac788f704f6c64ecbc3be034d3efc
permissions -rw-r--r--
Bug 792190: Relax D3D9 driver version requirements. r=bjacob

<!DOCTYPE HTML>
<html>
<head>
  <title>Test SmsFilter</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
<iframe></iframe>
</div>
<pre id="test">
<script type="application/javascript">

/** Test SmsFilter **/

function throwingCheck(aFilter, aProperty, disallowedValue)
{
  disallowedValue.forEach(function(v) {
    var exception = false;
    try {
      aFilter[aProperty] = v;
    } catch (e) {
      exception = true;
    }
    ok(exception, "An exception should have been thrown");
  });
}

var filter = new MozSmsFilter();

isnot(filter, null, "filter should be set");

is(filter.startDate, null, "Parameters shouldn't be initialized");
is(filter.endDate, null, "Parameters shouldn't be initialized");
is(filter.numbers, null, "Parameters shouldn't be initialized");
is(filter.delivery, null, "Parameters shouldn't be initialized");

var date = new Date();
filter.startDate = date;
is(filter.startDate, "" + date, "Setters and getters should work!");
filter.startDate = null;
is(filter.startDate, null, "null should revert the value to default");
throwingCheck(filter, 'startDate', [ "foo", 42, [1, 2], function () {}, undefined ]);

filter.endDate = date;
is(filter.endDate, "" + date, "Setters and getters should work!");
filter.endDate = null;
is(filter.endDate, null, "null should revert the value to default");
throwingCheck(filter, 'endDate', [ "foo", 42, [1, 2], function () {}, undefined ]);

var numbers = [ "foo", "bar" ];
filter.numbers = numbers;
is(filter.numbers, "" + numbers, "Setters and getters should work!");
filter.numbers = null;
is(filter.numbers, null, "null should revert the value to default");
throwingCheck(filter, 'numbers', [ "foo", 42, function () {}, new Date(), undefined ]);

filter.delivery = "sent";
is(filter.delivery, "sent", "Setters and getters should work!");
filter.delivery = "received";
is(filter.delivery, "received", "Setters and getters should work!");
filter.delivery = "";
is(filter.delivery, null, "The empty string should revert the value to default.");
filter.delivery = null;
is(filter.delivery, null, "'null' should revert the value to default.");
throwingCheck(filter, 'delivery', [ "foo", 42, [1, 2], function () {}, new Date(), undefined ]);

</script>
</pre>
</body>
</html>