Index: chrome/test/data/extensions/api_test/socket/api/background.js |
diff --git a/chrome/test/data/extensions/api_test/socket/api/background.js b/chrome/test/data/extensions/api_test/socket/api/background.js |
index 09e74dd4be7e79dc368a0f2cfbc7f1b8539730d9..85a44ab5478c3a9cd64640b9103ed898dd877f49 100644 |
--- a/chrome/test/data/extensions/api_test/socket/api/background.js |
+++ b/chrome/test/data/extensions/api_test/socket/api/background.js |
@@ -103,11 +103,37 @@ function onSetNoDelay(result) { |
socket.setKeepAlive(socketId, true, 1000, onSetKeepAlive); |
} |
+function onGetInfo(result) { |
+ chrome.test.assertTrue(!!result.localAddress, |
+ "Bound socket should always have local address"); |
+ chrome.test.assertTrue(!!result.localPort, |
+ "Bound socket should always have local port"); |
+ chrome.test.assertEq(result.socketType, protocol, "Unexpected socketType"); |
+ |
+ if (protocol == "tcp") { |
+ // NOTE: We're always called with 'localhost', but getInfo will only return |
+ // IPs, not names. |
+ chrome.test.assertEq(result.peerAddress, "127.0.0.1", |
+ "Peer addresss should be the listen server"); |
+ chrome.test.assertEq(result.peerPort, port, |
+ "Peer port should be the listen server"); |
+ chrome.test.assertTrue(result.connected, "Socket should be connected"); |
+ } else { |
+ chrome.test.assertFalse(result.connected, "UDP socket was not connected"); |
+ chrome.test.assertTrue(!result.peerAddress, |
+ "Unconnected UDP socket should not have peer address"); |
+ chrome.test.assertTrue(!result.peerPort, |
+ "Unconnected UDP socket should not have peer port"); |
+ } |
+ |
+ socket.setNoDelay(socketId, true, onSetNoDelay); |
+} |
+ |
function onConnectOrBindComplete(result) { |
chrome.test.assertEq(0, result, |
"Connect or bind failed with error " + result); |
if (result == 0) { |
- socket.setNoDelay(socketId, true, onSetNoDelay); |
+ socket.getInfo(socketId, onGetInfo); |
} |
} |