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

Unified Diff: third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-session-link.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-session-link.html
diff --git a/third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-session-link.html b/third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-session-link.html
new file mode 100644
index 0000000000000000000000000000000000000000..2741233c42149b915e2947c59e3ff717689176e6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/media/mediasession/mojo/metadata-session-link.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<title>MediaMetadata / MediaSession link 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',
+ }),
+ new MediaMetadata({
+ title: 'other',
+ }),
+ new MediaMetadata({
+ title: 'the right change',
+ }),
+ ];
+ 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.
+ var currentMetadata = new MediaMetadata({});
+ window.navigator.mediaSession.metadata = currentMetadata;
+
+ // `currentMetadata` is still associated to MediaSession.
+ currentMetadata.title = 'new title';
+
+ // De-associate them.
+ setTimeout(_ => {
+ // This change will trigger an asynchronous request for an update. It is
+ // Followed by another change that will prevent the former to work.
+ currentMetadata.title = 'should not be received';
+
+ var otherMetadata = new MediaMetadata({ title: 'other' });
+ window.navigator.mediaSession.metadata = otherMetadata;
+
+ // `currentMetadata` is no longer linked with the session so changes
+ // should have no effect.
+ currentMetadata.title = 'another attempt';
+
+ // This one will be received.
+ otherMetadata.title = 'the right change';
+ });
+ });
+}, "test that MediaMetadata is correctly propagated twice");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698