blob: 5b1b739801b5416a37c6eb7516b898405d2a93ae [file] [log] [blame]
<!DOCTYPE html>
<!--
original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_key_requirements.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 event.target.result after add() and put()");
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 = cleanDatabase;
request.onerror = unexpectedErrorCallback;
}
function cleanDatabase()
{
deleteAllObjectStores(db);
objectStore = evalAndLog("objectStore = db.createObjectStore('foo', { autoIncrement: true });");
request = evalAndLog("request = objectStore.add({});");
request.onsuccess = postAdd;
request.onerror = unexpectedErrorCallback;
}
function postAdd()
{
key1 = evalAndLog("key1 = event.target.result;");
request = evalAndLog("request = objectStore.put({}, key1);");
request.onsuccess = postPut1;
request.onerror = unexpectedErrorCallback;
}
function postPut1()
{
shouldBe("event.target.result", "key1");
key2 = evalAndLog("key2 = 10;");
request = evalAndLog("request = objectStore.put({}, key2);");
request.onsuccess = postPut2;
request.onerror = unexpectedErrorCallback;
}
function postPut2()
{
shouldBe("event.target.result", "key2");
key2 = evalAndLog("key2 = 100;");
request = evalAndLog("request = objectStore.put({}, key2);");
request.onsuccess = postPut3;
request.onerror = unexpectedErrorCallback;
}
function postPut3()
{
shouldBe("event.target.result", "key2");
done();
}
var successfullyParsed = true;
test();
</script>
</body>
</html>