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

        Reviewed by Tony Chang.

        Port Mozilla's IndexedDB tests: remove objectstore
        https://bugs.webkit.org/show_bug.cgi?id=60768

        This test creates an objectstore, populates it with 100 records,
        deletes the objectstore, and checks that the objectStoreNames array
        is updated properly at each step.

        * storage/indexeddb/mozilla/remove-objectstore-expected.txt: Added.
        * storage/indexeddb/mozilla/remove-objectstore.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 353d4773
2011-05-13 Mark Pilgrim <pilgrim@chromium.org>
Reviewed by Tony Chang.
Port Mozilla's IndexedDB tests: remove objectstore
https://bugs.webkit.org/show_bug.cgi?id=60768
This test creates an objectstore, populates it with 100 records,
deletes the objectstore, and checks that the objectStoreNames array
is updated properly at each step.
* storage/indexeddb/mozilla/remove-objectstore-expected.txt: Added.
* storage/indexeddb/mozilla/remove-objectstore.html: Added.
2011-05-13 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r86447.
Test IndexedDB deleting an object store
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
IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;
PASS IDBDatabaseException == null is false
indexedDB.open(name, description)
db = event.target.result
PASS db.objectStoreNames.length is 0
request = db.setVersion('1')
Deleted all object stores.
objectStoreName = 'Objects';
objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });
addedCount = 0;
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
request = objectStore.add({foo: i});
PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.item(0) is objectStoreName
db.deleteObjectStore(objectStore.name);
PASS db.objectStoreNames.length is 0
objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });
PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.item(0) is objectStoreName
request = objectStore.openCursor();
PASS event.target.result is null
db.deleteObjectStore(objectStore.name);
PASS db.objectStoreNames.length is 0
request = db.setVersion('3');
objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });
request = objectStore.add({foo:'bar'});
db.deleteObjectStore(objectStoreName);
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<!--
original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_remove_objectStore.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 deleting an object store");
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function test()
{
indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
shouldBeFalse("indexedDB == null");
IDBDatabaseException = evalAndLog("IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;");
shouldBeFalse("IDBDatabaseException == 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");
shouldBe("db.objectStoreNames.length", "0");
request = evalAndLog("request = db.setVersion('1')");
request.onsuccess = createAndPopulateObjectStore;
request.onerror = unexpectedErrorCallback;
}
function createAndPopulateObjectStore()
{
deleteAllObjectStores(db);
objectStoreName = evalAndLog("objectStoreName = 'Objects';");
objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });");
addedCount = evalAndLog("addedCount = 0;");
for (i = 0; i < 100; i++) {
request = evalAndLog("request = objectStore.add({foo: i});");
request.onerror = unexpectedErrorCallback;
request.onsuccess = function(event) {
if (++addedCount == 100) {
checkObjectStore();
}
}
}
}
function checkObjectStore()
{
shouldBe("db.objectStoreNames.length", "1");
shouldBe("db.objectStoreNames.item(0)", "objectStoreName");
request = db.setVersion('2');
request.onerror = unexpectedErrorCallback;
request.onsuccess = postSetVersion2;
}
function postSetVersion2()
{
evalAndLog("db.deleteObjectStore(objectStore.name);");
shouldBe("db.objectStoreNames.length", "0");
objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });");
shouldBe("db.objectStoreNames.length", "1");
shouldBe("db.objectStoreNames.item(0)", "objectStoreName");
request = evalAndLog("request = objectStore.openCursor();");
request.onerror = unexpectedErrorCallback;
request.onsuccess = function(event) {
shouldBe("event.target.result", "null");
deleteSecondObjectStore();
}
}
function deleteSecondObjectStore()
{
evalAndLog("db.deleteObjectStore(objectStore.name);");
shouldBe("db.objectStoreNames.length", "0");
setVersion3();
}
function setVersion3()
{
request = evalAndLog("request = db.setVersion('3');");
request.onerror = unexpectedErrorCallback;
request.onsuccess = postSetVersion3;
}
function postSetVersion3()
{
objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });");
request = evalAndLog("request = objectStore.add({foo:'bar'});");
request.onerror = unexpectedErrorCallback;
request.onsuccess = deleteThirdObjectStore;
}
function deleteThirdObjectStore()
{
evalAndLog("db.deleteObjectStore(objectStoreName);");
done();
}
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