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

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor_continue_index5.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.continue() - index - iterate using 'prevunique'</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 "prevunique", let temp record be the las t record in records which satisfy all of the following requirements:'>
6 <link rel=assert title="If position is defined, the record's key is less than po sition.">
7 <script src="../../../resources/testharness.js"></script>
8 <script src="../../../resources/testharnessreport.js"></script>
9 <script src="support.js"></script>
10
11 <script>
12
13 var db,
14 t = async_test(document.title, {timeout: 10000}),
15 records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
16 { pKey: "primaryKey_1", iKey: "indexKey_1" },
17 { pKey: "primaryKey_1-2", iKey: "indexKey_1" },
18 { pKey: "primaryKey_2", iKey: "indexKey_2" } ],
19
20 expected = [ { pKey: "primaryKey_2", iKey: "indexKey_2" },
21 { pKey: "primaryKey_1", iKey: "indexKey_1" },
22 { pKey: "primaryKey_0", iKey: "indexKey_0" } ];
23
24 var open_rq = createdb(t);
25 open_rq.onupgradeneeded = function(e) {
26 db = e.target.result;
27 var objStore = db.createObjectStore("test", { keyPath: "pKey" });
28
29 objStore.createIndex("index", "iKey");
30
31 for (var i = 0; i < records.length; i++)
32 objStore.add(records[i]);
33 };
34
35 open_rq.onsuccess = function(e) {
36 var count = 0,
37 cursor_rq = db.transaction("test")
38 .objectStore("test")
39 .index("index")
40 .openCursor(undefined, 'prevunique');
41
42 cursor_rq.onsuccess = t.step_func(function(e) {
43 if (!e.target.result) {
44 assert_equals(count, expected.length, 'count');
45 t.done();
46 return;
47 }
48 var cursor = e.target.result,
49 record = cursor.value;
50
51 assert_equals(record.pKey, expected[count].pKey, "pKey #" + count);
52 assert_equals(record.iKey, expected[count].iKey, "iKey #" + count);
53
54 assert_equals(cursor.key, expected[count].iKey, "cursor.key #" + co unt);
55 assert_equals(cursor.primaryKey, expected[count].pKey, "cursor.prima ryKey #" + count);
56
57 count++;
58 cursor.continue(expected[count] ? expected[count].iKey : undefined);
59 });
60 };
61
62 </script>
63
64 <div id="log"></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698