Revision a78790aeb8417fb65c61a74ca82aea5f1e7c63ff authored by James Graham on 28 March 2014, 16:19:44 UTC, committed by James Graham on 28 March 2014, 16:19:44 UTC
1 parent a4e2797
index_sort_order.htm
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title> Verify key sort order in an index is 'number < Date < DOMString' </title>
<script type="text/javascript" src="support.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
var objectStoreName = "objectstore";
var indexName = "index";
var d = new Date();
var records = [{foo:d},
{foo:"test"},
{foo:1},
{foo:2.55}];
var expectedKeyOrder = [1, 2.55, d, "test"];
var db = null;
var t = async_test();
function RunTest() {
var rqOpen = window.indexedDB.open(databaseName, databaseVersion);
rqOpen.onupgradeneeded = t.step_func(function(event) {
db = event.target.result;
db.onerror = t.step_func(assert_database_error);
var objStore = db.createObjectStore(objectStoreName, {autoIncrement:true});
var index = objStore.createIndex(indexName, "foo");
for (var i = 0; i < records.length; i++) {
objStore.add(records[i]);
}
});
rqOpen.onerror = t.step_func(assert_open_request_error);
rqOpen.onsuccess = t.step_func(VerifyKeyOrderIsCorrect);
}
function VerifyKeyOrderIsCorrect() {
var txn = db.transaction(objectStoreName, "readonly");
var objStore = txn.objectStore(objectStoreName);
var index = objStore.index(indexName);
var count = 0;
var rqCursor = index.openCursor();
rqCursor.onsuccess = t.step_func(function(event) {
var cursor = event.target.result;
if (cursor) {
assert_equals(cursor.key.valueOf(), expectedKeyOrder[count].valueOf(), 'cursor.key');
count++;
cursor.continue();
} else {
t.done();
}
});
}
add_completion_callback(function() { if(db) db.close(); });
setup(function() {
var rqDelete = window.indexedDB.deleteDatabase(databaseName);
rqDelete.onsuccess = t.step_func( RunTest );
});
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...