| Index: third_party/WebKit/LayoutTests/http/tests/inspector/indexeddb/upgrade-events.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/indexeddb/upgrade-events.html b/third_party/WebKit/LayoutTests/http/tests/inspector/indexeddb/upgrade-events.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c94f4208b8db5eb03da8e4095f4c0c408dd0339c
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/indexeddb/upgrade-events.html
|
| @@ -0,0 +1,146 @@
|
| +<html>
|
| +<head>
|
| +<script src="../inspector-test.js"></script>
|
| +<script src="indexeddb-test.js"></script>
|
| +<script>
|
| +function test()
|
| +{
|
| + var indexedDBModel = new WebInspector.IndexedDBModel(WebInspector.targetManager.mainTarget());
|
| + indexedDBModel.enable();
|
| + var mainFrameId = InspectorTest.resourceTreeModel.mainFrame.id;
|
| + var securityOrigin = "http://127.0.0.1:8000";
|
| + var databaseName = "testDatabase - " + self.location;
|
| + var objectStoreName = "testObjectStore";
|
| + var databaseId = new WebInspector.IndexedDBModel.DatabaseId(securityOrigin, databaseName);
|
| +
|
| + function onConsoleError(callback) {
|
| + var old = console.error;
|
| + console.error = function(message) {
|
| + console.error = old;
|
| + InspectorTest.addResult(message);
|
| + callback();
|
| + };
|
| + }
|
| +
|
| + function addIDBValues(count, callback)
|
| + {
|
| + var i = 0;
|
| + addValues();
|
| +
|
| + function addValues()
|
| + {
|
| + if (i == count) {
|
| + callback();
|
| + return;
|
| + }
|
| + ++i;
|
| + var id = i < 10 ? "0" + i : i;
|
| + var key = "key_" + id;
|
| + var value = "value_" + id;
|
| + InspectorTest.addIDBValue(mainFrameId, databaseName, objectStoreName, { key: key, value: value }, "", addValues);
|
| + }
|
| + }
|
| +
|
| + function loadValues(skipCount, pageSize, callback)
|
| + {
|
| + indexedDBModel.loadObjectStoreData(databaseId, objectStoreName, null, skipCount, pageSize, innerCallback);
|
| +
|
| + function innerCallback(entries, hasMore)
|
| + {
|
| + callback();
|
| + }
|
| + }
|
| +
|
| + InspectorTest.addSniffer(WebInspector.IndexedDBModel.prototype, "_updateOriginDatabaseNames", fillDatabase, false);
|
| +
|
| + function fillDatabase()
|
| + {
|
| + InspectorTest.addResult('Preparing database');
|
| + InspectorTest.deleteDatabase(mainFrameId, databaseName, step2);
|
| +
|
| + function step2()
|
| + {
|
| + InspectorTest.createDatabase(mainFrameId, databaseName, step3);
|
| + }
|
| +
|
| + function step3()
|
| + {
|
| + InspectorTest.createObjectStore(mainFrameId, databaseName, objectStoreName, "key", true, step4);
|
| + }
|
| +
|
| + function step4()
|
| + {
|
| + addIDBValues(6, step5);
|
| + }
|
| +
|
| + function step5()
|
| + {
|
| + InspectorTest.addResult('Verifying that database was created');
|
| + checkDatabaseDoesExist(loadValuesAndDeleteDatabase);
|
| + }
|
| + }
|
| +
|
| + function loadValuesAndDeleteDatabase()
|
| + {
|
| + InspectorTest.addResult('Loading values');
|
| + loadValues(0, 2, step2);
|
| +
|
| + function step2()
|
| + {
|
| + InspectorTest.addResult('Deleting database');
|
| + InspectorTest.deleteDatabase(mainFrameId, databaseName, step3);
|
| + }
|
| +
|
| + function step3()
|
| + {
|
| + // ... but access the database again. This will implicitly attempt to recreate it,
|
| + // which should be aborted during the "upgradeneeded" event.
|
| + InspectorTest.addResult('Loading values again (which should fail)');
|
| + loadValues(0, 2, function() { InspectorTest.addResult("Unexpected callback"); });
|
| + onConsoleError(step4);
|
| + }
|
| +
|
| + function step4()
|
| + {
|
| + InspectorTest.addResult('Verifying that database was not recreated');
|
| + checkDatabaseDoesNotExist(step5);
|
| + }
|
| +
|
| + function step5()
|
| + {
|
| + InspectorTest.completeTest();
|
| + }
|
| + }
|
| +
|
| + function checkDatabaseDoesExist(callback)
|
| + {
|
| + InspectorTest.addSniffer(WebInspector.IndexedDBModel.prototype, "_updateOriginDatabaseNames", step2, false);
|
| + indexedDBModel.refreshDatabaseNames();
|
| +
|
| + function step2()
|
| + {
|
| + var names = indexedDBModel._databaseNamesBySecurityOrigin[securityOrigin];
|
| + InspectorTest.assertGreaterOrEqual(0, names.indexOf(databaseName), "Database should exist");
|
| + callback();
|
| + }
|
| + }
|
| +
|
| + function checkDatabaseDoesNotExist(callback)
|
| + {
|
| + InspectorTest.addSniffer(WebInspector.IndexedDBModel.prototype, "_updateOriginDatabaseNames", step2, false);
|
| + indexedDBModel.refreshDatabaseNames();
|
| +
|
| + function step2()
|
| + {
|
| + var names = indexedDBModel._databaseNamesBySecurityOrigin[securityOrigin];
|
| + InspectorTest.assertEquals(-1, names.indexOf(databaseName), "Database should not exist");
|
| + callback();
|
| + }
|
| + }
|
| +}
|
| +</script>
|
| +</head>
|
| +<body onload="runTest()">
|
| +<p>Tests that deleted databases do not get recreated.</p>
|
| +</body>
|
| +</html>
|
|
|