2 <!-- Submitted from TestTWF Paris -->
6 <title id='desc'>IDBKeyRange Tests - Incorrect</title>
7 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#range-concept">
8 <link rel=assert title="If the lower key is greater than the upper key, then a DOMException of type DataError must be thrown.">
9 <link rel=author href="mailto:chrcharles67@gmail.com" title="Christophe CHARLES">
11 <script src="../../../resources/testharness.js"></script>
12 <script src="../../../resources/testharnessreport.js"></script>
13 <script src="support.js"></script>
15 <script type="text/javascript">
17 // TypeError: bound requires more than 0 arguments
19 assert_throws(new TypeError(), function() {
22 }, "IDBKeyRange.bound() - bound requires more than 0 arguments.");
26 assert_throws("DataError", function() {
27 IDBKeyRange.bound(null, null);
29 }, "IDBKeyRange.bound(null, null) - null parameters are incorrect.");
33 assert_throws("DataError", function() {
34 IDBKeyRange.bound(1, null);
36 assert_throws("DataError", function() {
37 IDBKeyRange.bound(null, 1);
39 }, "IDBKeyRange.bound(1, null / null, 1) - null parameter is incorrect.");
43 var lowerBad = Math.floor(Math.random()*31) + 5;
44 var upper = lowerBad - 1;
45 assert_throws("DataError", function() {
46 IDBKeyRange.bound(lowerBad, upper);
48 assert_throws("DataError", function() {
49 IDBKeyRange.bound('b', 'a');
51 }, "IDBKeyRange.bound(lower, upper / lower > upper) - 'lower' is greater than 'upper'."
55 assert_throws("DataError", function() {
56 IDBKeyRange.bound('a', 1);
58 assert_throws("DataError", function() {
59 IDBKeyRange.bound(new Date(), 1);
61 assert_throws("DataError", function() {
62 IDBKeyRange.bound([1, 2], 1);
64 }, "IDBKeyRange.bound(DOMString/Date/Array, 1) - A DOMString, Date and Array are greater than a float.");
67 // ReferenceError: the variable is not defined
70 assert_throws(new ReferenceError(), function() {
71 IDBKeyRange.bound(noExistingVariable, 1);
73 assert_throws(new ReferenceError(), function() {
74 IDBKeyRange.bound(goodVariable, noExistingVariable);
76 }, "IDBKeyRange.bound(noExistingVariable, 1 / goodVariable, noExistingVariable) - noExistingVariable is not defined.");
78 // Valid type key error
80 assert_throws("DataError", function() {
81 IDBKeyRange.bound(true, 1);
83 }, "IDBKeyRange.bound(true, 1) - boolean is not a valid key type.");