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

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-direction-index-keyrange.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 direction - index with keyrange</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# cursor-iteration-operation">
5 <link rel=assert title='If direction is "next", let found record be the first re cord in records which satisfy all of the following requirements'>
6 <link rel=assert title="If position is defined, and source is an index, the reco rd's key is equal to position and the record's value is greater than object stor e position or the record's key is greater than position.">
7 <link rel=assert title='If direction is "prev", let found record be the last rec ord in records which satisfy all of the following requirements'>
8 <link rel=assert title="If position is defined, and source is an index, the reco rd's key is equal to position and the record's value is less than object store p osition or the record's key is less than position.">
9 <link rel=assert title="If range is defined, the record's key is in range.">
10 <link rel=assert title="If temp record is defined, let found record be the first record in records whose key is equal to temp record's key.">
11 <link rel=assert title="records is always sorted in ascending key order. In the case of source being an index, records is secondarily sorted in ascending value order.">
12 <script src="../../../resources/testharness.js"></script>
13 <script src="../../../resources/testharnessreport.js"></script>
14 <script src="support.js"></script>
15
16 <script>
17 var records = [ 1337, "Alice", "Bob", "Bob", "Greg", "Åke", ["Anne"] ];
18 var directions = ["next", "prev", "nextunique", "prevunique"];
19 var tests = {};
20
21 directions.forEach(function(dir) {
22 tests[dir] = async_test(document.title + ' - ' + dir);
23 });
24
25 var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random( ));
26
27 open_rq.onupgradeneeded = function(e) {
28 var objStore = e.target.result.createObjectStore("test");
29 objStore.createIndex("idx", "name");
30
31 for (var i = 0; i < records.length; i++)
32 objStore.add({ name: records[i] }, i);
33 };
34
35 open_rq.onsuccess = function(e) {
36 var db = e.target.result;
37 db.onerror = fail_helper("db.onerror");
38
39
40 // The tests
41 testdir('next', ['Alice:1', 'Bob:2', 'Bob:3', 'Greg:4']);
42 testdir('prev', ['Greg:4', 'Bob:3', 'Bob:2', 'Alice:1']);
43 testdir('nextunique', ['Alice:1', 'Bob:2', 'Greg:4']);
44 testdir('prevunique', ['Greg:4', 'Bob:2', 'Alice:1']);
45
46
47 // Test function
48 function testdir(dir, expect) {
49 var count = 0;
50 var t = tests[dir];
51 var rq = db.transaction("test").objectStore("test").index("idx").ope nCursor(IDBKeyRange.bound("AA", "ZZ"), dir);
52 rq.onsuccess = t.step_func(function(e) {
53 var cursor = e.target.result;
54 if (!cursor) {
55 assert_equals(count, expect.length, "cursor runs");
56 t.done();
57 }
58 assert_equals(cursor.value.name + ":" + cursor.primaryKey, expec t[count], "cursor.value");
59 count++;
60 cursor.continue();
61 });
62 rq.onerror = t.step_func(function(e) {
63 e.preventDefault();
64 e.stopPropagation();
65 assert_unreached("rq.onerror - " + e.message);
66 });
67 }
68 };
69
70 // Fail handling
71 function fail_helper(name) {
72 return function() {
73 directions.forEach(function(dir) {
74 tests[dir].step(function() { assert_unreached(name); });
75 });
76 };
77 }
78 open_rq.onblocked = fail_helper('open_rq.onblocked');
79 open_rq.onerror = fail_helper('open_rq.onerror');
80 </script>
81
82 <div id=log> </div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698