| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>MediaMetadata / MediaSession link Mojo Test</title> |
| 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> |
| 5 <script src="../../../resources/mojo-helpers.js"></script> |
| 6 <script src="resources/mediasessionservice-mock.js"></script> |
| 7 <script src="resources/utils.js"></script> |
| 8 <script> |
| 9 |
| 10 async_test(t => { |
| 11 // The following are expected results. |
| 12 var results = [ |
| 13 new MediaMetadata({}), |
| 14 new MediaMetadata({ |
| 15 title: 'new title', |
| 16 }), |
| 17 new MediaMetadata({ |
| 18 title: 'other', |
| 19 }), |
| 20 new MediaMetadata({ |
| 21 title: 'the right change', |
| 22 }), |
| 23 ]; |
| 24 var resultId = 0; |
| 25 |
| 26 mediaSessionServiceMock.then(m => { |
| 27 m.setMetadataCallback(t.step_func(receivedMetadata => { |
| 28 assert_metadata_equals(receivedMetadata, results[resultId]); |
| 29 ++resultId; |
| 30 |
| 31 if (results.length == resultId) |
| 32 t.done(); |
| 33 })); |
| 34 |
| 35 // Setting the metadata property will update the mojo service. |
| 36 var currentMetadata = new MediaMetadata({}); |
| 37 window.navigator.mediaSession.metadata = currentMetadata; |
| 38 |
| 39 // `currentMetadata` is still associated to MediaSession. |
| 40 currentMetadata.title = 'new title'; |
| 41 |
| 42 // De-associate them. |
| 43 setTimeout(_ => { |
| 44 // This change will trigger an asynchronous request for an update. It is |
| 45 // Followed by another change that will prevent the former to work. |
| 46 currentMetadata.title = 'should not be received'; |
| 47 |
| 48 var otherMetadata = new MediaMetadata({ title: 'other' }); |
| 49 window.navigator.mediaSession.metadata = otherMetadata; |
| 50 |
| 51 // `currentMetadata` is no longer linked with the session so changes |
| 52 // should have no effect. |
| 53 currentMetadata.title = 'another attempt'; |
| 54 |
| 55 // This one will be received. |
| 56 otherMetadata.title = 'the right change'; |
| 57 }); |
| 58 }); |
| 59 }, "test that MediaMetadata is correctly propagated twice"); |
| 60 |
| 61 </script> |
| OLD | NEW |