blob: fcd9817595f14d8d50cec1d134989cc408de0a39 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/third_party/blink/public/mojom/presentation/presentation.mojom.js"></script>
<script src="resources/presentation-service-mock.js"></script>
<button>click me</button>
<script>
async_test(t => {
const button = document.querySelector('button');
// This is receiving the user gesture and runs the callback.
waitForClick(() => {
new PresentationRequest('https://example.com').start().then(
connection => {
connection.onterminate = t.step_func_done();
connection.onconnect = () => {
connection.terminate();
};
// 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 = presentationServiceMock.getControllerConnectionPtr();
w.receiverConnectionRequest = presentationServiceMock.getReceiverConnectionRequest();
w.shouldCallClose = false;
});
}, button);
}, "Test that controller connection.terminate() fires onterminate event handler.");
</script>
</body>
</html>