Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-action-reaches-client.html |
| diff --git a/third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-action-reaches-client.html b/third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-action-reaches-client.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..064b97f5ae3be8956d2ce010ecd393f66dec068a |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-action-reaches-client.html |
| @@ -0,0 +1,63 @@ |
| +<!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 mock; |
| + |
| +function runTests() { |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onplay = t.step_func_done(); |
| + mock.getClient().didReceivedAction(0); |
| + }, "test that onplay handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onpause = t.step_func_done(); |
| + mock.getClient().didReceivedAction(1); |
| + }, "test that onpause handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onplaypause = t.step_func_done(); |
| + mock.getClient().didReceivedAction(2); |
| + }, "test that onplaypause handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onprevioustrack = t.step_func_done(); |
| + mock.getClient().didReceivedAction(3); |
| + }, "test that onprevioustrack handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onnexttrack = t.step_func_done(); |
| + mock.getClient().didReceivedAction(4); |
| + }, "test that onnexttrack handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onseekforward = t.step_func_done(); |
| + mock.getClient().didReceivedAction(5); |
| + }, "test that onseekforward handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onseekbackward = t.step_func_done(); |
| + mock.getClient().didReceivedAction(6); |
| + }, "test that onseekbackward handler is notified correctly"); |
| + |
| +} |
| + |
| +// Use async_test to do asynchronous setup since setup() only works for |
| +// synchronous setup. |
| +async_test(function(t) { |
| + mediaSessionServiceMock.then(m => { |
| + mock = m; |
| + m.setClientCallback(t.step_func_done(_ => { |
|
whywhat
2016/10/18 21:02:57
it seems like you could just use t.step_func() her
Zhiqiang Zhang (Slow)
2016/10/19 12:52:06
I'm doing similar as the "set-handler-notifies-ser
|
| + runTests(); |
| + })); |
| + // Touch window.navigator.mediaSession to start the service. |
| + window.navigator.mediaSession.metadata = null; |
| + }); |
| +}, "test that the mock service is setup"); |
| + |
| +</script> |