| mlamouri | 3d90a80 | 2017-02-09 20:50:21 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <title>Tests various ways to call cancelWatchAvailability()</title> |
| 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script src="/common/media.js"></script> |
| 7 | <script> |
| 8 | async_test(t => { |
| 9 | var v = document.createElement('video'); |
| 10 | v.src = getVideoURI('movie_5'); |
| 11 | |
| 12 | v.remote.watchAvailability(function() {}) |
| 13 | .then(t.step_func(id => { |
| 14 | v.remote.cancelWatchAvailability(id).then(t.step_func(function() { |
| 15 | v.remote.cancelWatchAvailability(id).then( |
| 16 | t.unreached_func(), t.step_func_done(e => { |
| 17 | assert_equals(e.name, 'NotFoundError'); |
| 18 | }) |
| 19 | ); |
| 20 | }), t.unreached_func()); |
| 21 | }), t.unreached_func()); |
| 22 | }, 'Test that calling cancelWatchAvailability() with an id does remove the callback.'); |
| 23 | |
| 24 | async_test(t => { |
| 25 | var v = document.createElement('video'); |
| 26 | v.src = getVideoURI('media_5'); |
| 27 | |
| 28 | Promise.all([ |
| 29 | v.remote.watchAvailability(function() {}), |
| 30 | v.remote.watchAvailability(function() {}) |
| 31 | ]).then(t.step_func(ids => { |
| 32 | v.remote.cancelWatchAvailability().then(t.step_func(function() { |
| 33 | v.remote.cancelWatchAvailability(ids[0]).then(t.unreached_func(), t.step_func(function(e) { |
| 34 | assert_equals(e.name, 'NotFoundError'); |
| 35 | v.remote.cancelWatchAvailability(ids[1]) |
| 36 | .then(t.unreached_func(), t.step_func_done(function(e) { |
| 37 | assert_equals(e.name, 'NotFoundError'); |
| 38 | })); |
| 39 | })); |
| 40 | }), t.unreached_func()); |
| 41 | }), t.unreached_func()); |
| 42 | }, 'Test that calling cancelWatchAvailability() without an id removes all the callbacks.'); |
| 43 | </script> |
| 44 | </html> |