Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / storage / indexeddb / index-basics-expected.txt
1 Test the basics of IndexedDB's IDBIndex.
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 = "index-basics.html"
9 indexedDB.deleteDatabase(dbname)
10 indexedDB.open(dbname)
11
12 prepareDatabase():
13 db.createObjectStore('storeName', null)
14 store.createIndex('indexName', 'x')
15 store.createIndex('indexName2', 'y', {unique: false})
16 store.createIndex('zIndex', 'z', {unique: true})
17 PASS store.createIndex('index4', 'path', undefined) did not throw exception.
18 PASS indexObject2.unique is false
19 PASS indexObject3.unique is true
20 Expecting TypeError exception from store.createIndex('failureIndex', 'zzz', true)
21 PASS Exception was thrown.
22 PASS store.createIndex('failureIndex', 'zzz', true) threw TypeError: Failed to execute 'createIndex' on 'IDBObjectStore': parameter 3 ('options') is not an object.
23 Expecting TypeError exception from store.createIndex('failureIndex', 'zzz', 'string')
24 PASS Exception was thrown.
25 PASS store.createIndex('failureIndex', 'zzz', 'string') threw TypeError: Failed to execute 'createIndex' on 'IDBObjectStore': parameter 3 ('options') is not an object.
26 PASS 'name' in indexObject is true
27 PASS indexObject.name is "indexName"
28 PASS 'objectStore' in indexObject is true
29 PASS indexObject.objectStore.name is "storeName"
30 PASS 'keyPath' in indexObject is true
31 PASS indexObject.keyPath is "x"
32 PASS 'unique' in indexObject is true
33 PASS 'multiEntry' in indexObject is true
34 PASS indexObject.unique is false
35 PASS indexObject.multiEntry is false
36 PASS 'openKeyCursor' in indexObject is true
37 PASS typeof indexObject.openKeyCursor is "function"
38 PASS 'openCursor' in indexObject is true
39 PASS typeof indexObject.openCursor is "function"
40 PASS 'getKey' in indexObject is true
41 PASS typeof indexObject.getKey is "function"
42 PASS 'get' in indexObject is true
43 PASS typeof indexObject.get is "function"
44 PASS 'count' in indexObject is true
45 PASS typeof indexObject.count is "function"
46 store.add({x: 'value', y: 'zzz', z: 2.72}, 'key')
47 event.target.source.add({x: 'value2', y: 'zzz2', z: 2.71, foobar: 12}, 'key2')
48 store.createIndex('indexWhileAddIsInFlight', 'x')
49 store.createIndex('indexWithWeirdKeyPath', 'foobar')
50 Add data which doesn't have a key in the z index.
51 event.target.source.add({x: 'value3', y: '456'}, 'key3')
52 Add data which has invalid key for y index, no key for the z index.
53 event.target.source.add({x: 'value4', y: null}, 'key4')
54 indexObject.getKey('value')
55 PASS event.target.result is "key"
56 indexObject2.getKey('zzz')
57 PASS event.target.result is "key"
58 indexObject3.get(2.71)
59 PASS event.target.result.x is "value2"
60 indexObject.get('value')
61 PASS event.target.result.x is "value"
62 PASS event.target.result.y is "zzz"
63 indexObject.getKey('does not exist')
64 PASS event.target.result is undefined
65 indexObject.get('does not exist')
66 PASS event.target.result is undefined
67 indexObject4.getKey('value2')
68 PASS event.target.result is "key2"
69
70 Verify that specifying an invalid direction raises an exception:
71 Expecting TypeError exception from indexObject.openKeyCursor(0, 'invalid-direction')
72 PASS Exception was thrown.
73 PASS indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openKeyCursor' on 'IDBIndex': parameter 2 ('invalid-direction') is not a valid enum value.
74
75 indexObject.openKeyCursor()
76 PASS event.target.source is indexObject
77 PASS event.target.result is non-null.
78 PASS event.target.result.key is "value"
79 PASS event.target.result.primaryKey is "key"
80 event.target.result.continue()
81 PASS event.target.result is non-null.
82 PASS event.target.result.key is "value2"
83 PASS event.target.result.primaryKey is "key2"
84 event.target.result.continue()
85 PASS event.target.result is non-null.
86 PASS event.target.result.key is "value3"
87 PASS event.target.result.primaryKey is "key3"
88 event.target.result.continue()
89 PASS event.target.result is non-null.
90 PASS event.target.result.key is "value4"
91 PASS event.target.result.primaryKey is "key4"
92 event.target.result.continue()
93 PASS event.target.result is null
94
95 Verify that specifying an invalid direction raises an exception:
96 Expecting TypeError exception from indexObject.openCursor(0, 'invalid-direction')
97 PASS Exception was thrown.
98 PASS indexObject.openCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openCursor' on 'IDBIndex': parameter 2 ('invalid-direction') is not a valid enum value.
99
100 indexObject.openCursor()
101 PASS event.target.source is indexObject
102 PASS event.target.result is non-null.
103 PASS event.target.result.key is "value"
104 PASS event.target.result.value.x is "value"
105 PASS event.target.result.value.y is "zzz"
106 event.target.result.continue()
107 PASS event.target.result is non-null.
108 PASS event.target.result.key is "value2"
109 PASS event.target.result.value.x is "value2"
110 PASS event.target.result.value.y is "zzz2"
111 event.target.result.continue()
112 PASS event.target.result is non-null.
113 PASS event.target.result.key is "value3"
114 PASS event.target.result.value.x is "value3"
115 PASS event.target.result.value.y is "456"
116 event.target.result.continue()
117 PASS event.target.result is non-null.
118 PASS event.target.result.key is "value4"
119 PASS event.target.result.value.x is "value4"
120 PASS event.target.result.value.y is null
121 event.target.result.continue()
122 PASS event.target.result is null
123 request = indexObject.count()
124 PASS event.target.result is 4
125 request = indexObject2.count()
126 PASS event.target.result is 3
127 request = indexObject3.count()
128 PASS event.target.result is 2
129 Passing an invalid key into indexObject.get({}).
130 Expecting exception from indexObject.get({})
131 PASS Exception was thrown.
132 PASS code is 0
133 PASS ename is 'DataError'
134 Exception message: Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key.
135 Passing an invalid key into indexObject.getKey({}).
136 Expecting exception from indexObject.getKey({})
137 PASS Exception was thrown.
138 PASS code is 0
139 PASS ename is 'DataError'
140 Exception message: Failed to execute 'getKey' on 'IDBIndex': The parameter is not a valid key.
141 PASS successfullyParsed is true
142
143 TEST COMPLETE
144