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
|
<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 transaction and objectStore calls");
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function test()
{
shouldBeTrue("'webkitIndexedDB' in window");
shouldBeFalse("webkitIndexedDB == null");
result = evalAndLog("webkitIndexedDB.open('name', 'description')");
verifyResult(result);
result.onsuccess = openSuccess;
result.onerror = unexpectedErrorCallback;
}
function openSuccess()
{
window.db = evalAndLog("db = event.result");
result = evalAndLog("result = db.setVersion('version 1')");
result.onsuccess = cleanDatabase;
result.onerror = unexpectedErrorCallback;
}
function cleanDatabase()
{
trans = evalAndLog("trans = event.result");
deleteAllObjectStores(db, cleaned);
}
function cleaned()
{
evalAndLog("db.createObjectStore('a')");
evalAndLog("db.createObjectStore('b')");
evalAndLog("trans.oncomplete = created");
debug("");
}
function created()
{
trans = evalAndLog("trans = db.transaction({objectStoreNames: 'a'})");
evalAndLog("trans.objectStore('a')");
evalAndExpectException("trans.objectStore('b')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
trans = evalAndLog("trans = db.transaction({objectStoreNames: ['a']})");
evalAndLog("trans.objectStore('a')");
evalAndExpectException("trans.objectStore('b')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
trans = evalAndLog("trans = db.transaction({objectStoreNames: ['b']})");
evalAndLog("trans.objectStore('b')");
evalAndExpectException("trans.objectStore('a')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
trans = evalAndLog("trans = db.transaction({objectStoreNames: ['a', 'b']})");
evalAndLog("trans.objectStore('a')");
evalAndLog("trans.objectStore('b')");
evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
trans = evalAndLog("trans = db.transaction({objectStoreNames: ['b', 'a']})");
evalAndLog("trans.objectStore('a')");
evalAndLog("trans.objectStore('b')");
evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
trans = evalAndLog("trans = db.transaction({objectStoreNames: []})");
evalAndLog("trans.objectStore('a')");
evalAndLog("trans.objectStore('b')");
evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
trans = evalAndLog("trans = db.transaction()");
evalAndLog("trans.objectStore('a')");
evalAndLog("trans.objectStore('b')");
evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
evalAndExpectException("db.transaction({objectStoreNames: 'x'})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
evalAndExpectException("db.transaction({objectStoreNames: ['x']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
evalAndExpectException("db.transaction({objectStoreNames: ['a', 'x']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
evalAndExpectException("db.transaction({objectStoreNames: ['x', 'x']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
evalAndExpectException("db.transaction({objectStoreNames: ['a', 'x', 'b']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
debug("");
done();
}
var successfullyParsed = true;
test();
</script>
</body>
</html>
|