OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>Bubbling and capturing of request events</title> | 3 <title>Bubbling and capturing of request events</title> |
4 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal"> | 4 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal"> |
5 <script src=../../../resources/testharness.js></script> | 5 <script src=../../../resources/testharness.js></script> |
6 <script src=../../../resources/testharnessreport.js></script> | 6 <script src=../../../resources/testharnessreport.js></script> |
7 <script src=support.js></script> | 7 <script src=support.js></script> |
8 | 8 |
9 <script> | 9 <script> |
10 var events = []; | 10 var events = []; |
(...skipping 11 matching lines...) Expand all Loading... |
22 log_request('txn', txn); | 22 log_request('txn', txn); |
23 log_request('rq1', rq1); | 23 log_request('rq1', rq1); |
24 log_request('rq2', rq2); | 24 log_request('rq2', rq2); |
25 | 25 |
26 // Don't let it get to abort | 26 // Don't let it get to abort |
27 db.addEventListener('error', function(e) { e.preventDefault() }, false); | 27 db.addEventListener('error', function(e) { e.preventDefault() }, false); |
28 } | 28 } |
29 | 29 |
30 open_rq.onsuccess = function(e) { | 30 open_rq.onsuccess = function(e) { |
31 log("open_rq.success")(e); | 31 log("open_rq.success")(e); |
32 assert_object_equals(events, [ | 32 assert_array_equals(events, [ |
33 "capture db.success", | 33 "capture db.success", |
34 "capture txn.success", | 34 "capture txn.success", |
35 "capture rq1.success", | 35 "capture rq1.success", |
36 "bubble rq1.success", | 36 "bubble rq1.success", |
37 | 37 |
38 "capture db.error: ConstraintError", | 38 "capture db.error: ConstraintError", |
39 "capture txn.error: ConstraintError", | 39 "capture txn.error: ConstraintError", |
40 "capture rq2.error: ConstraintError", | 40 "capture rq2.error: ConstraintError", |
41 "bubble rq2.error: ConstraintError", | 41 "bubble rq2.error: ConstraintError", |
42 "bubble txn.error: ConstraintError", | 42 "bubble txn.error: ConstraintError", |
43 "bubble db.error: ConstraintError", | 43 "bubble db.error: ConstraintError", |
44 | 44 |
45 "open_rq.success" | 45 "open_rq.success" |
46 ], | 46 ], |
47 "events"); | 47 "events"); |
48 this.done(); | 48 this.done(); |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 function log_request(type, obj) { | 52 function log_request(type, obj) { |
53 obj.addEventListener('success', log('capture ' + type + '.success'), tru
e); | 53 obj.addEventListener('success', log('capture ' + type + '.success'), tru
e); |
54 obj.addEventListener('success', log('bubble ' + type + '.success'), fal
se); | 54 obj.addEventListener('success', log('bubble ' + type + '.success'), fal
se); |
55 obj.addEventListener('error', log('capture ' + type + '.error'), true); | 55 obj.addEventListener('error', log('capture ' + type + '.error'), true); |
56 obj.addEventListener('error', log('bubble ' + type + '.error'), false); | 56 obj.addEventListener('error', log('bubble ' + type + '.error'), false); |
57 } | 57 } |
58 | 58 |
59 function log(msg) { | 59 function log(msg) { |
60 return function(e) { | 60 return function(e) { |
61 if(e && e.target && e.target.error) | 61 if(e && e.target && e.target.error) |
62 events.push(msg + ": " + e.target.error.name); | 62 events.push(msg + ": " + e.target.error.name); |
63 else | 63 else |
64 events.push(msg); | 64 events.push(msg); |
65 }; | 65 }; |
66 } | 66 } |
67 </script> | 67 </script> |
68 | 68 |
69 <div id=log></div> | 69 <div id=log></div> |
OLD | NEW |