8b8f740b656a51d26638bc52af49d21a3561cd46
[WebKit-https.git] / LayoutTests / imported / w3c / IndexedDB-private-browsing / idbobjectstore_deleted.html
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Attempting to use deleted IDBObjectStore</title>
4 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#object-store">
5 <link rel=assert title="InvalidStateError Occurs if a request is made on a source object that has been deleted or removed.">
6 <link rel=author href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
7 <script src="../../../resources/testharness.js"></script>
8 <script src="../../../resources/testharnessreport.js"></script>
9 <script src=support.js></script>
10
11 <script>
12     var db,
13       add_success = false,
14       t = async_test(document.title, {timeout: 10000})
15
16     var open_rq = createdb(t);
17     open_rq.onupgradeneeded = function(e) {
18         db = e.target.result;
19
20         var objStore = db.createObjectStore("store", { autoIncrement: true });
21         assert_equals(db.objectStoreNames[0], "store", "objectStoreNames");
22
23         var rq_add = objStore.add(1);
24         rq_add.onsuccess = function() { add_success = true; };
25         rq_add.onerror = fail(t, 'rq_add.error');
26
27         objStore.createIndex("idx", "a");
28         db.deleteObjectStore("store");
29         assert_equals(db.objectStoreNames.length, 0, "objectStoreNames.length after delete");
30
31         assert_throws(null, function() { objStore.add(2); });
32         assert_throws(null, function() { objStore.put(3); });
33         assert_throws(null, function() { objStore.get(1); });
34         assert_throws(null, function() { objStore.clear(); });
35         assert_throws(null, function() { objStore.count(); });
36         assert_throws(null, function() { objStore.delete(1); });
37         assert_throws(null, function() { objStore.openCursor(); });
38         assert_throws(null, function() { objStore.index("idx"); });
39         assert_throws(null, function() { objStore.deleteIndex("idx"); });
40         assert_throws(null, function() { objStore.createIndex("idx2", "a"); });
41     }
42
43     open_rq.onsuccess = function() {
44         assert_true(add_success, "First add was successful");
45         t.done();
46     }
47 </script>
48
49 <div id=log></div>