2 Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/
7 <title>Indexed Database Property Test
</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <script type=
"text/javascript">
15 const name
= window
.location
.pathname
;
17 const objectStoreName
= "Blobs";
19 const blob
= getRandomBlob(1000);
20 const file
= getRandomFile("random.bin", 100000);
22 const objectData1
= { key
: 1, object
: { foo
: blob
, bar
: blob
} };
23 const objectData2
= { key
: 2, object
: { foo
: file
, bar
: file
} };
25 SpecialPowers
.pushPrefEnv({ set: [["dom.indexedDB.dataThreshold", -1]] },
29 let request
= indexedDB
.open(name
, 1);
30 request
.onerror
= errorHandler
;
31 request
.onupgradeneeded
= grabEventAndContinueHandler
;
32 request
.onsuccess
= grabEventAndContinueHandler
;
33 let event
= yield undefined;
35 is(event
.type
, "upgradeneeded", "Got correct event type");
37 let db
= event
.target
.result
;
38 db
.onerror
= errorHandler
;
40 let objectStore
= db
.createObjectStore(objectStoreName
, { });
42 objectStore
.add(objectData1
.object
, objectData1
.key
);
43 objectStore
.add(objectData2
.object
, objectData2
.key
);
45 event
= yield undefined;
47 is(event
.type
, "success", "Got correct event type");
49 objectStore
= db
.transaction([objectStoreName
])
50 .objectStore(objectStoreName
);
51 request
= objectStore
.get(objectData1
.key
);
52 request
.onsuccess
= grabEventAndContinueHandler
;
53 event
= yield undefined;
55 let result
= event
.target
.result
;
57 verifyBlob(result
.foo
, blob
, 1);
60 verifyBlob(result
.bar
, blob
, 1);
63 objectStore
= db
.transaction([objectStoreName
])
64 .objectStore(objectStoreName
);
65 request
= objectStore
.get(objectData2
.key
);
66 request
.onsuccess
= grabEventAndContinueHandler
;
67 event
= yield undefined;
69 result
= event
.target
.result
;
71 verifyBlob(result
.foo
, file
, 2);
74 verifyBlob(result
.bar
, file
, 2);
80 <script type=
"text/javascript" src=
"file.js"></script>
81 <script type=
"text/javascript" src=
"helpers.js"></script>
85 <body onload=
"runTest();"></body>