OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test that setting MediaSession callbacks are alive after garbage-collecti
on</title> | 2 <title>Test that setting MediaSession callbacks are alive after garbage-collecti
on</title> |
3 <script src="../../../resources/testharness.js"></script> | 3 <script src="../../../resources/testharness.js"></script> |
4 <script src="../../../resources/testharnessreport.js"></script> | 4 <script src="../../../resources/testharnessreport.js"></script> |
5 <script src="../../../resources/mojo-helpers.js"></script> | 5 <script src="../../../resources/mojo-helpers.js"></script> |
6 <script src="resources/mediasessionservice-mock.js"></script> | 6 <script src="resources/mediasessionservice-mock.js"></script> |
7 <script src="resources/utils.js"></script> | 7 <script src="resources/utils.js"></script> |
| 8 <script src="../../../resources/gc.js"></script> |
8 <script> | 9 <script> |
9 | 10 |
10 var mock; | 11 var mock; |
11 | 12 |
12 function gc() { | |
13 if (window.GCController) { | |
14 GCController.collect(); | |
15 } else { | |
16 for (var i = 0; i < 10000; ++i) { | |
17 ({ }); | |
18 } | |
19 } | |
20 } | |
21 | |
22 async_test(function(t) { | 13 async_test(function(t) { |
23 mediaSessionServiceMock.then(m => { | 14 mediaSessionServiceMock.then(m => { |
24 mock = m; | 15 mock = m; |
25 mock.setClientCallback(_ => { | 16 mock.setClientCallback(_ => { |
26 gc(); | 17 gc(); |
27 setTimeout(_ => { | 18 setTimeout(_ => { |
28 mock.getClient().didReceiveAction(MediaSessionAction.PLAY); | 19 mock.getClient().didReceiveAction(MediaSessionAction.PLAY); |
29 }); | 20 }); |
30 }); | 21 }); |
31 window.navigator.mediaSession.setActionHandler("play", _ => { t.done(); }); | 22 window.navigator.mediaSession.setActionHandler("play", _ => { t.done(); }); |
32 }); | 23 }); |
33 }); | 24 }); |
34 </script> | 25 </script> |
OLD | NEW |