blob: c2b90ec25a97f361e527f4dd410c9a1a9342ee58 [file] [log] [blame]
<!DOCTYPE html>
<!--
original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_remove_index.html
license of original test:
" Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ "
-->
<html>
<head>
<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
<script src="../../../fast/js/resources/js-test-pre.js"></script>
<script src="../resources/shared.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test IndexedDB's creating and deleting indexes");
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function test()
{
indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
shouldBeFalse("indexedDB == null");
name = window.location.pathname;
description = "My Test Database";
request = evalAndLog("indexedDB.open(name, description)");
request.onsuccess = openSuccess;
request.onerror = unexpectedErrorCallback;
}
function openSuccess()
{
db = evalAndLog("db = event.target.result");
request = evalAndLog("request = db.setVersion('1')");
request.onsuccess = createAndDeleteIndex;
request.onerror = unexpectedErrorCallback;
}
function createAndDeleteIndex()
{
deleteAllObjectStores(db);
objectStoreName = "test store";
objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });");
shouldBe("db.objectStoreNames.length", "1");
shouldBe("db.objectStoreNames.item(0)", "objectStoreName");
shouldBe("objectStore.indexNames.length", "0");
indexName = "My Test Index";
index = evalAndLog("index = objectStore.createIndex(indexName, 'foo');");
shouldBe("objectStore.indexNames.length", "1");
shouldBe("objectStore.indexNames.item(0)", "indexName");
evalAndLog("objectStore.deleteIndex(indexName);");
shouldBe("objectStore.indexNames.length", "0");
done();
}
var successfullyParsed = true;
test();
</script>
</body>
</html>