| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <body> | 3 <body> |
| 4 <script src="../resources/testharness.js"></script> | 4 <script src="../resources/testharness.js"></script> |
| 5 <script src="../resources/testharnessreport.js"></script> | 5 <script src="../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/gc.js"></script> | 6 <script src="../resources/gc.js"></script> |
| 7 <script src="../resources/mojo-helpers.js"></script> | 7 <script src="../resources/mojo-helpers.js"></script> |
| 8 <script src="resources/presentation-service-mock.js"></script> | 8 <script src="resources/presentation-service-mock.js"></script> |
| 9 <button>click me</button> | 9 <button>click me</button> |
| 10 <script> | 10 <script> |
| 11 | 11 |
| 12 function waitForClick(callback) { | |
| 13 var button = document.querySelector('button'); | |
| 14 button.addEventListener('click', callback, { once: true }); | |
| 15 | |
| 16 if (!('eventSender' in window)) | |
| 17 return; | |
| 18 | |
| 19 var boundingRect = button.getBoundingClientRect(); | |
| 20 var x = boundingRect.left + boundingRect.width / 2; | |
| 21 var y = boundingRect.top + boundingRect.height / 2; | |
| 22 | |
| 23 eventSender.mouseMoveTo(x, y); | |
| 24 eventSender.mouseDown(); | |
| 25 eventSender.mouseUp(); | |
| 26 } | |
| 27 | |
| 28 async_test(t => { | 12 async_test(t => { |
| 29 presentationServiceMock.then(mockService => { | 13 presentationServiceMock.then(mockService => { |
| 14 var button = document.querySelector('button'); |
| 30 var connection = null; | 15 var connection = null; |
| 31 var request = new PresentationRequest('https://example.com'); | 16 var request = new PresentationRequest('https://example.com'); |
| 32 | 17 |
| 33 waitForClick(_ => { | 18 waitForClick(_ => { |
| 34 request.start().then(conn => { | 19 request.start().then(conn => { |
| 35 connection = conn; | 20 connection = conn; |
| 36 assert_not_equals(connection, null); | 21 assert_not_equals(connection, null); |
| 37 | 22 |
| 38 request.reconnect(connection.id).then( | 23 request.reconnect(connection.id).then( |
| 39 t.step_func_done(conn => { | 24 t.step_func_done(conn => { |
| 40 assert_true(connection === conn); | 25 assert_true(connection === conn); |
| 41 })); | 26 })); |
| 42 }); | 27 }); |
| 43 }); | 28 }, button); |
| 44 }); | 29 }); |
| 45 }, "Test that Presentation.reconnect() resolves with existing presentation conne
ction."); | 30 }, "Test that Presentation.reconnect() resolves with existing presentation conne
ction."); |
| 46 | 31 |
| 47 </script> | 32 </script> |
| 48 </body> | 33 </body> |
| 49 </html> | 34 </html> |
| OLD | NEW |