| 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/mojo-helpers.js"></script> | 6 <script src="../resources/mojo-helpers.js"></script> |
| 7 <script src="resources/presentation-service-mock.js"></script> | 7 <script src="resources/presentation-service-mock.js"></script> |
| 8 <button>click me</button> | 8 <button>click me</button> |
| 9 <script> | 9 <script> |
| 10 | 10 |
| 11 function waitForClick(callback) { | |
| 12 var button = document.querySelector('button'); | |
| 13 button.addEventListener('click', callback, { once: true }); | |
| 14 | |
| 15 if (!('eventSender' in window)) | |
| 16 return; | |
| 17 | |
| 18 var boundingRect = button.getBoundingClientRect(); | |
| 19 var x = boundingRect.left + boundingRect.width / 2; | |
| 20 var y = boundingRect.top + boundingRect.height / 2; | |
| 21 | |
| 22 eventSender.mouseMoveTo(x, y); | |
| 23 eventSender.mouseDown(); | |
| 24 eventSender.mouseUp(); | |
| 25 } | |
| 26 | |
| 27 async_test(t => { | 11 async_test(t => { |
| 28 presentationServiceMock.then(t.step_func(mockService => { | 12 presentationServiceMock.then(t.step_func(mockService => { |
| 13 var button = document.querySelector('button'); |
| 29 // This is receiving the user gesture and runs the callback. | 14 // This is receiving the user gesture and runs the callback. |
| 30 waitForClick(t.step_func(_ => { | 15 waitForClick(t.step_func(_ => { |
| 31 new PresentationRequest('https://example.com').start().then( | 16 new PresentationRequest('https://example.com').start().then( |
| 32 t.step_func_done(result => { | 17 t.step_func_done(result => { |
| 33 var e = new PresentationConnectionAvailableEvent( | 18 var e = new PresentationConnectionAvailableEvent( |
| 34 'connectionavailable', { connection: result }); | 19 'connectionavailable', { connection: result }); |
| 35 assert_not_equals(e, null); | 20 assert_not_equals(e, null); |
| 36 assert_equals(e.connection, result); | 21 assert_equals(e.connection, result); |
| 37 })); | 22 })); |
| 38 })); | 23 }), button); |
| 39 })); | 24 })); |
| 40 }, "Test that the PresentationConnectionAvailableEvent ctor can take a valid Pre
sentationConnection.") | 25 }, "Test that the PresentationConnectionAvailableEvent ctor can take a valid Pre
sentationConnection.") |
| 41 | 26 |
| 42 </script> | 27 </script> |
| 43 </body> | 28 </body> |
| 44 </html> | 29 </html> |
| OLD | NEW |