Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / imported / web-platform-tests / IndexedDB / interfaces.html
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>IndexedDB IDL tests</title>
4 <script src=../../../resources/testharness.js></script>
5 <script src=../../../resources/testharnessreport.js></script>
6 <script src=/resources/WebIDLParser.js></script>
7 <script src=/resources/idlharness.js></script>
8 <script src=support.js></script>
9
10 <h1>IndexedDB IDL tests</h1>
11 <div id=log></div>
12
13 <script type=text/plain>
14 enum IDBTransactionMode {
15     "readonly",
16     "readwrite",
17     "versionchange"
18 };
19
20 enum IDBRequestReadyState {
21     "pending",
22     "done"
23 };
24
25 interface IDBKeyRange {
26     readonly    attribute any     lower;
27     readonly    attribute any     upper;
28     readonly    attribute boolean lowerOpen;
29     readonly    attribute boolean upperOpen;
30     static IDBKeyRange only (any value);
31     static IDBKeyRange lowerBound (any lower, optional boolean open = false);
32     static IDBKeyRange upperBound (any upper, optional boolean open = false);
33     static IDBKeyRange bound (any lower, any upper, optional boolean lowerOpen = false, optional boolean upperOpen = false);
34 };
35
36 enum IDBCursorDirection {
37     "next",
38     "nextunique",
39     "prev",
40     "prevunique"
41 };
42
43 dictionary IDBObjectStoreParameters {
44     (DOMString or sequence<DOMString>)? keyPath = null;
45     boolean                             autoIncrement = false;
46 };
47
48 dictionary IDBIndexParameters {
49     boolean unique = false;
50     boolean multiEntry = false;
51 };
52
53 dictionary IDBVersionChangeEventInit : EventInit {
54     unsigned long long  oldVersion = 0;
55     unsigned long long? newVersion = null;
56 };
57
58 interface IDBRequest : EventTarget {
59     readonly    attribute any                                        result;
60     readonly    attribute DOMError                                   error;
61     readonly    attribute (IDBObjectStore or IDBIndex or IDBCursor)? source;
62     readonly    attribute IDBTransaction                             transaction;
63     readonly    attribute IDBRequestReadyState                       readyState;
64                 attribute EventHandler                               onsuccess;
65                 attribute EventHandler                               onerror;
66 };
67
68 interface IDBOpenDBRequest : IDBRequest {
69                 attribute EventHandler onblocked;
70                 attribute EventHandler onupgradeneeded;
71 };
72
73 [Constructor(DOMString type, optional IDBVersionChangeEventInit eventInitDict)]
74 interface IDBVersionChangeEvent : Event {
75     readonly    attribute unsigned long long  oldVersion;
76     readonly    attribute unsigned long long? newVersion;
77 };
78
79 Window implements IDBEnvironment;
80 WorkerUtils implements IDBEnvironment;
81
82 [NoInterfaceObject]
83 interface IDBEnvironment {
84     readonly    attribute IDBFactory indexedDB;
85 };
86
87 interface IDBFactory {
88     IDBOpenDBRequest open (DOMString name, [EnforceRange] optional unsigned long long version);
89     IDBOpenDBRequest deleteDatabase (DOMString name);
90     short            cmp (any first, any second);
91 };
92
93 interface IDBDatabase : EventTarget {
94     readonly    attribute DOMString          name;
95     readonly    attribute unsigned long long version;
96     readonly    attribute DOMStringList      objectStoreNames;
97     IDBObjectStore createObjectStore (DOMString name, optional IDBObjectStoreParameters optionalParameters);
98     void           deleteObjectStore (DOMString name);
99     IDBTransaction transaction ((DOMString or sequence<DOMString>) storeNames, optional IDBTransactionMode mode = "readonly");
100     void           close ();
101                 attribute EventHandler       onabort;
102                 attribute EventHandler       onerror;
103                 attribute EventHandler       onversionchange;
104 };
105
106 interface IDBObjectStore {
107     readonly    attribute DOMString      name;
108     readonly    attribute any            keyPath;
109     readonly    attribute DOMStringList  indexNames;
110     readonly    attribute IDBTransaction transaction;
111     readonly    attribute boolean        autoIncrement;
112     IDBRequest put (any value, optional any key);
113     IDBRequest add (any value, optional any key);
114     IDBRequest delete (any key);
115     IDBRequest get (any key);
116     IDBRequest clear ();
117     IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
118     IDBIndex   createIndex (DOMString name, (DOMString or sequence<DOMString>) keyPath, optional IDBIndexParameters optionalParameters);
119     IDBIndex   index (DOMString name);
120     void       deleteIndex (DOMString indexName);
121     IDBRequest count (optional any key);
122 };
123
124 interface IDBIndex {
125     readonly    attribute DOMString      name;
126     readonly    attribute IDBObjectStore objectStore;
127     readonly    attribute any            keyPath;
128     readonly    attribute boolean        multiEntry;
129     readonly    attribute boolean        unique;
130     IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
131     IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next");
132     IDBRequest get (any key);
133     IDBRequest getKey (any key);
134     IDBRequest count (optional any key);
135 };
136
137 interface IDBCursor {
138     readonly    attribute (IDBObjectStore or IDBIndex) source;
139     readonly    attribute IDBCursorDirection           direction;
140     readonly    attribute any                          key;
141     readonly    attribute any                          primaryKey;
142     IDBRequest update (any value);
143     void       advance ([EnforceRange] unsigned long count);
144     void       continue (optional any key);
145     IDBRequest delete ();
146 };
147
148 interface IDBCursorWithValue : IDBCursor {
149     readonly    attribute any value;
150 };
151
152 interface IDBTransaction : EventTarget {
153     readonly    attribute IDBTransactionMode mode;
154     readonly    attribute IDBDatabase        db;
155     readonly    attribute DOMError           error;
156     IDBObjectStore objectStore (DOMString name);
157     void           abort ();
158                 attribute EventHandler       onabort;
159                 attribute EventHandler       oncomplete;
160                 attribute EventHandler       onerror;
161 };
162 </script>
163
164 <script type="text/plain" class="untested">
165 interface Window { };
166
167 interface WorkerUtils { };
168
169 interface EventTarget { };
170 </script>
171
172 <script>
173 "use strict";
174 setup(function() {
175   var idlArray = new IdlArray();
176
177   [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
178     if (node.className == "untested") {
179        idlArray.add_untested_idls(node.textContent);
180     } else {
181        idlArray.add_idls(node.textContent);
182     }
183   });
184
185   idlArray.add_objects({
186     IDBKeyRange: [],
187     IDBRequest: [],
188     IDBOpenDBRequest: [],
189     IDBEnvironment: [],
190     IDBVersionChangeEvent: ['new IDBVersionChangeEvent("foo")'],
191     IDBFactory: ['window.indexedDB'],
192     IDBDatabase: [],
193     IDBObjectStore: [],
194     IDBIndex: [],
195     IDBCursor: [],
196     IDBCursorWithValue: [],
197     IDBTransaction: []
198   });
199
200   idlArray.test();
201 });
202 </script>
203