Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / imported / web-platform-tests / IndexedDB / idbcursor_continue_invalid.htm
1 <!DOCTYPE html>
2 <title>IDBCursor.continue() - attempt to call continue two times</title>
3 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
4 <script src="../../../resources/testharness.js"></script>
5 <script src="../../../resources/testharnessreport.js"></script>
6 <script src="support.js"></script>
7
8 <script>
9
10     var db,
11       t = async_test(document.title, {timeout: 10000});
12
13     var open_rq = createdb(t);
14     open_rq.onupgradeneeded = function(e) {
15         db = e.target.result;
16         var objStore = db.createObjectStore("test");
17
18         objStore.createIndex("index", "");
19
20         objStore.add("data",  1);
21         objStore.add("data2", 2);
22     };
23
24     open_rq.onsuccess = function(e) {
25         var count = 0;
26         var cursor_rq = db.transaction("test")
27                           .objectStore("test")
28                           .index("index")
29                           .openCursor();
30
31         cursor_rq.onsuccess = t.step_func(function(e) {
32             if (!e.target.result) {
33                 assert_equals(count, 2, 'count');
34                 t.done();
35                 return;
36             }
37             var cursor = e.target.result;
38
39             cursor.continue(undefined);
40
41             // Second try
42             assert_throws('InvalidStateError',
43                 function() { cursor.continue(); }, 'second continue');
44
45             assert_throws('InvalidStateError',
46                 function() { cursor.continue(3); }, 'third continue');
47
48             count++;
49         });
50     };
51
52 </script>
53
54 <div id="log"></div>