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

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

Powered by Google App Engine
This is Rietveld 408576698