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

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-direction-objectstore-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 - object store 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 direction is "prev", let found record be the last rec ord in records which satisfy all of the following requirements'>
7 <link rel=assert title="If range is defined, the record's key is in range.">
8 <script src="../../../resources/testharness.js"></script>
9 <script src="../../../resources/testharnessreport.js"></script>
10 <script src="support.js"></script>
11
12 <script>
13 var records = [ 1337, "Alice", "Bob", "Greg", "Åke", ["Anne"] ];
14 var directions = ["next", "prev", "nextunique", "prevunique"];
15 var tests = {};
16
17 directions.forEach(function(dir) {
18 tests[dir] = async_test(document.title + ' - ' + dir);
19 });
20
21 var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random( ));
22
23 open_rq.onupgradeneeded = function(e) {
24 var objStore = e.target.result.createObjectStore("test");
25
26 for (var i = 0; i < records.length; i++)
27 objStore.add(records[i], records[i]);
28 };
29
30 open_rq.onsuccess = function(e) {
31 var db = e.target.result;
32 db.onerror = fail_helper("db.onerror");
33
34
35 // The tests
36 testdir('next', ['Alice', 'Bob', 'Greg']);
37 testdir('prev', ['Greg', 'Bob', 'Alice']);
38 testdir('nextunique', ['Alice', 'Bob', 'Greg']);
39 testdir('prevunique', ['Greg', 'Bob', 'Alice']);
40
41
42 // Test function
43 function testdir(dir, expect) {
44 var count = 0;
45 var t = tests[dir];
46 var rq = db.transaction("test").objectStore("test").openCursor(IDBKe yRange.bound("AA", "ZZ"), dir);
47 rq.onsuccess = t.step_func(function(e) {
48 var cursor = e.target.result;
49 if (!cursor) {
50 assert_equals(count, expect.length, "cursor runs");
51 t.done();
52 }
53 assert_equals(cursor.value, expect[count], "cursor.value");
54 count++;
55 cursor.continue();
56 });
57 rq.onerror = t.step_func(function(e) {
58 e.preventDefault();
59 e.stopPropagation();
60 assert_unreached("rq.onerror - " + e.message);
61 });
62 }
63 };
64
65 // Fail handling
66 function fail_helper(name) {
67 return function() {
68 directions.forEach(function(dir) {
69 tests[dir].step(function() { assert_unreached(name); });
70 });
71 };
72 }
73 open_rq.onblocked = fail_helper('open_rq.onblocked');
74 open_rq.onerror = fail_helper('open_rq.onerror');
75 </script>
76
77 <div id=log> </div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698