Chromium Code Reviews| OLD | NEW |
|---|---|
| (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("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.
| |
| 20 theConnection => { | |
| 21 connection = theConnection; | |
| 22 connection.onclose = () => { | |
| 23 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.
| |
| 24 assert_true(receiverConnectionClosed); | |
| 25 t.done(); | |
| 26 }; | |
| 27 connection.onconnect = () => { | |
| 28 // Open a receiver page and pass controller connection's | |
| 29 // controllerConnectionPtr and receiverConnectionRequest to it. | |
| 30 w = window.open("resources/presentation-receiver-close-connection.ht ml"); | |
| 31 w.controllerConnectionPtr = service.getControllerConnectionPtr(); | |
| 32 w.receiverConnectionRequest = service.getReceiverConnectionRequest() ; | |
| 33 w.shouldCallClose = false; | |
| 34 }; | |
| 35 }); | |
| 36 }, button); | |
| 37 }); | |
| 38 | |
| 39 window.addEventListener("message", t.step_func(e => { | |
| 40 if (e.data == "receiver connection closed") { | |
| 41 receiverConnectionClosed = true; | |
| 42 } else if (e.data == "receiver connection ready") { | |
| 43 assert_not_equals(connection, null); | |
| 44 connection.close(); | |
| 45 } | |
| 46 })); | |
| 47 }, "controller connection.close() should fire both controller's and receiver's o nclose event handler"); | |
| 48 | |
| 49 </script> | |
| 50 </body> | |
| 51 </html> | |
| OLD | NEW |