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..afdbf332831111d80afff6ce31d202254c388bf7 |
| --- /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("play"); |
| + }, "test that onplay handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onpause = t.step_func_done(); |
| + mock.getClient().didReceivedAction("pause"); |
| + }, "test that onpause handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onplaypause = t.step_func_done(); |
| + mock.getClient().didReceivedAction("playpause"); |
| + }, "test that onplaypause handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onprevioustrack = t.step_func_done(); |
| + mock.getClient().didReceivedAction("previoustrack"); |
| + }, "test that onprevioustrack handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onnexttrack = t.step_func_done(); |
| + mock.getClient().didReceivedAction("nexttrack"); |
| + }, "test that onnexttrack handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onseekforward = t.step_func_done(); |
| + mock.getClient().didReceivedAction("seekforward"); |
| + }, "test that onseekforward handler is notified correctly"); |
| + |
| + async_test(function(t) { |
| + window.navigator.mediaSession.onseekbackward = t.step_func_done(); |
| + mock.getClient().didReceivedAction("seekbackward"); |
| + }, "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(_ => { |
| + runTests(); |
|
whywhat
2016/10/17 15:38:43
hm, does this really work?
Zhiqiang Zhang (Slow)
2016/10/17 21:17:39
Yes. It does work. Sadly I have to use async_test
|
| + })); |
| + // Touch window.navigator.mediaSession to start the service. |
| + window.navigator.mediaSession.metadata = null; |
| + }); |
| +}, "test that the mock service is setup"); |
| + |
| +</script> |