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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-async.html
diff --git a/third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-async.html b/third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-async.html
new file mode 100644
index 0000000000000000000000000000000000000000..185b81be8e245bbdcddfedbe347a1a84f64b2b43
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-async.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<title>MediaMetadata Mojo Test</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../resources/mojo-helpers.js"></script>
+<script src="resources/mediasessionservice-mock.js"></script>
+<script src="resources/utils.js"></script>
+<script>
+
+async_test(t => {
+ // The following are expected results.
+ var results = [
+ new MediaMetadata({}),
+ new MediaMetadata({
+ title: 'new title',
+ album: 'new album',
+ artist: 'new artist',
+ artwork: [
+ { src: 'http://example.com/', type: 'image/png', sizes: '40x40' }
+ ]
+ }),
+ new MediaMetadata({
+ title: 'first timeout',
+ album: 'new album',
+ artist: 'new artist',
+ artwork: [
+ { src: 'http://example.com/', type: 'image/png', sizes: '40x40' }
+ ]
+ }),
+ new MediaMetadata({
+ title: 'second timeout',
+ album: 'new album',
+ artist: 'new artist',
+ artwork: [
+ { src: 'http://example.com/', type: 'image/png', sizes: '40x40' }
+ ]
+ }),
+ ];
+ var resultId = 0;
+
+ mediaSessionServiceMock.then(m => {
+ m.setMetadataCallback(t.step_func(receivedMetadata => {
+ assert_metadata_equals(receivedMetadata, results[resultId]);
+ ++resultId;
+
+ if (results.length == resultId)
+ t.done();
+ }));
+
+ // Setting the metadata property will update the mojo service.
+ window.navigator.mediaSession.metadata = new MediaMetadata({});
+
+ // All the next lines will produce only one call.
+ window.navigator.mediaSession.metadata.title = 'new title';
+ window.navigator.mediaSession.metadata.album = 'new album';
+ window.navigator.mediaSession.metadata.artist = 'new artist';
+ var image = new MediaImage(
+ { src: 'http://example.com/', sizes: '40x40', type: 'image/png' });
+ window.navigator.mediaSession.metadata.artwork = [ image ];
+
+ // This two last changes are made asynchronously and will go in different
+ // mojo calls.
+ setTimeout(_ => {
+ window.navigator.mediaSession.metadata.title = 'first timeout';
+ setTimeout(_ => {
+ window.navigator.mediaSession.metadata.title = 'second timeout';
+ });
+ });
+ });
+}, "test that MediaMetadata is correctly propagated twice");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698