Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-advance-invalid.htm

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>IDBCursor.advance() - invalid</title>
3 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
4 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html# widl-IDBCursor-advance-void-unsigned-long-count">
5 <link rel=assert title="If the value for count is 0 (zero) or a negative number, this method must throw a JavaScript TypeError exception.">
6 <link rel=assert title="TypeError The value passed into the count parameter was zero or a negative number.">
7 <link rel=assert title="InvalidStateError The cursor is currently being iterated , or has iterated past its end.">
8 <link rel=assert title="Calling this method more than once before new cursor dat a has been loaded is not allowed and results in a DOMException of type InvalidSt ateError being thrown. For example, calling advance() twice from the same onsucc ess handler results in a DOMException of type InvalidStateError being thrown on the second call.">
9 <link rel=assert title="Before this method returns, unless an exception was thro wn, it sets the got value flag on the cursor to false.">
10 <script src="../../../resources/testharness.js"></script>
11 <script src="../../../resources/testharnessreport.js"></script>
12 <script src="support.js"></script>
13
14 <script>
15
16 var db, open;
17
18 setup(function() {
19 open = indexedDB.open('testdb-' + new Date().getTime());
20 open.onupgradeneeded = function(e) {
21 db = e.target.result;
22 var objStore = db.createObjectStore("test");
23 objStore.createIndex("index", "");
24
25 objStore.add("data", 1);
26 objStore.add("data2", 2);
27 };
28 },
29 { explicit_done: true });
30
31
32 open.onsuccess = function() {
33
34 async_test(document.title + " - attempt to call advance twice").step(fun ction(e) {
35 var count = 0;
36 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
37
38 rq.onsuccess = this.step_func(function(e) {
39 if (!e.target.result) {
40 assert_equals(count, 2, 'count');
41 this.done();
42 return;
43 }
44 var cursor = e.target.result;
45
46 cursor.advance(1);
47
48 // Second try
49 assert_throws('InvalidStateError',
50 function() { cursor.advance(1); }, 'second advance');
51
52 assert_throws('InvalidStateError',
53 function() { cursor.advance(3); }, 'third advance');
54
55 count++;
56 });
57 rq.onerror = fail(this, "unexpected error")
58 });
59
60
61 async_test(document.title + " - pass something other than number").step( function(e) {
62 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
63
64 rq.onsuccess = this.step_func(function(e) {
65 var cursor = e.target.result;
66
67 assert_throws({ name: "TypeError" },
68 function() { cursor.advance(document); });
69
70 assert_throws({ name: "TypeError" },
71 function() { cursor.advance({}); });
72
73 assert_throws({ name: "TypeError" },
74 function() { cursor.advance([]); });
75
76 assert_throws({ name: "TypeError" },
77 function() { cursor.advance(""); });
78
79 assert_throws({ name: "TypeError" },
80 function() { cursor.advance("1 2"); });
81
82 this.done();
83 });
84 rq.onerror = fail(this, "unexpected error")
85 });
86
87
88 async_test(document.title + " - pass null/undefined").step(function(e) {
89 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
90
91 rq.onsuccess = this.step_func(function(e) {
92 var cursor = e.target.result;
93
94 assert_throws({ name: "TypeError" },
95 function() { cursor.advance(null); });
96
97 assert_throws({ name: "TypeError" },
98 function() { cursor.advance(undefined); });
99
100 var myvar = null;
101 assert_throws({ name: "TypeError" },
102 function() { cursor.advance(myvar); });
103
104 this.done();
105 });
106 rq.onerror = fail(this, "unexpected error")
107 });
108
109
110 async_test(document.title + " - missing argument").step(function(e) {
111 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
112
113 rq.onsuccess = this.step_func(function(e) {
114 var cursor = e.target.result;
115
116 assert_throws({ name: "TypeError" },
117 function() { cursor.advance(); });
118
119 this.done();
120 });
121 rq.onerror = fail(this, "unexpected error")
122 });
123
124
125 async_test(document.title + " - pass negative numbers").step(function(e) {
126 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
127
128 rq.onsuccess = this.step_func(function(e) {
129 var cursor = e.target.result;
130
131 assert_throws({ name: "TypeError" },
132 function() { cursor.advance(-1); });
133
134 assert_throws({ name: "TypeError" },
135 function() { cursor.advance(NaN); });
136
137 assert_throws({ name: "TypeError" },
138 function() { cursor.advance(0); });
139
140 assert_throws({ name: "TypeError" },
141 function() { cursor.advance(-0); });
142
143 assert_throws({ name: "TypeError" },
144 function() { cursor.advance(Infinity); });
145
146 assert_throws({ name: "TypeError" },
147 function() { cursor.advance(-Infinity); });
148
149 var myvar = -999999;
150 assert_throws({ name: "TypeError" },
151 function() { cursor.advance(myvar); });
152
153 this.done();
154 });
155 rq.onerror = fail(this, "unexpected error")
156 });
157
158
159 async_test(document.title + " - got value not set on exception").step(fu nction(e) {
160 var count = 0;
161 var rq = db.transaction("test").objectStore("test").index("index").o penCursor();
162
163 rq.onsuccess = this.step_func(function(e) {
164 var cursor = e.target.result;
165 if (!cursor)
166 {
167 assert_equals(count, 2, "count runs");
168 this.done();
169 return;
170 }
171
172 assert_throws({ name: "TypeError" },
173 function() { cursor.advance(0); });
174
175 cursor.advance(1);
176 count++;
177 });
178 rq.onerror = fail(this, "unexpected error")
179 });
180
181
182 // Stop blocking the testing system from hereon
183 done();
184 }
185
186 </script>
187
188 <div id=log></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698