blob: fed163e63b1c2d1ac907c6f480a5e9cd43fa9466 [file] [log] [blame]
<!DOCTYPE html>
<!--
original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_event_source.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.source in success callbacks");
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()
{
source = evalAndLog("source = event.target.source;");
shouldBe("source", "indexedDB");
db = evalAndLog("db = event.target.result");
request = evalAndLog("request = db.setVersion('1')");
request.onsuccess = cleanDatabase;
request.onerror = unexpectedErrorCallback;
}
function cleanDatabase()
{
source = evalAndLog("source = event.target.source;");
shouldBe("source", "db");
deleteAllObjectStores(db);
objectStoreName = "Objects";
objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { autoIncrement: true });");
request = evalAndLog("request = objectStore.add({});");
request.onsuccess = areWeDoneYet;
request.onerror = unexpectedErrorCallback;
}
function areWeDoneYet()
{
source = evalAndLog("source = event.target.source;");
shouldBe("source", "objectStore");
done();
}
var successfullyParsed = true;
test();
</script>
</body>
</html>