Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: third_party/WebKit/LayoutTests/presentation/presentation-controller-connection-closed-by-receiver.html

Issue 2730123003: [Presentation API] Add layout test for connection.close() and fix test failures (Closed)
Patch Set: remove unnecessary forward declarations Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/presentation/presentation-controller-connection-closed-by-receiver.html
diff --git a/third_party/WebKit/LayoutTests/presentation/presentation-controller-connection-closed-by-receiver.html b/third_party/WebKit/LayoutTests/presentation/presentation-controller-connection-closed-by-receiver.html
new file mode 100644
index 0000000000000000000000000000000000000000..77020d1b6880b750195d6a755f7c7afb98c862d8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/presentation/presentation-controller-connection-closed-by-receiver.html
@@ -0,0 +1,48 @@
+<!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 controllerConnectionClosed = false;
+
+async_test(t => {
+ presentationServiceMock.then(service => {
+ // This is receiving the user gesture and runs the callback.
+ waitForClick(() => {
+ new PresentationRequest("https://example.com/").start().then(
+ connection => {
+ connection.onclose = (closeEvent) => {
+ assert_equals(closeEvent.reason, "closed");
+ assert_equals(closeEvent.message, "");
+ assert_equals(connection.state, "closed");
+ controllerConnectionClosed = true;
+ };
+ 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 = true;
+ };
+ });
+ }, button);
+ });
+
+ window.addEventListener("message", t.step_func(e => {
+ if (e.data == "receiver connection closed") {
+ assert_true(controllerConnectionClosed);
+ t.done();
+ }
+ }));
+}, "receiver connection.close() should fire both controller's and receiver's onclose event handler");
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698