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

Unified Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-direction-index.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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-direction-index.htm
diff --git a/LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-direction-index.htm b/LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-direction-index.htm
new file mode 100644
index 0000000000000000000000000000000000000000..8e028fde7e7efc16236e1f922753087d6ac98aa3
--- /dev/null
+++ b/LayoutTests/imported/web-platform-tests/IndexedDB/idbcursor-direction-index.htm
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<title>IDBCursor direction - index</title>
+<link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
+<link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#cursor-iteration-operation">
+<link rel=assert title='If direction is "next", let found record be the first record in records which satisfy all of the following requirements'>
+<link rel=assert title="If position is defined, and source is an object store, the record's key is greater than position.">
+<link rel=assert title='If direction is "prev", let found record be the last record in records which satisfy all of the following requirements'>
+<link rel=assert title="If position is defined, and source is an object store, the record's key is less than position.">
+<link rel=assert title="Set cursor's position to found record's key. If source is an index, set cursor's object store position to found record's value.">
+<link rel=assert title="Set cursor's key to found record's key.">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="support.js"></script>
+
+<script>
+ var records = [ "Alice", "Bob", "Bob", "Greg" ];
+ var directions = ["next", "prev", "nextunique", "prevunique"];
+ var tests = {};
+
+ directions.forEach(function(dir) {
+ tests[dir] = async_test(document.title + ' - ' + dir);
+ });
+
+ var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random());
+
+ open_rq.onupgradeneeded = function(e) {
+ var objStore = e.target.result.createObjectStore("test");
+ objStore.createIndex("idx", "name");
+
+ for (var i = 0; i < records.length; i++)
+ objStore.add({ name: records[i] }, i);
+ };
+
+ open_rq.onsuccess = function(e) {
+ var db = e.target.result;
+ db.onerror = fail_helper("db.onerror");
+
+
+ // The tests
+ testdir('next', ['Alice:0', 'Bob:1', 'Bob:2', 'Greg:3']);
+ testdir('prev', ['Greg:3', 'Bob:2', 'Bob:1', 'Alice:0']);
+ testdir('nextunique', ['Alice:0', 'Bob:1', 'Greg:3']);
+ testdir('prevunique', ['Greg:3', 'Bob:1', 'Alice:0']);
+
+
+ // Test function
+ function testdir(dir, expect) {
+ var count = 0;
+ var t = tests[dir];
+ var rq = db.transaction("test").objectStore("test").index("idx").openCursor(undefined, dir);
+ rq.onsuccess = t.step_func(function(e) {
+ var cursor = e.target.result;
+ if (!cursor) {
+ assert_equals(count, expect.length, "cursor runs");
+ t.done();
+ }
+ assert_equals(cursor.value.name + ":" + cursor.primaryKey, expect[count], "cursor.value");
+ count++;
+ cursor.continue();
+ });
+ rq.onerror = t.step_func(function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ assert_unreached("rq.onerror - " + e.message);
+ });
+ }
+ };
+
+ // Fail handling
+ function fail_helper(name) {
+ return function() {
+ directions.forEach(function(dir) {
+ tests[dir].step(function() { assert_unreached(name); });
+ });
+ };
+ }
+ open_rq.onblocked = fail_helper('open_rq.onblocked');
+ open_rq.onerror = fail_helper('open_rq.onerror');
+</script>
+
+<div id=log> </div>

Powered by Google App Engine
This is Rietveld 408576698