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

Side by Side Diff: third_party/WebKit/LayoutTests/presentation/presentation-controller-close-connection.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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <script src="../resources/mojo-helpers.js"></script>
7 <script src="resources/presentation-service-mock.js"></script>
8 <button>click me</button>
9 <script>
10
11 var button = document.querySelector('button');
12 var receiverConnectionClosed = false;
13 var connection = null;
14
15 async_test(t => {
16 presentationServiceMock.then(service => {
17 // This is receiving the user gesture and runs the callback.
18 waitForClick(() => {
19 new PresentationRequest("https://example.com/").start().then(
20 theConnection => {
21 connection = theConnection;
22 connection.onclose = (closeEvent) => {
23 assert_equals(closeEvent.reason, "closed");
24 assert_equals(closeEvent.message, "");
25 assert_equals(connection.state, "closed");
26 assert_true(receiverConnectionClosed);
27 t.done();
28 };
29 connection.onconnect = () => {
30 // Open a receiver page and pass controller connection's
31 // controllerConnectionPtr and receiverConnectionRequest to it.
32 w = window.open("resources/presentation-receiver-close-connection.ht ml");
33 w.controllerConnectionPtr = service.getControllerConnectionPtr();
34 w.receiverConnectionRequest = service.getReceiverConnectionRequest() ;
35 w.shouldCallClose = false;
36 };
37 });
38 }, button);
39 });
40
41 window.addEventListener("message", t.step_func(e => {
42 if (e.data == "receiver connection closed") {
43 receiverConnectionClosed = true;
44 } else if (e.data == "receiver connection ready") {
45 assert_not_equals(connection, null);
46 connection.close();
47 }
48 }));
49 }, "controller connection.close() should fire both controller's and receiver's o nclose event handler");
50
51 </script>
52 </body>
53 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698