2011-05-02 Mark Pilgrim <pilgrim@chromium.org>

        Reviewed by Tony Chang.

        Port Mozilla's IndexedDB tests: adding and removing values
        https://bugs.webkit.org/show_bug.cgi?id=59953

        * storage/indexeddb/mozilla/object-store-remove-values-expected.txt: Added.
        * storage/indexeddb/mozilla/object-store-remove-values.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@85574 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 973282ea
2011-05-02 Mark Pilgrim <pilgrim@chromium.org>
Reviewed by Tony Chang.
Port Mozilla's IndexedDB tests: adding and removing values
https://bugs.webkit.org/show_bug.cgi?id=59953
* storage/indexeddb/mozilla/object-store-remove-values-expected.txt: Added.
* storage/indexeddb/mozilla/object-store-remove-values.html: Added.
2011-05-02 Alpha Lam <hclam@chromium.org>
Not reviewed. Build fix.
Test IndexedDB: adds, gets, deletes, and re-gets a record in a variety of different object store configurations
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
PASS indexedDB == null is false
indexedDB.open(name, description)
db = event.target.result
data = [
{ name: 'inline key; key generator',
autoIncrement: true,
storedObject: {name: 'Lincoln'},
keyName: 'id',
keyValue: undefined,
},
{ name: 'inline key; no key generator',
autoIncrement: false,
storedObject: {id: 1, name: 'Lincoln'},
keyName: 'id',
keyValue: undefined,
},
{ name: 'out of line key; key generator',
autoIncrement: true,
storedObject: {name: 'Lincoln'},
keyName: undefined,
keyValue: undefined,
},
{ name: 'out of line key; no key generator',
autoIncrement: false,
storedObject: {name: 'Lincoln'},
keyName: undefined,
keyValue: 1,
}
];
i = 0;
request = db.setVersion('1')
Deleted all object stores.
objectStore = db.createObjectStore(test.name, { keyPath: test.keyName, autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
request = db.setVersion('1')
Deleted all object stores.
objectStore = db.createObjectStore(test.name, { keyPath: test.keyName, autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
request = db.setVersion('1')
Deleted all object stores.
objectStore = db.createObjectStore(test.name, { autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
request = db.setVersion('1')
Deleted all object stores.
objectStore = db.createObjectStore(test.name, { autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject, test.keyValue);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<!--
original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_objectStore_remove_values.html?force=1
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="../../../fast/js/resources/js-test-post-function.js"></script>
<script src="../resources/shared.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test IndexedDB: adds, gets, deletes, and re-gets a record in a variety of different object store configurations");
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");
data = evalAndLog("data = [\n" +
" { name: 'inline key; key generator',\n" +
" autoIncrement: true,\n" +
" storedObject: {name: 'Lincoln'},\n" +
" keyName: 'id',\n" +
" keyValue: undefined,\n" +
" },\n" +
" { name: 'inline key; no key generator',\n" +
" autoIncrement: false,\n" +
" storedObject: {id: 1, name: 'Lincoln'},\n" +
" keyName: 'id',\n" +
" keyValue: undefined,\n" +
" },\n" +
" { name: 'out of line key; key generator',\n" +
" autoIncrement: true,\n" +
" storedObject: {name: 'Lincoln'},\n" +
" keyName: undefined,\n" +
" keyValue: undefined,\n" +
" },\n" +
" { name: 'out of line key; no key generator',\n" +
" autoIncrement: false,\n" +
" storedObject: {name: 'Lincoln'},\n" +
" keyName: undefined,\n" +
" keyValue: 1,\n" +
" }\n" +
" ];");
i = evalAndLog("i = 0;");
setVersion();
}
function setVersion()
{
if (i < data.length) {
test = data[i];
request = evalAndLog("request = db.setVersion('1')");
request.onsuccess = createObjectStore;
request.onerror = unexpectedErrorCallback;
} else {
done();
}
}
function createObjectStore()
{
deleteAllObjectStores(db);
if (test.keyName) {
objectStore = evalAndLog("objectStore = db.createObjectStore(test.name, { keyPath: test.keyName, autoIncrement: test.autoIncrement });");
} else {
objectStore = evalAndLog("objectStore = db.createObjectStore(test.name, { autoIncrement: test.autoIncrement });");
}
if (test.keyValue) {
request = evalAndLog("request = objectStore.add(test.storedObject, test.keyValue);");
} else {
request = evalAndLog("request = objectStore.add(test.storedObject);");
}
request.onsuccess = getRecord;
request.onerror = unexpectedErrorCallback;
}
function getRecord()
{
id = evalAndLog("id = event.target.result;");
request = evalAndLog("request = objectStore.get(id);");
request.onerror = unexpectedErrorCallback;
request.onsuccess = deleteRecord;
}
function deleteRecord()
{
shouldBe("test.storedObject.name", "event.target.result.name");
request = evalAndLog("request = objectStore.delete(id);");
request.onerror = unexpectedErrorCallback;
request.onsuccess = getRecordAgain;
}
function getRecordAgain()
{
request = evalAndLog("request = objectStore.get(id);");
request.onerror = unexpectedErrorCallback;
request.onsuccess = finalCheck;
}
function finalCheck()
{
shouldBeTrue("event.target.result === undefined");
i++;
setVersion();
}
var successfullyParsed = true;
test();
</script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment