Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1161)

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbfactory_open10.htm

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>IDBFactory.open() - error in upgradeneeded resets db</title>
3 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
4 <script src=../../../resources/testharness.js></script>
5 <script src=../../../resources/testharnessreport.js></script>
6 <script src=support.js></script>
7
8 <script>
9 var db, db2;
10 var open_rq = createdb(async_test(document.title, {timeout: 10000}), undefin ed, 9);
11
12 open_rq.onupgradeneeded = function(e) {
13 db = e.target.result;
14
15 var st = db.createObjectStore("store");
16 st.createIndex("index", "i");
17
18 assert_equals(db.version, 9, "first db.version");
19 assert_true(db.objectStoreNames.contains("store"), "objectStoreNames con tains store");
20 assert_true(st.indexNames.contains("index"), "indexNames contains index" );
21
22 st.add({i: "Joshua"}, 1);
23 st.add({i: "Jonas"}, 2);
24 };
25 open_rq.onsuccess = function(e) {
26 db.close();
27 var open_rq2 = window.indexedDB.open(db.name, 10);
28 open_rq2.onupgradeneeded = this.step_func(function(e) {
29 db2 = e.target.result;
30
31 db2.createObjectStore("store2");
32
33 var store = open_rq2.transaction.objectStore("store")
34 store.createIndex("index2", "i");
35
36 assert_equals(db2.version, 10, "db2.version");
37
38 assert_true(db2.objectStoreNames.contains("store"), "second objectSt oreNames contains store");
39 assert_true(db2.objectStoreNames.contains("store2"), "second objectS toreNames contains store2");
40 assert_true(store.indexNames.contains("index"), "second indexNames c ontains index");
41 assert_true(store.indexNames.contains("index2"), "second indexNames contains index2");
42
43 store.add({i: "Odin"}, 3);
44 store.put({i: "Sicking"}, 2);
45
46 open_rq2.transaction.abort();
47 });
48 open_rq2.onerror = this.step_func(function(e) {
49 assert_equals(db2.version, 9, "db2.version after error");
50 assert_true(db2.objectStoreNames.contains("store"), "objectStoreName s contains store after error");
51 assert_false(db2.objectStoreNames.contains("store2"), "objectStoreNa mes not contains store2 after error");
52
53 var open_rq3 = window.indexedDB.open(db.name);
54 open_rq3.onsuccess = this.step_func(function(e) {
55 var db3 = e.target.result;
56
57 assert_true(db3.objectStoreNames.contains("store"), "third objec tStoreNames contains store");
58 assert_false(db3.objectStoreNames.contains("store2"), "third obj ectStoreNames contains store2");
59
60 var st = db3.transaction("store").objectStore("store");
61
62 assert_equals(db3.version, 9, "db3.version");
63
64 assert_true(st.indexNames.contains("index"), "third indexNames c ontains index");
65 assert_false(st.indexNames.contains("index2"), "third indexNames contains index2");
66
67 st.openCursor(null, "prev").onsuccess = this.step_func(function( e) {
68 assert_equals(e.target.result.key, 2, "opencursor(prev) key" );
69 assert_equals(e.target.result.value.i, "Jonas", "opencursor( prev) value");
70 });
71 st.get(3).onsuccess = this.step_func(function(e) {
72 assert_equals(e.target.result, undefined, "get(3)");
73 });
74
75 var idx = st.index("index");
76 idx.getKey("Jonas").onsuccess = this.step_func(function(e) {
77 assert_equals(e.target.result, 2, "getKey(Jonas)");
78 });
79 idx.getKey("Odin").onsuccess = this.step_func(function(e) {
80 assert_equals(e.target.result, undefined, "getKey(Odin)");
81 });
82 idx.getKey("Sicking").onsuccess = this.step_func(function(e) {
83 assert_equals(e.target.result, undefined, "getKey(Sicking)") ;
84 this.done();
85 });
86 });
87 });
88 };
89 </script>
90
91 <div id=log></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698