| 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/mojo-helpers.js"></script> | 5 <script src="../../resources/mojo-helpers.js"></script> |
| 6 <script src="presentation-service-mock.js"></script> | 6 <script src="presentation-service-mock.js"></script> |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 // Parent window sets parameter for this page. | 9 // Parent window sets parameter for this page. |
| 10 assert_not_equals(controllerConnectionPtr, null); | 10 assert_not_equals(controllerConnectionPtr, null); |
| 11 assert_not_equals(receiverConnectionRequest, null); | 11 assert_not_equals(receiverConnectionRequest, null); |
| 12 assert_not_equals(shouldCallClose, null); | 12 assert_not_equals(shouldCallClose, null); |
| 13 | 13 |
| 14 internals.settings.setPresentationReceiver(true); | 14 internals.settings.setPresentationReceiver(true); |
| 15 | 15 |
| 16 presentationServiceMock.then(mockService => { | 16 presentationServiceMock.then(mockService => { |
| 17 const url = 'http://example.com/a.html'; | 17 const url = 'http://example.com/a.html'; |
| 18 const id = 'fakeSessionId'; | 18 const id = 'fakeSessionId'; |
| 19 | 19 |
| 20 mockService.onSetClient = () => { | 20 mockService.onSetClient = () => { |
| 21 mockService.onReceiverConnectionAvailable( | 21 mockService.onReceiverConnectionAvailable( |
| 22 url, id, controllerConnectionPtr, receiverConnectionRequest); | 22 url, id, controllerConnectionPtr, receiverConnectionRequest); |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 navigator.presentation.receiver.connectionList.then(list => { | 25 navigator.presentation.receiver.connectionList.then(list => { |
| 26 assert_equals(list.connections.length, 1); | 26 assert_equals(list.connections.length, 1); |
| 27 const connection = list.connections[0]; | 27 const connection = list.connections[0]; |
| 28 connection.onclose = () => { | 28 connection.onclose = () => { |
| 29 assert_equals(connection.state, 'closed'); | 29 assert_equals(connection.state, 'closed'); |
| 30 opener.postMessage('receiver connection closed', '*'); | 30 setTimeout(() => { |
| 31 assert_equals(list.connections.length, 0); |
| 32 opener.postMessage('receiver connection closed', '*'); |
| 33 } ,0); |
| 31 }; | 34 }; |
| 32 opener.postMessage('receiver connection ready', '*'); | 35 opener.postMessage('receiver connection ready', '*'); |
| 33 if (shouldCallClose) { | 36 if (shouldCallClose) { |
| 34 connection.close(); | 37 list.connections.forEach(theConnection => { |
| 38 theConnection.close(); |
| 39 }); |
| 35 } | 40 } |
| 36 }); | 41 }); |
| 37 }); | 42 }); |
| 38 | 43 |
| 39 window.onunload = () => { | 44 window.onunload = () => { |
| 40 internals.settings.setPresentationReceiver(false); | 45 internals.settings.setPresentationReceiver(false); |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 </script> | 48 </script> |
| 44 </body> | 49 </body> |
| 45 </html> | 50 </html> |
| OLD | NEW |