Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7460)

Unified Diff: chrome/test/data/extensions/api_test/socket/api/background.js

Issue 10790137: Adds socket.getInfo to the socket API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Broke apart local/peer into localAddress,localPort peerAddress,peerPort, and updated the docs Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}
}

Powered by Google App Engine
This is Rietveld 408576698