| 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("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> |
| OLD | NEW |