blob: 51df848de5f01fa6d14b21b4031f5b3ea0fdc6ab [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>
var button = document.querySelector('button');
var controllerConnectionTerminated = false;
async_test(t => {
// This is receiving the user gesture and runs the callback.
waitForClick(() => {
new PresentationRequest("https://example.com/").start().then(
connection => {
connection.onterminate = () => {
assert_equals(connection.state, "terminated");
controllerConnectionTerminated = true;
};
// Open a receiver page and pass controller connection's
// controllerConnectionPtr and receiverConnectionRequest to it.
var w = window.open(
"resources/presentation-receiver-postmessage.html");
w.controllerConnectionPtr = presentationServiceMock.getControllerConnectionPtr();
w.receiverConnectionRequest = presentationServiceMock.getReceiverConnectionRequest();
});
}, button);
window.addEventListener("message", t.step_func(e => {
if (e.data == "passed" || e.data == "failed") {
assert_equals("passed", e.data, "Receiver connection is terminated!");
assert_true(controllerConnectionTerminated);
t.done();
}
}));
}, "receiver connection.terminate() should close receiver frame");
</script>
</body>
</html>