OLD | NEW |
| (Empty) |
1 Test IndexedDB binary keys | |
2 | |
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | |
4 | |
5 | |
6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | |
7 | |
8 dbname = "key-type-binary.html" | |
9 indexedDB.deleteDatabase(dbname) | |
10 indexedDB.open(dbname) | |
11 db.createObjectStore('store'); | |
12 | |
13 | |
14 testValidBinaryKeys(): | |
15 trans = db.transaction('store', 'readwrite') | |
16 store = trans.objectStore('store') | |
17 | |
18 store.put(0, new Uint8Array([])); | |
19 PASS request.result.toString() is "[object Uint8Array]" | |
20 PASS [].slice.call(request.result).toString() is [].toString() | |
21 store.get(new Uint8Array([])); | |
22 PASS request.result is 0 | |
23 | |
24 store.put(1, new Uint8Array([0])); | |
25 PASS request.result.toString() is "[object Uint8Array]" | |
26 PASS [].slice.call(request.result).toString() is [0].toString() | |
27 store.get(new Uint8Array([0])); | |
28 PASS request.result is 1 | |
29 | |
30 store.put(2, new Uint8Array([0, 0])); | |
31 PASS request.result.toString() is "[object Uint8Array]" | |
32 PASS [].slice.call(request.result).toString() is [0, 0].toString() | |
33 store.get(new Uint8Array([0, 0])); | |
34 PASS request.result is 2 | |
35 | |
36 store.put(3, new Uint8Array([0, 1])); | |
37 PASS request.result.toString() is "[object Uint8Array]" | |
38 PASS [].slice.call(request.result).toString() is [0, 1].toString() | |
39 store.get(new Uint8Array([0, 1])); | |
40 PASS request.result is 3 | |
41 | |
42 store.put(4, new Uint8Array([1])); | |
43 PASS request.result.toString() is "[object Uint8Array]" | |
44 PASS [].slice.call(request.result).toString() is [1].toString() | |
45 store.get(new Uint8Array([1])); | |
46 PASS request.result is 4 | |
47 | |
48 store.put(5, new Uint8Array([1, 0])); | |
49 PASS request.result.toString() is "[object Uint8Array]" | |
50 PASS [].slice.call(request.result).toString() is [1, 0].toString() | |
51 store.get(new Uint8Array([1, 0])); | |
52 PASS request.result is 5 | |
53 | |
54 store.put(6, new Uint8Array([1, 1])); | |
55 PASS request.result.toString() is "[object Uint8Array]" | |
56 PASS [].slice.call(request.result).toString() is [1, 1].toString() | |
57 store.get(new Uint8Array([1, 1])); | |
58 PASS request.result is 6 | |
59 | |
60 store.put(7, new Uint8Array([255])); | |
61 PASS request.result.toString() is "[object Uint8Array]" | |
62 PASS [].slice.call(request.result).toString() is [255].toString() | |
63 store.get(new Uint8Array([255])); | |
64 PASS request.result is 7 | |
65 | |
66 testInvalidBinaryKeys(): | |
67 trans = db.transaction('store', 'readwrite') | |
68 store = trans.objectStore('store') | |
69 | |
70 Expecting exception from store.put('value', new Uint8ClampedArray([1,2,3])) | |
71 PASS Exception was thrown. | |
72 PASS code is 0 | |
73 PASS ename is 'DataError' | |
74 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
75 | |
76 Expecting exception from store.put('value', new Uint16Array([1,2,3])) | |
77 PASS Exception was thrown. | |
78 PASS code is 0 | |
79 PASS ename is 'DataError' | |
80 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
81 | |
82 Expecting exception from store.put('value', new Uint32Array([1,2,3])) | |
83 PASS Exception was thrown. | |
84 PASS code is 0 | |
85 PASS ename is 'DataError' | |
86 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
87 | |
88 Expecting exception from store.put('value', new Int8Array([1,2,3])) | |
89 PASS Exception was thrown. | |
90 PASS code is 0 | |
91 PASS ename is 'DataError' | |
92 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
93 | |
94 Expecting exception from store.put('value', new Int16Array([1,2,3])) | |
95 PASS Exception was thrown. | |
96 PASS code is 0 | |
97 PASS ename is 'DataError' | |
98 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
99 | |
100 Expecting exception from store.put('value', new Int32Array([1,2,3])) | |
101 PASS Exception was thrown. | |
102 PASS code is 0 | |
103 PASS ename is 'DataError' | |
104 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
105 | |
106 Expecting exception from store.put('value', new Float32Array([1,2,3])) | |
107 PASS Exception was thrown. | |
108 PASS code is 0 | |
109 PASS ename is 'DataError' | |
110 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
111 | |
112 Expecting exception from store.put('value', new Float64Array([1,2,3])) | |
113 PASS Exception was thrown. | |
114 PASS code is 0 | |
115 PASS ename is 'DataError' | |
116 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
117 | |
118 Expecting exception from store.put('value', new Uint8Array([1,2,3]).buffer) | |
119 PASS Exception was thrown. | |
120 PASS code is 0 | |
121 PASS ename is 'DataError' | |
122 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
123 | |
124 Expecting exception from store.put('value', new DataView(new Uint8Array([1,2,3])
.buffer)) | |
125 PASS Exception was thrown. | |
126 PASS code is 0 | |
127 PASS ename is 'DataError' | |
128 Exception message: Failed to execute 'put' on 'IDBObjectStore': The parameter is
not a valid key. | |
129 PASS successfullyParsed is true | |
130 | |
131 TEST COMPLETE | |
132 | |
OLD | NEW |