| 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 5b3b425806a4ebd05b7c0ca2559868cfbb17e2c5..4bf47265fd07526c192a97f9d6621ad96fee2b08 100644
|
| --- a/chrome/test/data/extensions/api_test/socket/api/background.js
|
| +++ b/chrome/test/data/extensions/api_test/socket/api/background.js
|
| @@ -70,6 +70,59 @@ var testSocketCreation = function() {
|
| };
|
|
|
|
|
| +var testAllowAddressReuseUDP = function() {
|
| + var otherSocketId = null;
|
| + function onCreate(socketInfo) {
|
| + function onAllowAddressReuse(result) {
|
| + function onBind(result) {
|
| + chrome.test.assertEq(
|
| + 0, result,
|
| + "Bind for " + (otherSocketId ? "second" : "first") + " socket " +
|
| + "failed with error code " + result);
|
| +
|
| + if (otherSocketId) {
|
| + socket.destroy(socketInfo.socketId);
|
| + socket.destroy(otherSocketId);
|
| + otherSocketId = null;
|
| + chrome.test.succeed();
|
| + } else {
|
| + otherSocketId = socketInfo.socketId;
|
| + }
|
| + }
|
| +
|
| + chrome.test.assertEq(
|
| + 0, result,
|
| + "AllowAddressReuse failed with " + result);
|
| + socket.bind(socketInfo.socketId, "127.0.0.1", 9999, onBind);
|
| + }
|
| +
|
| + chrome.test.assertTrue(socketInfo.socketId > 0);
|
| + socket.allowAddressReuse(socketInfo.socketId, onAllowAddressReuse);
|
| + }
|
| +
|
| + socket.create(protocol, {}, onCreate);
|
| + socket.create(protocol, {}, onCreate);
|
| +};
|
| +
|
| +var testAllowAddressReuseTCP = function() {
|
| + var otherSocketId = null;
|
| + function onCreate(socketInfo) {
|
| + function onAllowAddressReuse(result) {
|
| + chrome.test.assertTrue(result < 0);
|
| + chrome.test.succeed();
|
| + }
|
| + chrome.test.assertTrue(socketInfo.socketId > 0);
|
| + socket.allowAddressReuse(socketInfo.socketId, onAllowAddressReuse);
|
| + }
|
| +
|
| + socket.create(protocol, {}, onCreate);
|
| +};
|
| +
|
| +var testAllowAddressReuse = function() {
|
| + if (protocol == "tcp") testAllowAddressReuseTCP();
|
| + else testAllowAddressReuseUDP();
|
| +};
|
| +
|
| var testGetInfo = function() {
|
| };
|
|
|
| @@ -245,7 +298,8 @@ var onMessageReply = function(message) {
|
| chrome.test.runTests([ testMulticast ]);
|
| } else {
|
| protocol = test_type;
|
| - chrome.test.runTests([ testSocketCreation, testSending ]);
|
| + chrome.test.runTests([ testSocketCreation, testSending,
|
| + testAllowAddressReuse ]);
|
| }
|
| };
|
|
|
|
|