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..7d1ecca9c4337c2fe2c95f9b35e6013bab058a19 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/media/mediasession/mojo/media-control-action-reaches-client.html |
| @@ -0,0 +1,60 @@ |
| +<!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; |
| + |
| +var expectations = [ |
| + "play", |
| + "pause", |
| + "playpause", |
| + "previoustrack", |
| + "nexttrack", |
| + "seekforward", |
| + "seekbackward", |
| +]; |
| + |
| +var nextExpectation = 0; |
| + |
| +function checkExpectation(t, event) { |
| + var expectedEvent = expectations[nextExpectation]; |
| + assert_equals(expectedEvent, event.type); |
| + if (++nextExpectation >= expectations.length) |
| + t.done(); |
| +} |
| + |
| +function runTests(t) { |
| + window.navigator.mediaSession.onplay = t.step_func(checkExpectation.bind(null, t)); |
|
whywhat
2016/10/19 21:59:00
the order of parameters seems confusing: t should
Zhiqiang Zhang (Slow)
2016/10/21 14:52:45
Yes, "null" is for this
|
| + window.navigator.mediaSession.onpause = t.step_func(checkExpectation.bind(null, t)); |
| + window.navigator.mediaSession.onplaypause = t.step_func(checkExpectation.bind(null, t)); |
| + window.navigator.mediaSession.onprevioustrack = t.step_func(checkExpectation.bind(null, t)); |
| + window.navigator.mediaSession.onnexttrack = t.step_func(checkExpectation.bind(null, t)); |
| + window.navigator.mediaSession.onseekforward = t.step_func(checkExpectation.bind(null, t)); |
| + window.navigator.mediaSession.onseekbackward = t.step_func(checkExpectation.bind(null, t)); |
| + |
| + mock.getClient().didReceiveAction(MOJOM_ACTION_PLAY); |
| + mock.getClient().didReceiveAction(MOJOM_ACTION_PAUSE); |
| + mock.getClient().didReceiveAction(MOJOM_ACTION_PLAY_PAUSE); |
| + mock.getClient().didReceiveAction(MOJOM_ACTION_PREVIOUS_TRACK); |
| + mock.getClient().didReceiveAction(MOJOM_ACTION_NEXT_TRACK); |
| + mock.getClient().didReceiveAction(MOJOM_ACTION_SEEK_FORWARD); |
| + mock.getClient().didReceiveAction(MOJOM_ACTION_SEEK_BACKWARD); |
| +} |
| + |
| +// Use async_test to do asynchronous setup since setup() only works for |
| +// synchronous setup. |
| +async_test(function(t) { |
| + mediaSessionServiceMock.then(m => { |
| + mock = m; |
| + mock.setClientCallback(t.step_func(runTests.bind(null, t))); |
| + // Touch window.navigator.mediaSession to start the service. |
| + window.navigator.mediaSession.metadata = null; |
| + }); |
| +}, "test that the mock service is setup"); |
| + |
| +</script> |