Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / imported / web-platform-tests / IndexedDB / idbkeyrange_incorrect.htm
1 <!DOCTYPE html>
2 <!--  Submitted from TestTWF Paris  -->
3 <html>
4     <head>
5         <meta charset=utf-8>
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">
10
11         <script src="../../../resources/testharness.js"></script>
12         <script src="../../../resources/testharnessreport.js"></script>
13         <script src="support.js"></script>
14
15         <script type="text/javascript">
16
17             // TypeError: bound requires more than 0 arguments
18             test( function() {
19                 assert_throws(new TypeError(), function() {
20                     IDBKeyRange.bound();
21                 });
22             }, "IDBKeyRange.bound() - bound requires more than 0 arguments.");
23
24             // Null parameters
25             test( function() {
26                 assert_throws("DataError", function() {
27                     IDBKeyRange.bound(null, null);
28                 });
29             }, "IDBKeyRange.bound(null, null) - null parameters are incorrect.");
30
31             // // Null parameter
32             test( function() {
33                 assert_throws("DataError", function() {
34                     IDBKeyRange.bound(1, null);
35                 });
36                 assert_throws("DataError", function() {
37                     IDBKeyRange.bound(null, 1);
38                 });
39             }, "IDBKeyRange.bound(1, null / null, 1) - null parameter is incorrect.");
40
41             // bound incorrect
42             test( function() {
43                 var lowerBad = Math.floor(Math.random()*31) + 5;
44                 var upper = lowerBad - 1;
45                 assert_throws("DataError", function() {
46                     IDBKeyRange.bound(lowerBad, upper);
47                 });
48                 assert_throws("DataError", function() {
49                     IDBKeyRange.bound('b', 'a');
50                 });
51             }, "IDBKeyRange.bound(lower, upper / lower > upper) -  'lower' is greater than 'upper'."
52             );
53
54             test( function() {
55                 assert_throws("DataError", function() {
56                     IDBKeyRange.bound('a', 1);
57                 });
58                 assert_throws("DataError", function() {
59                     IDBKeyRange.bound(new Date(), 1);
60                 });
61                 assert_throws("DataError", function() {
62                     IDBKeyRange.bound([1, 2], 1);
63                 });
64             }, "IDBKeyRange.bound(DOMString/Date/Array, 1) - A DOMString, Date and Array are greater than a float.");
65
66
67             // ReferenceError: the variable is not defined
68             test( function() {
69                 var goodVariable = 1;
70                 assert_throws(new ReferenceError(), function() {
71                     IDBKeyRange.bound(noExistingVariable, 1);
72                 });
73                 assert_throws(new ReferenceError(), function() {
74                     IDBKeyRange.bound(goodVariable, noExistingVariable);
75                 });
76             }, "IDBKeyRange.bound(noExistingVariable, 1 / goodVariable, noExistingVariable) - noExistingVariable is not defined.");
77
78             // Valid type key error
79             test( function() {
80                 assert_throws("DataError", function() {
81                     IDBKeyRange.bound(true, 1);
82                 });
83             }, "IDBKeyRange.bound(true, 1) - boolean is not a valid key type.");
84
85
86         </script>
87     </head>
88
89     <body>
90         <div id="log"></div>
91     </body>
92 </html>