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

Side by Side Diff: third_party/WebKit/LayoutTests/storage/indexeddb/idbcursor-update-exception-order.html

Issue 2415203002: Indexed DB: More exception precedence tests (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>IndexedDB: IDBCursor update() Exception Ordering</title> 2 <title>IndexedDB: IDBCursor update() Exception Ordering</title>
3 <meta charset=utf-8>
3 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbcursor-update"> 4 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbcursor-update">
4 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="resources/testharness-helpers.js"></script> 7 <script src="resources/testharness-helpers.js"></script>
7
8 <script> 8 <script>
9 9
10 indexeddb_test( 10 indexeddb_test(
11 function(t, db) { 11 (t, db) => {
12 var s = db.createObjectStore('s'); 12 const s = db.createObjectStore('s');
13 s.put('value', 'key'); 13 s.put('value', 'key');
14 }, 14 },
15 function(t, db) { 15 (t, db) => {
16 var s = db.transaction('s', 'readonly').objectStore('s'); 16 const s = db.transaction('s', 'readonly').objectStore('s');
17 var r = s.openCursor(); 17 const r = s.openCursor();
18 r.onsuccess = t.step_func(function() { 18 r.onsuccess = t.step_func(() => {
19 r.onsuccess = null; 19 r.onsuccess = null;
20 var cursor = r.result; 20 const cursor = r.result;
21 setTimeout(t.step_func(function() { 21 setTimeout(t.step_func(() => {
22 assert_throws('TransactionInactiveError', function() { 22 assert_throws('TransactionInactiveError', () => {
23 cursor.update('value2'); 23 cursor.update('value2');
24 }, '"Transaction inactive" check (TransactionInactiveError) ' + 24 }, '"Transaction inactive" check (TransactionInactiveError) ' +
25 'should precede "read only" check (ReadOnlyError)'); 25 'should precede "read only" check (ReadOnlyError)');
26 t.done(); 26 t.done();
27 }), 0); 27 }), 0);
28 }); 28 });
29 }, 29 },
30 'IDBCursor.update exception order: TransactionInactiveError vs. ReadOnlyErro r' 30 'IDBCursor.update exception order: TransactionInactiveError vs. ReadOnlyError'
31 ); 31 );
32 32
33 indexeddb_test( 33 indexeddb_test(
34 function(t, db) { 34 (t, db) => {
35 var s = db.createObjectStore('s'); 35 const s = db.createObjectStore('s');
36 s.put('value', 'key'); 36 s.put('value', 'key');
37 }, 37 },
38 function(t, db) { 38 (t, db) => {
39 var s = db.transaction('s', 'readonly').objectStore('s'); 39 const s = db.transaction('s', 'readonly').objectStore('s');
40 var r = s.openCursor(); 40 const r = s.openCursor();
41 r.onsuccess = t.step_func(function() { 41 r.onsuccess = t.step_func(() => {
42 r.onsuccess = null; 42 r.onsuccess = null;
43 var cursor = r.result; 43 const cursor = r.result;
44 cursor.continue(); 44 cursor.continue();
45 assert_throws('ReadOnlyError', function() { 45 assert_throws('ReadOnlyError', () => {
46 cursor.update('value2'); 46 cursor.update('value2');
47 }, '"Read only" check (ReadOnlyError) should precede '+ 47 }, '"Read only" check (ReadOnlyError) should precede '+
48 '"got value flag" check (InvalidStateError)'); 48 '"got value flag" check (InvalidStateError)');
49 t.done(); 49 t.done();
50 }); 50 });
51 }, 51 },
52 'IDBCursor.update exception order: ReadOnlyError vs. InvalidStateError #1' 52 'IDBCursor.update exception order: ReadOnlyError vs. InvalidStateError #1'
53 ); 53 );
54 54
55 indexeddb_test( 55 indexeddb_test(
56 function(t, db) { 56 (t, db) => {
57 var s = db.createObjectStore('s'); 57 const s = db.createObjectStore('s');
58 s.put('value', 'key'); 58 s.put('value', 'key');
59 }, 59 },
60 function(t, db) { 60 (t, db) => {
61 var s = db.transaction('s', 'readonly').objectStore('s'); 61 const s = db.transaction('s', 'readonly').objectStore('s');
62 var r = s.openKeyCursor(); 62 const r = s.openKeyCursor();
63 r.onsuccess = t.step_func(function() { 63 r.onsuccess = t.step_func(() => {
64 r.onsuccess = null; 64 r.onsuccess = null;
65 var cursor = r.result; 65 const cursor = r.result;
66 cursor.continue(); 66 cursor.continue();
pwnall 2016/10/14 07:57:04 I think this continue() call also gets you in the
jsbell 2016/10/17 19:42:03 Done.
67 assert_throws('ReadOnlyError', function() { 67 assert_throws('ReadOnlyError', () => {
68 cursor.update('value2'); 68 cursor.update('value2');
69 }, '"Read only" check (ReadOnlyError) should precede '+ 69 }, '"Read only" check (ReadOnlyError) should precede '+
70 '"key only flag" check (InvalidStateError)'); 70 '"key only flag" check (InvalidStateError)');
71 t.done(); 71 t.done();
72 }); 72 });
73 }, 73 },
74 'IDBCursor.update exception order: ReadOnlyError vs. InvalidStateError #2' 74 'IDBCursor.update exception order: ReadOnlyError vs. InvalidStateError #2'
75 ); 75 );
76 76
77 indexeddb_test( 77 indexeddb_test(
78 function(t, db) { 78 (t, db) => {
79 var s = db.createObjectStore('s', {keyPath: 'id'}); 79 const s = db.createObjectStore('s', {keyPath: 'id'});
80 s.put({id: 123, data: 'value'}); 80 s.put({id: 123, data: 'value'});
81 }, 81 },
82 function(t, db) { 82 (t, db) => {
83 var s = db.transaction('s', 'readwrite').objectStore('s'); 83 const s = db.transaction('s', 'readwrite').objectStore('s');
84 var r = s.openCursor(); 84 const r = s.openCursor();
85 r.onsuccess = t.step_func(function() { 85 r.onsuccess = t.step_func(() => {
86 r.onsuccess = null; 86 r.onsuccess = null;
87 var cursor = r.result; 87 const cursor = r.result;
88 cursor.continue(); 88 cursor.continue();
89 assert_throws('InvalidStateError', function() { 89 assert_throws('InvalidStateError', () => {
90 cursor.update({id: 123, data: 'value2'}); 90 cursor.update({id: 123, data: 'value2'});
91 }, '"Got value flag" check (InvalidStateError) should precede ' + 91 }, '"Got value flag" check (InvalidStateError) should precede ' +
92 '"modified key" check (DataError)'); 92 '"modified key" check (DataError)');
93 t.done(); 93 t.done();
94 }); 94 });
95 }, 95 },
96 'IDBCursor.update exception order: InvalidStateError vs. DataError' 96 'IDBCursor.update exception order: InvalidStateError vs. DataError'
97 ); 97 );
98 98
99 </script> 99 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698