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