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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-upgradeneeded-event-exception.html

Issue 2734533002: IndexedDB: Align abort behavior on uncaught exception with Gecko (Closed)
Patch Set: Test refactors per review Created 3 years, 9 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
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Fire upgradeneeded event - Exception thrown</title>
4 <link rel="help" href="https://w3c.github.io/IndexedDB/#fire-a-version-change-ev ent">
5 <script src=/resources/testharness.js></script>
6 <script src=/resources/testharnessreport.js></script>
7 <script src=support.js></script>
8 <script>
9 setup({allow_uncaught_exception:true});
10
11 function fire_upgradeneeded_event_test(func, description) {
12 async_test(t => {
13 const dbname = document.location + '-' + t.name;
14 const del = indexedDB.deleteDatabase(dbname);
15 del.onerror = t.unreached_func('deleteDatabase should succeed');
16 const open = indexedDB.open(dbname, 1);
17 open.onsuccess = t.unreached_func('open should fail');
18 func(t, open);
19 }, description);
20 }
21
22 fire_upgradeneeded_event_test((t, open) => {
23 let tx;
24 open.onupgradeneeded = () => {
25 tx = open.transaction;
26 throw Error();
27 };
28 open.onerror = t.step_func_done(() => {
29 assert_equals(tx.error.name, 'AbortError');
30 });
31 }, 'Exception in upgradeneeded handler');
32
33 fire_upgradeneeded_event_test((t, open) => {
34 let tx;
35 open.addEventListener('upgradeneeded', () => {
36 tx = open.transaction;
37 throw Error();
38 });
39 open.onerror = t.step_func_done(() => {
40 assert_equals(tx.error.name, 'AbortError');
41 });
42 }, 'Exception in upgradeneeded listener');
43
44 fire_upgradeneeded_event_test((t, open) => {
45 let tx;
46 open.addEventListener('upgradeneeded', () => {
47 // No-op.
48 });
49 open.addEventListener('upgradeneeded', () => {
50 tx = open.transaction;
51 throw Error();
52 });
53 open.onerror = t.step_func_done(() => {
54 assert_equals(tx.error.name, 'AbortError');
55 });
56 }, 'Exception in second upgradeneeded listener');
57
58 fire_upgradeneeded_event_test((t, open) => {
59 let tx;
60 let second_listener_called = false;
61 open.addEventListener('upgradeneeded', () => {
62 open.result.createObjectStore('s');
63 throw Error();
64 });
65 open.addEventListener('upgradeneeded', t.step_func(() => {
66 second_listener_called = true;
67 tx = open.transaction;
68 assert_true(is_transaction_active(tx, 's'),
69 'Transaction should be active until dispatch completes');
70 }));
71 open.onerror = t.step_func_done(() => {
72 assert_true(second_listener_called);
73 assert_equals(tx.error.name, 'AbortError');
74 });
75 }, 'Exception in first upgradeneeded listener, tx active in second');
76
77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698