Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/presentation/presentation-controller-close-connection.html |
| diff --git a/third_party/WebKit/LayoutTests/presentation/presentation-controller-close-connection.html b/third_party/WebKit/LayoutTests/presentation/presentation-controller-close-connection.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8acf5c4faf403ff70f5556ed704235587313d384 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/presentation/presentation-controller-close-connection.html |
| @@ -0,0 +1,51 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<body> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../resources/mojo-helpers.js"></script> |
| +<script src="resources/presentation-service-mock.js"></script> |
| +<button>click me</button> |
| +<script> |
| + |
| +var button = document.querySelector('button'); |
| +var receiverConnectionClosed = false; |
| +var connection = null; |
| + |
| +async_test(t => { |
| + presentationServiceMock.then(service => { |
| + // This is receiving the user gesture and runs the callback. |
| + waitForClick(() => { |
| + new PresentationRequest("http://example.com/").start().then( |
|
mark a. foltz
2017/03/06 18:57:55
Nit: Use https: to reflect upcoming deprecation on
zhaobin
2017/03/06 19:52:23
Done.
|
| + theConnection => { |
| + connection = theConnection; |
| + connection.onclose = () => { |
| + assert_equals(connection.state, "closed"); |
|
imcheng
2017/03/04 00:58:28
Is there a specific reason / message we should be
mark a. foltz
2017/03/06 18:57:55
The message is only required for the "error" close
zhaobin
2017/03/06 19:52:23
Done.
|
| + assert_true(receiverConnectionClosed); |
| + t.done(); |
| + }; |
| + connection.onconnect = () => { |
| + // Open a receiver page and pass controller connection's |
| + // controllerConnectionPtr and receiverConnectionRequest to it. |
| + w = window.open("resources/presentation-receiver-close-connection.html"); |
| + w.controllerConnectionPtr = service.getControllerConnectionPtr(); |
| + w.receiverConnectionRequest = service.getReceiverConnectionRequest(); |
| + w.shouldCallClose = false; |
| + }; |
| + }); |
| + }, button); |
| + }); |
| + |
| + window.addEventListener("message", t.step_func(e => { |
| + if (e.data == "receiver connection closed") { |
| + receiverConnectionClosed = true; |
| + } else if (e.data == "receiver connection ready") { |
| + assert_not_equals(connection, null); |
| + connection.close(); |
| + } |
| + })); |
| +}, "controller connection.close() should fire both controller's and receiver's onclose event handler"); |
| + |
| +</script> |
| +</body> |
| +</html> |