| 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 4518b77315f8b74f527e789bb407ee8bd6e41523..e2ebc63bb0a009953aad7cac7e04115f8e1217af 100644 | 
| --- a/chrome/test/data/extensions/api_test/socket/api/background.js | 
| +++ b/chrome/test/data/extensions/api_test/socket/api/background.js | 
| @@ -185,6 +185,55 @@ var testSending = function() { | 
| socket.create(protocol, {}, onCreate); | 
| }; | 
|  | 
| +// Tests listening on a socket and sending/receiving from accepted sockets. | 
| +var testSocketListening = function() { | 
| +  var tmpSocketId = 0; | 
| + | 
| +  function onServerSocketAccept(acceptInfo) { | 
| +    chrome.test.assertEq(0, acceptInfo.resultCode); | 
| +    var acceptedSocketId = acceptInfo.socketId; | 
| +    socket.read(acceptedSocketId, function(readInfo) { | 
| +      arrayBuffer2String(readInfo.data, function(s) { | 
| +        var match = !!s.match(request); | 
| +        chrome.test.assertTrue(match, "Received data does not match."); | 
| +        succeeded = true; | 
| +        chrome.test.succeed(); | 
| +      }); | 
| +    }); | 
| +  } | 
| + | 
| +  function onListen(result) { | 
| +    chrome.test.assertEq(0, result, "Listen failed."); | 
| +    socket.accept(socketId, onServerSocketAccept); | 
| + | 
| +    // Create a new socket to connect to the TCP server. | 
| +    socket.create('tcp', {}, function(socketInfo) { | 
| +      tmpSocketId = socketInfo.socketId; | 
| +      socket.connect(tmpSocketId, address, port, | 
| +        function(result) { | 
| +          chrome.test.assertEq(0, result, "Connect failed"); | 
| + | 
| +          // Write. | 
| +          string2ArrayBuffer(request, function(buf) { | 
| +            socket.write(tmpSocketId, buf, function() {}); | 
| +          }); | 
| +        }); | 
| +    }); | 
| +  } | 
| + | 
| +  function onServerSocketBind(result) { | 
| +    chrome.test.assertEq(0, result, "Server socket bind failed."); | 
| +    socket.listen(socketId, 5, onListen); | 
| +  } | 
| + | 
| +  function onServerSocketCreate(socketInfo) { | 
| +    socketId = socketInfo.socketId; | 
| +    socket.bind(socketId, address, port, onServerSocketBind); | 
| +  } | 
| + | 
| +  socket.create('tcp', {}, onServerSocketCreate); | 
| +}; | 
| + | 
| var onMessageReply = function(message) { | 
| var parts = message.split(":"); | 
| protocol = parts[0]; | 
| @@ -192,7 +241,10 @@ var onMessageReply = function(message) { | 
| port = parseInt(parts[2]); | 
| console.log("Running tests, protocol " + protocol + ", echo server " + | 
| address + ":" + port); | 
| -  chrome.test.runTests([ testSocketCreation, testSending ]); | 
| +  if (protocol == 'tcp_server') | 
| +    chrome.test.runTests([ testSocketListening]); | 
| +  else | 
| +    chrome.test.runTests([ testSocketCreation, testSending ]); | 
| }; | 
|  | 
| // Find out which protocol we're supposed to test, and which echo server we | 
|  |