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

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

Issue 15039012: Add the ability to use AllowAddressReuse for UDP sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master Created 7 years, 7 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
« no previous file with comments | « chrome/common/extensions/api/socket.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ]);
}
};
« no previous file with comments | « chrome/common/extensions/api/socket.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698