blob: ebbc8b8beff0c82e94cc3fb1860ec39afd244101 (
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
|
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Indexed Database Property Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript;version=1.7">
function testSteps()
{
const dbName = window.location.pathname;
const dbVersion = 1;
const objectStoreName = "foo";
const entryCount = 10;
let request = indexedDB.open(dbName, dbVersion);
request.onerror = errorHandler;
request.onupgradeneeded = grabEventAndContinueHandler;
request.onsuccess = unexpectedSuccessHandler;
let event = yield undefined;
is(event.type, "upgradeneeded", "Got correct event type");
let db = event.target.result;
db.onerror = errorHandler;
db.createObjectStore(objectStoreName, { autoIncrement: true });
request.onupgradeneeded = unexpectedSuccessHandler;
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "success", "Got correct event type");
request = db.createMutableFile("bar");
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
let mutableFile = event.target.result;
let trans = db.transaction(objectStoreName, "readwrite");
let objectStore = trans.objectStore(objectStoreName);
for (let i = 0; i < entryCount; i++) {
request = objectStore.add(mutableFile);
}
let seenEntryCount = 0;
request = objectStore.openCursor().onsuccess = event => {
let cursor = event.target.result;
if (cursor) {
seenEntryCount++;
cursor.continue();
} else {
continueToNextStep();
}
}
yield undefined;
is(seenEntryCount, entryCount, "Correct entry count");
finishTest();
yield undefined;
}
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>
|