| 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 controllerConnectionClosed = false; |
| 13 |
| 14 async_test(t => { |
| 15 presentationServiceMock.then(service => { |
| 16 // This is receiving the user gesture and runs the callback. |
| 17 waitForClick(() => { |
| 18 new PresentationRequest("http://example.com/").start().then( |
| 19 connection => { |
| 20 connection.onclose = () => { |
| 21 assert_equals(connection.state, "closed"); |
| 22 controllerConnectionClosed = true; |
| 23 }; |
| 24 connection.onconnect = () => { |
| 25 // Open a receiver page and pass controller connection's |
| 26 // controllerConnectionPtr and receiverConnectionRequest to it. |
| 27 w = window.open("resources/presentation-receiver-close-connection.ht
ml"); |
| 28 w.controllerConnectionPtr = service.getControllerConnectionPtr(); |
| 29 w.receiverConnectionRequest = service.getReceiverConnectionRequest()
; |
| 30 w.shouldCallClose = true; |
| 31 }; |
| 32 }); |
| 33 }, button); |
| 34 }); |
| 35 |
| 36 window.addEventListener("message", t.step_func(e => { |
| 37 if (e.data == "receiver connection closed") { |
| 38 assert_true(controllerConnectionClosed); |
| 39 t.done(); |
| 40 } |
| 41 })); |
| 42 }, "receiver connection.close() should fire both controller's and receiver's onc
lose event handler"); |
| 43 |
| 44 </script> |
| 45 </body> |
| 46 </html> |
| OLD | NEW |