blob: fba6b95fbe8e8a97dbb04a9964439b5ed138ed47 (
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
|
<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 read-only transactions in IndexedDB.");
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function test()
{
shouldBeTrue("'webkitIndexedDB' in window");
shouldBeFalse("webkitIndexedDB == null");
result = evalAndLog("webkitIndexedDB.open('name')");
verifyResult(result);
result.onsuccess = openSuccess;
result.onerror = unexpectedErrorCallback;
}
function openSuccess()
{
debug("openSuccess():");
verifySuccessEvent(event);
window.db = evalAndLog("db = event.result");
result = evalAndLog("result = db.setVersion('version 1')");
result.onsuccess = cleanDatabase;
result.onerror = unexpectedErrorCallback;
}
function cleanDatabase()
{
verifySuccessEvent(event);
deleteAllObjectStores(db, setVersionStuff);
}
function setVersionStuff()
{
event.result.oncomplete = setVersionDone;
event.result.onabort = unexpectedAbortCallback;
store = evalAndLog("store = db.createObjectStore('store')");
evalAndLog("store.put('x', 'y')");
}
function setVersionDone()
{
trans = evalAndLog("trans = db.transaction()");
evalAndExpectException("trans.objectStore('store').put('a', 'b')", "webkitIDBDatabaseException.READ_ONLY_ERR");
trans = evalAndLog("trans = db.transaction()");
evalAndExpectException("trans.objectStore('store').delete('x')", "webkitIDBDatabaseException.READ_ONLY_ERR");
trans = evalAndLog("trans = db.transaction()");
cur = evalAndLog("cur = trans.objectStore('store').openCursor()");
cur.onsuccess = gotCursor;
cur.onerror = unexpectedErrorCallback;
}
function gotCursor()
{
shouldBeFalse("!event.result");
evalAndExpectException("event.result.delete()", "webkitIDBDatabaseException.READ_ONLY_ERR");
done();
}
var successfullyParsed = true;
test();
</script>
</body>
</html>
|