Chromium Code Reviews| 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 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 => { | |
| 28 presentationServiceMock.then(mockService => { | |
| 29 var connection = null; | |
| 30 var request = new PresentationRequest('https://example.com'); | |
| 31 | |
| 32 waitForClick(_ => { | |
| 33 request.start().then(conn => { | |
| 34 connection = conn; | |
| 35 assert_not_equals(connection, null); | |
| 36 assert_true(connection.state === 'connecting'); | |
| 37 | |
| 38 connection.onclose = (_ => { | |
| 39 request.reconnect(connection.id).then( | |
| 40 t.step_func_done(conn => { | |
| 41 assert_true(connection === conn); | |
| 42 assert_true(connection.state === 'connecting' || | |
| 43 connection.state === 'connected'); | |
| 44 }) | |
| 45 ); | |
| 46 }); | |
| 47 connection.close(); | |
|
zhaobin
2017/01/18 19:46:52
assert_true(connection.state === 'closed'); ?
takumif
2017/01/18 19:57:26
Added the check to the onclose callback, as the st
| |
| 48 }); | |
| 49 }); | |
| 50 }); | |
| 51 }, "Test that Presentation.reconnect() resolves with a closed presentation conne ction and updates its state."); | |
| 52 | |
| 53 </script> | |
| 54 </body> | |
| 55 </html> | |
| OLD | NEW |