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

Side by Side Diff: third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-async.html

Issue 2584703002: Media Session API: make MediaMetadata mutable. (Closed)
Patch Set: review comments and tests Created 4 years 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 <title>MediaMetadata 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 album: 'new album',
17 artist: 'new artist',
18 artwork: [
19 { src: 'http://example.com/', type: 'image/png', sizes: '40x40' }
20 ]
21 }),
22 new MediaMetadata({
23 title: 'first timeout',
24 album: 'new album',
25 artist: 'new artist',
26 artwork: [
27 { src: 'http://example.com/', type: 'image/png', sizes: '40x40' }
28 ]
29 }),
30 new MediaMetadata({
31 title: 'second timeout',
32 album: 'new album',
33 artist: 'new artist',
34 artwork: [
35 { src: 'http://example.com/', type: 'image/png', sizes: '40x40' }
36 ]
37 }),
38 ];
39 var resultId = 0;
40
41 mediaSessionServiceMock.then(m => {
42 m.setMetadataCallback(t.step_func(receivedMetadata => {
43 assert_metadata_equals(receivedMetadata, results[resultId]);
44 ++resultId;
45
46 if (results.length == resultId)
47 t.done();
48 }));
49
50 // Setting the metadata property will update the mojo service.
51 window.navigator.mediaSession.metadata = new MediaMetadata({});
52
53 // All the next lines will produce only one call.
54 window.navigator.mediaSession.metadata.title = 'new title';
55 window.navigator.mediaSession.metadata.album = 'new album';
56 window.navigator.mediaSession.metadata.artist = 'new artist';
57 var image = new MediaImage(
58 { src: 'http://example.com/', sizes: '40x40', type: 'image/png' });
59 window.navigator.mediaSession.metadata.artwork = [ image ];
60
61 // This two last changes are made asynchronously and will go in different
62 // mojo calls.
63 setTimeout(_ => {
64 window.navigator.mediaSession.metadata.title = 'first timeout';
65 setTimeout(_ => {
66 window.navigator.mediaSession.metadata.title = 'second timeout';
67 });
68 });
69 });
70 }, "test that MediaMetadata is correctly propagated twice");
71
72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698