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

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: Adds tests 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..8dcd32ab4c1bb9262d4a53eae0a60bca6add1056 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,31 @@ function onSetNoDelay(result) {
socket.setKeepAlive(socketId, true, 1000, onSetKeepAlive);
}
+function onGetInfo(result) {
+ chrome.test.assertTrue(!!result.local,
+ "Bound socket should always have local part");
+ 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.peer, "127.0.0.1:" + port,
+ "Peer address was not 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.peer,
+ "Unconnected UDP socket must not have peer");
+ }
+
+ 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