Index: third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-set-handler-notifies-service.html |
diff --git a/third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-set-handler-notifies-service.html b/third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-set-handler-notifies-service.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..199092744acd4e25fd7b162fbfc2c474f721c3cc |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-set-handler-notifies-service.html |
@@ -0,0 +1,47 @@ |
+<!DOCTYPE html> |
+<title>MediaSession 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> |
+ |
+var expectations = [ |
+ [ "play", true ], |
+ [ "pause", false ], |
+ [ "playpause", true ], |
+ [ "previoustrack", false ], |
+ [ "nexttrack", true ], |
+ [ "seekforward", false ], |
+ [ "seekbackward", true ], |
+]; |
+ |
+var nextExpectation = 0; |
+ |
+async_test(function(t) { |
+ mediaSessionServiceMock.then(m => { |
+ m.setEventHandlerCallback(t.step_func(function(action, is_set) { |
+ var expectedAction = expectations[nextExpectation][0]; |
+ var expectedFlag = expectations[nextExpectation][1]; |
+ |
+ assert_equals(expectedAction, action); |
+ assert_equals(expectedFlag, is_set); |
+ if (++nextExpectation >= expectations.length) |
+ t.done(); |
+ })); |
+ |
+ // Unknown function should not be propagated. |
+ window.navigator.mediaSession.onresize = _ => {}; |
+ // MediaSession events should be propagated. |
+ window.navigator.mediaSession.onplay = _ => {}; |
+ window.navigator.mediaSession.onpause = null; |
+ window.navigator.mediaSession.onplaypause = _ => {}; |
+ window.navigator.mediaSession.onprevioustrack = null; |
+ window.navigator.mediaSession.onnexttrack = _ => {}; |
+ window.navigator.mediaSession.onseekforward = null; |
+ window.navigator.mediaSession.onseekbackward = _ => {}; |
+ }); |
+}, "test that setting event handler notifies the mojo service"); |
+ |
+</script> |