blob: e842f5bfbf8ee117f0d6f3c0c0ca84ec47ae48c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<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's IDBObjectStore.removeObjectStore().");
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function test()
{
result = evalAndLog("indexedDB.open('name', 'description')");
verifyResult(result);
result.onsuccess = createObjectStore;
result.onerror = unexpectedErrorCallback;
}
function createObjectStore()
{
verifySuccessEvent(event);
db = evalAndLog("db = event.result");
deleteAllObjectStores(db);
result = evalAndLog("db.createObjectStore('storeName', null)");
verifyResult(result);
result.onsuccess = addValue;
result.onerror = unexpectedErrorCallback;
}
function addValue()
{
verifySuccessEvent(event);
result = evalAndLog("event.result.add('value', 'key')");
verifyResult(result);
result.onsuccess = getValue;
result.onerror = unexpectedErrorCallback;
}
function getValue()
{
verifySuccessEvent(event);
result = evalAndLog("event.source.get('key')");
verifyResult(result);
result.onsuccess = addIndex;
result.onerror = unexpectedErrorCallback;
}
function addIndex()
{
verifySuccessEvent(event);
shouldBeEqualToString("event.result", "value");
result = evalAndLog("event.source.createIndex('indexName', '')");
verifyResult(result);
result.onsuccess = removeObjectStore;
result.onerror = unexpectedErrorCallback;
}
function removeObjectStore()
{
verifySuccessEvent(event);
shouldBeTrue("event.source.indexNames.contains('indexName')");
result = evalAndLog("db.removeObjectStore('storeName')");
verifyResult(result);
result.onsuccess = createObjectStoreAgain;
result.onerror = unexpectedErrorCallback;
}
function createObjectStoreAgain()
{
verifySuccessEvent(event);
result = evalAndLog("db.createObjectStore('storeName', null)");
verifyResult(result);
result.onsuccess = getValueAgain;
result.onerror = unexpectedErrorCallback;
}
function getValueAgain()
{
verifySuccessEvent(event);
result = evalAndLog("event.result.get('key')");
verifyResult(result);
result.onsuccess = unexpectedSuccessCallback;
result.onerror = verifyError;
}
function verifyError()
{
verifyErrorEvent(event);
// FIXME: Should just be IDBDatabaseException.NOT_FOUND_ERR but that doesn't work yet.
shouldBe("event.code", "2");
shouldBeFalse("event.source.indexNames.contains('indexName')");
done();
}
test();
var successfullyParsed = true;
</script>
</body>
</html>
|