Backed out changeset a1d51e3fea63 (bug 935838) for B2G test_udpsocket.html timeouts.

CLOSED TREE

--HG--
extra : rebase_source : c38820b067a8faf405bfae7f5b5fb1089bd29bbc
This commit is contained in:
Ryan VanderMeulen 2015-03-09 16:35:06 -04:00
parent 4877857e68
commit 91323d7a02
20 changed files with 40 additions and 205 deletions

View File

@ -387,19 +387,8 @@ UDPSocket::InitLocal(const nsAString& aLocalAddress,
return rv;
}
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner(), &rv);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIPrincipal> principal = global->PrincipalOrNull();
if (!principal) {
return NS_ERROR_FAILURE;
}
if (aLocalAddress.IsEmpty()) {
rv = sock->Init(aLocalPort, /* loopback = */ false, principal,
mAddressReuse, /* optionalArgc = */ 1);
rv = sock->Init(aLocalPort, /* loopback = */ false, mAddressReuse, /* optionalArgc = */ 1);
} else {
PRNetAddr prAddr;
PR_InitializeNetAddr(PR_IpAddrAny, aLocalPort, &prAddr);
@ -407,8 +396,7 @@ UDPSocket::InitLocal(const nsAString& aLocalAddress,
mozilla::net::NetAddr addr;
PRNetAddrToNetAddr(&prAddr, &addr);
rv = sock->InitWithAddress(&addr, principal, mAddressReuse,
/* optionalArgc = */ 1);
rv = sock->InitWithAddress(&addr, mAddressReuse, /* optionalArgc = */ 1);
}
if (NS_FAILED(rv)) {
return rv;
@ -470,19 +458,7 @@ UDPSocket::InitRemote(const nsAString& aLocalAddress,
return rv;
}
nsCOMPtr<nsIGlobalObject> obj = do_QueryInterface(GetOwner(), &rv);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIPrincipal> principal = obj->PrincipalOrNull();
if (!principal) {
return NS_ERROR_FAILURE;
}
rv = sock->Bind(this, principal,
NS_ConvertUTF16toUTF8(aLocalAddress), aLocalPort,
mAddressReuse, mLoopback);
rv = sock->Bind(this, NS_ConvertUTF16toUTF8(aLocalAddress), aLocalPort, mAddressReuse, mLoopback);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -6,7 +6,6 @@
#include "mozilla/unused.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/net/NeckoChild.h"
#include "mozilla/dom/PermissionMessageUtils.h"
using mozilla::net::gNeckoChild;
@ -64,7 +63,6 @@ UDPSocketChild::~UDPSocketChild()
NS_IMETHODIMP
UDPSocketChild::Bind(nsIUDPSocketInternal* aSocket,
nsIPrincipal* aPrincipal,
const nsACString& aHost,
uint16_t aPort,
bool aAddressReuse,
@ -75,8 +73,7 @@ UDPSocketChild::Bind(nsIUDPSocketInternal* aSocket,
mSocket = aSocket;
AddIPDLReference();
gNeckoChild->SendPUDPSocketConstructor(this, IPC::Principal(aPrincipal),
mFilterName);
gNeckoChild->SendPUDPSocketConstructor(this, mFilterName);
SendBind(UDPAddressInfo(nsCString(aHost), aPort), aAddressReuse, aLoopback);
return NS_OK;

View File

@ -18,8 +18,6 @@
#include "nsNetUtil.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/TabParent.h"
#include "nsIPermissionManager.h"
#include "nsIScriptSecurityManager.h"
namespace mozilla {
namespace dom {
@ -67,46 +65,19 @@ UDPSocketParent::OfflineNotification(nsISupports *aSubject)
uint32_t
UDPSocketParent::GetAppId()
{
if (!mPrincipal) {
return nsIScriptSecurityManager::UNKNOWN_APP_ID;
}
uint32_t appId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
nsresult rv = mPrincipal->GetAppId(&appId);
if (NS_FAILED(rv)) {
appId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
const PContentParent *content = Manager()->Manager();
const InfallibleTArray<PBrowserParent*>& browsers = content->ManagedPBrowserParent();
if (browsers.Length() > 0) {
TabParent *tab = TabParent::GetFrom(browsers[0]);
appId = tab->OwnAppId();
}
return appId;
}
bool
UDPSocketParent::Init(const IPC::Principal& aPrincipal,
const nsACString& aFilter)
UDPSocketParent::Init(const nsACString& aFilter)
{
mPrincipal = aPrincipal;
if (net::UsingNeckoIPCSecurity() &&
mPrincipal &&
!ContentParent::IgnoreIPCPrincipal()) {
if (!AssertAppPrincipal(Manager()->Manager(), mPrincipal)) {
return false;
}
nsCOMPtr<nsIPermissionManager> permMgr =
services::GetPermissionManager();
if (!permMgr) {
NS_WARNING("No PermissionManager available!");
return false;
}
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestExactPermissionFromPrincipal(mPrincipal, "udp-socket",
&permission);
if (permission != nsIPermissionManager::ALLOW_ACTION) {
return false;
}
}
if (!aFilter.IsEmpty()) {
nsAutoCString contractId(NS_NETWORK_UDP_SOCKET_FILTER_HANDLER_PREFIX);
contractId.Append(aFilter);
@ -136,9 +107,10 @@ UDPSocketParent::RecvBind(const UDPAddressInfo& aAddressInfo,
{
// We don't have browser actors in xpcshell, and hence can't run automated
// tests without this loophole.
if (net::UsingNeckoIPCSecurity() && !mFilter) {
if (net::UsingNeckoIPCSecurity() && !mFilter &&
!AssertAppProcessPermission(Manager()->Manager(), "udp-socket")) {
FireInternalError(__LINE__);
return true;
return false;
}
if (NS_FAILED(BindInternal(aAddressInfo.addr(), aAddressInfo.port(), aAddressReuse, aLoopback))) {
@ -180,8 +152,7 @@ UDPSocketParent::BindInternal(const nsCString& aHost, const uint16_t& aPort,
}
if (aHost.IsEmpty()) {
rv = sock->Init(aPort, false, mPrincipal, aAddressReuse,
/* optional_argc = */ 1);
rv = sock->Init(aPort, false, aAddressReuse, /* optional_argc = */ 1);
} else {
PRNetAddr prAddr;
PR_InitializeNetAddr(PR_IpAddrAny, aPort, &prAddr);
@ -192,8 +163,7 @@ UDPSocketParent::BindInternal(const nsCString& aHost, const uint16_t& aPort,
mozilla::net::NetAddr addr;
PRNetAddrToNetAddr(&prAddr, &addr);
rv = sock->InitWithAddress(&addr, mPrincipal, aAddressReuse,
/* optional_argc = */ 1);
rv = sock->InitWithAddress(&addr, aAddressReuse, /* optional_argc = */ 1);
}
if (NS_WARN_IF(NS_FAILED(rv))) {

View File

@ -12,7 +12,6 @@
#include "nsIUDPSocket.h"
#include "nsIUDPSocketFilter.h"
#include "mozilla/net/OfflineObserver.h"
#include "mozilla/dom/PermissionMessageUtils.h"
namespace mozilla {
namespace dom {
@ -27,7 +26,7 @@ public:
UDPSocketParent();
bool Init(const IPC::Principal& aPrincipal, const nsACString& aFilter);
bool Init(const nsACString& aFilter);
virtual bool RecvBind(const UDPAddressInfo& aAddressInfo,
const bool& aAddressReuse, const bool& aLoopback) MOZ_OVERRIDE;
@ -58,7 +57,6 @@ private:
nsCOMPtr<nsIUDPSocket> mSocket;
nsCOMPtr<nsIUDPSocketFilter> mFilter;
nsRefPtr<mozilla::net::OfflineObserver> mObserver;
nsCOMPtr<nsIPrincipal> mPrincipal;
};
} // namespace dom

View File

@ -7,7 +7,6 @@
interface nsIUDPSocketInternal;
interface nsIInputStream;
interface nsIPrincipal;
%{ C++
namespace mozilla {
@ -19,7 +18,7 @@ union NetAddr;
native NetAddr(mozilla::net::NetAddr);
[ptr] native NetAddrPtr(mozilla::net::NetAddr);
[scriptable, uuid(d24536f1-dc03-4ef4-a347-647625def206)]
[scriptable, uuid(36ec5264-6a58-4cf2-ad9a-185292e0d1d1)]
interface nsIUDPSocketChild : nsISupports
{
readonly attribute unsigned short localPort;
@ -27,8 +26,7 @@ interface nsIUDPSocketChild : nsISupports
attribute AUTF8String filterName;
// Tell the chrome process to bind the UDP socket to a given local host and port
void bind(in nsIUDPSocketInternal socket, in nsIPrincipal principal,
in AUTF8String host, in unsigned short port,
void bind(in nsIUDPSocketInternal socket, in AUTF8String host, in unsigned short port,
in bool addressReuse, in bool loopback);
// Tell the chrome process to perform equivalent operations to all following methods

View File

@ -1684,7 +1684,7 @@ this.PushService = {
this._udpServer = Cc["@mozilla.org/network/udp-socket;1"]
.createInstance(Ci.nsIUDPSocket);
this._udpServer.init(-1, false, Services.scriptSecurityManager.getSystemPrincipal());
this._udpServer.init(-1, false);
this._udpServer.asyncListen(this);
debug("listenForUDPWakeup listening on " + this._udpServer.port);

View File

@ -1078,7 +1078,7 @@ void NrSocketIpc::create_m(const nsACString &host, const uint16_t port) {
return;
}
if (NS_FAILED(socket_child_->Bind(proxy, nullptr, host, port,
if (NS_FAILED(socket_child_->Bind(proxy, host, port,
/* reuse = */ false,
/* loopback = */ false))) {
err_ = true;

View File

@ -11,7 +11,6 @@ interface nsIUDPMessage;
interface nsISocketTransport;
interface nsIOutputStream;
interface nsIInputStream;
interface nsIPrincipal;
%{ C++
#include "nsTArrayForwardDeclare.h"
@ -30,7 +29,7 @@ native NetAddr(mozilla::net::NetAddr);
*
* An interface to a UDP socket that can accept incoming connections.
*/
[scriptable, uuid(e0377f7b-34a9-4d0f-8191-7e0cba77a52f)]
[scriptable, uuid(8f28299c-f2ac-468a-8223-190335006bbc)]
interface nsIUDPSocket : nsISupports
{
/**
@ -46,16 +45,11 @@ interface nsIUDPSocket : nsISupports
* local loopback interface. Otherwise, it will accept connections
* from any interface. To specify a particular network interface,
* use initWithAddress.
* @param aPrincipal
* The principal connected to this socket.
* @param aAddressReuse
* If true, the socket is allowed to be bound to an address that is
* already in use. Default is true.
*/
[optional_argc] void init(in long aPort,
in boolean aLoopbackOnly,
in nsIPrincipal aPrincipal,
[optional] in boolean aAddressReuse);
[optional_argc] void init(in long aPort, in boolean aLoopbackOnly, [optional] in boolean aAddressReuse);
/**
* initWithAddress
@ -65,15 +59,11 @@ interface nsIUDPSocket : nsISupports
*
* @param aAddr
* The address to which this UDP socket should be bound.
* @param aPrincipal
* The principal connected to this socket.
* @param aAddressReuse
* If true, the socket is allowed to be bound to an address that is
* already in use. Default is true.
*/
[noscript, optional_argc] void initWithAddress([const] in NetAddrPtr aAddr,
in nsIPrincipal aPrincipal,
[optional] in boolean aAddressReuse);
[noscript, optional_argc] void initWithAddress([const] in NetAddrPtr aAddr, [optional] in boolean aAddressReuse);
/**
* close

View File

@ -14,7 +14,6 @@
#include "nsAutoPtr.h"
#include "nsError.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "prnetdb.h"
#include "prio.h"
#include "nsNetAddr.h"
@ -28,10 +27,6 @@
#include "nsIDNSService.h"
#include "nsICancelable.h"
#ifdef MOZ_WIDGET_GONK
#include "NetStatistics.h"
#endif
using namespace mozilla::net;
using namespace mozilla;
@ -259,8 +254,6 @@ nsUDPMessage::GetDataAsTArray()
nsUDPSocket::nsUDPSocket()
: mLock("nsUDPSocket.mLock")
, mFD(nullptr)
, mAppId(NECKO_UNKNOWN_APP_ID)
, mIsInBrowserElement(false)
, mAttached(false)
, mByteReadCount(0)
, mByteWriteCount(0)
@ -293,7 +286,6 @@ void
nsUDPSocket::AddOutputBytes(uint64_t aBytes)
{
mByteWriteCount += aBytes;
SaveNetworkStats(false);
}
void
@ -481,7 +473,6 @@ nsUDPSocket::OnSocketReady(PRFileDesc *fd, int16_t outFlags)
return;
}
mByteReadCount += count;
SaveNetworkStats(false);
FallibleTArray<uint8_t> data;
if(!data.AppendElements(buff, count)){
@ -529,7 +520,6 @@ nsUDPSocket::OnSocketDetached(PRFileDesc *fd)
PR_Close(mFD);
mFD = nullptr;
}
SaveNetworkStats(true);
if (mListener)
{
@ -566,8 +556,7 @@ NS_IMPL_ISUPPORTS(nsUDPSocket, nsIUDPSocket)
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsUDPSocket::Init(int32_t aPort, bool aLoopbackOnly, nsIPrincipal *aPrincipal,
bool aAddressReuse, uint8_t aOptionalArgc)
nsUDPSocket::Init(int32_t aPort, bool aLoopbackOnly, bool aAddressReuse, uint8_t aOptionalArgc)
{
NetAddr addr;
@ -582,12 +571,11 @@ nsUDPSocket::Init(int32_t aPort, bool aLoopbackOnly, nsIPrincipal *aPrincipal,
else
addr.inet.ip = htonl(INADDR_ANY);
return InitWithAddress(&addr, aPrincipal, aAddressReuse, aOptionalArgc);
return InitWithAddress(&addr, aAddressReuse, aOptionalArgc);
}
NS_IMETHODIMP
nsUDPSocket::InitWithAddress(const NetAddr *aAddr, nsIPrincipal *aPrincipal,
bool aAddressReuse, uint8_t aOptionalArgc)
nsUDPSocket::InitWithAddress(const NetAddr *aAddr, bool aAddressReuse, uint8_t aOptionalArgc)
{
NS_ENSURE_TRUE(mFD == nullptr, NS_ERROR_ALREADY_INITIALIZED);
@ -604,27 +592,6 @@ nsUDPSocket::InitWithAddress(const NetAddr *aAddr, nsIPrincipal *aPrincipal,
return NS_ERROR_FAILURE;
}
if (aPrincipal) {
nsresult rv = aPrincipal->GetAppId(&mAppId);
if (NS_FAILED(rv)) {
return rv;
}
rv = aPrincipal->GetIsInBrowserElement(&mIsInBrowserElement);
if (NS_FAILED(rv)) {
return rv;
}
}
#ifdef MOZ_WIDGET_GONK
if (mAppId != NECKO_UNKNOWN_APP_ID) {
nsCOMPtr<nsINetworkInterface> activeNetwork;
GetActiveNetworkInterface(activeNetwork);
mActiveNetwork =
new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
}
#endif
uint16_t port;
if (NS_FAILED(net::GetPort(aAddr, &port))) {
NS_WARNING("invalid bind address");
@ -691,7 +658,6 @@ nsUDPSocket::Close()
PR_Close(mFD);
mFD = nullptr;
}
SaveNetworkStats(true);
return NS_OK;
}
}
@ -727,34 +693,6 @@ nsUDPSocket::GetAddress(NetAddr *aResult)
return NS_OK;
}
void
nsUDPSocket::SaveNetworkStats(bool aEnforce)
{
#ifdef MOZ_WIDGET_GONK
if (!mActiveNetwork || mAppId == NECKO_UNKNOWN_APP_ID) {
return;
}
if (mByteReadCount == 0 && mByteWriteCount == 0) {
return;
}
uint64_t total = mByteReadCount + mByteWriteCount;
if (aEnforce || total > NETWORK_STATS_THRESHOLD) {
// Create the event to save the network statistics.
// the event is then dispathed to the main thread.
nsRefPtr<nsRunnable> event =
new SaveNetworkStatsEvent(mAppId, mIsInBrowserElement, mActiveNetwork,
mByteReadCount, mByteWriteCount, false);
NS_DispatchToMainThread(event);
// Reset the counters after saving.
mByteReadCount = 0;
mByteWriteCount = 0;
}
#endif
}
namespace {
//-----------------------------------------------------------------------------
// SocketListenerProxy

View File

@ -12,10 +12,6 @@
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
#endif
//-----------------------------------------------------------------------------
class nsUDPSocket MOZ_FINAL : public nsASocketHandler
@ -54,15 +50,11 @@ private:
const PRNetAddr& aIface);
nsresult SetMulticastInterfaceInternal(const PRNetAddr& aIface);
void SaveNetworkStats(bool aEnforce);
// lock protects access to mListener;
// so mListener is not cleared while being used/locked.
mozilla::Mutex mLock;
PRFileDesc *mFD;
mozilla::net::NetAddr mAddr;
uint32_t mAppId;
bool mIsInBrowserElement;
nsCOMPtr<nsIUDPSocketListener> mListener;
nsCOMPtr<nsIEventTarget> mListenerTarget;
bool mAttached;
@ -70,9 +62,6 @@ private:
uint64_t mByteReadCount;
uint64_t mByteWriteCount;
#ifdef MOZ_WIDGET_GONK
nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
#endif
};
//-----------------------------------------------------------------------------

View File

@ -237,8 +237,7 @@ NeckoChild::DeallocPTCPServerSocketChild(PTCPServerSocketChild* child)
}
PUDPSocketChild*
NeckoChild::AllocPUDPSocketChild(const Principal& aPrincipal,
const nsCString& aFilter)
NeckoChild::AllocPUDPSocketChild(const nsCString& aFilter)
{
NS_NOTREACHED("AllocPUDPSocket should not be called");
return nullptr;

View File

@ -51,8 +51,7 @@ protected:
const uint16_t& aBacklog,
const nsString& aBinaryType) MOZ_OVERRIDE;
virtual bool DeallocPTCPServerSocketChild(PTCPServerSocketChild*) MOZ_OVERRIDE;
virtual PUDPSocketChild* AllocPUDPSocketChild(const Principal& aPrincipal,
const nsCString& aFilter) MOZ_OVERRIDE;
virtual PUDPSocketChild* AllocPUDPSocketChild(const nsCString& aFilter) MOZ_OVERRIDE;
virtual bool DeallocPUDPSocketChild(PUDPSocketChild*) MOZ_OVERRIDE;
virtual PDNSRequestChild* AllocPDNSRequestChild(const nsCString& aHost,
const uint32_t& aFlags,

View File

@ -455,8 +455,7 @@ NeckoParent::DeallocPTCPServerSocketParent(PTCPServerSocketParent* actor)
}
PUDPSocketParent*
NeckoParent::AllocPUDPSocketParent(const Principal& /* unused */,
const nsCString& /* unused */)
NeckoParent::AllocPUDPSocketParent(const nsCString& /* unused */)
{
nsRefPtr<UDPSocketParent> p = new UDPSocketParent();
@ -465,10 +464,9 @@ NeckoParent::AllocPUDPSocketParent(const Principal& /* unused */,
bool
NeckoParent::RecvPUDPSocketConstructor(PUDPSocketParent* aActor,
const Principal& aPrincipal,
const nsCString& aFilter)
{
return static_cast<UDPSocketParent*>(aActor)->Init(aPrincipal, aFilter);
return static_cast<UDPSocketParent*>(aActor)->Init(aFilter);
}
bool

View File

@ -149,11 +149,8 @@ protected:
const uint16_t& aBacklog,
const nsString& aBinaryType) MOZ_OVERRIDE;
virtual bool DeallocPTCPServerSocketParent(PTCPServerSocketParent*) MOZ_OVERRIDE;
virtual PUDPSocketParent* AllocPUDPSocketParent(const Principal& aPrincipal,
const nsCString& aFilter) MOZ_OVERRIDE;
virtual bool RecvPUDPSocketConstructor(PUDPSocketParent*,
const Principal& aPrincipal,
const nsCString& aFilter) MOZ_OVERRIDE;
virtual PUDPSocketParent* AllocPUDPSocketParent(const nsCString& aFilter) MOZ_OVERRIDE;
virtual bool RecvPUDPSocketConstructor(PUDPSocketParent*, const nsCString& aFilter) MOZ_OVERRIDE;
virtual bool DeallocPUDPSocketParent(PUDPSocketParent*) MOZ_OVERRIDE;
virtual PDNSRequestParent* AllocPDNSRequestParent(const nsCString& aHost,
const uint32_t& aFlags,

View File

@ -30,7 +30,6 @@ include PBrowserOrId;
using class IPC::SerializedLoadContext from "SerializedLoadContext.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
namespace mozilla {
namespace net {
@ -66,7 +65,7 @@ parent:
PWebSocket(PBrowserOrId browser, SerializedLoadContext loadContext);
PTCPServerSocket(uint16_t localPort, uint16_t backlog, nsString binaryType);
PUDPSocket(Principal principal, nsCString filter);
PUDPSocket(nsCString filter);
PDNSRequest(nsCString hostName, uint32_t flags, nsCString networkInterface);

View File

@ -11,7 +11,6 @@
#include "nsIInputStream.h"
#include "nsINetAddr.h"
#include "nsITimer.h"
#include "nsNetUtil.h"
#include "mozilla/net/DNS.h"
#include "prerror.h"
@ -273,16 +272,8 @@ main(int32_t argc, char *argv[])
// Create UDPServerListener to process UDP packets
nsRefPtr<UDPServerListener> serverListener = new UDPServerListener();
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, -1);
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
NS_ENSURE_SUCCESS(rv, -1);
// Bind server socket to 0.0.0.0
rv = server->Init(0, false, systemPrincipal, true, 0);
rv = server->Init(0, false, true, 0);
NS_ENSURE_SUCCESS(rv, -1);
int32_t serverPort;
server->GetPort(&serverPort);
@ -290,7 +281,7 @@ main(int32_t argc, char *argv[])
// Bind clinet on arbitrary port
nsRefPtr<UDPClientListener> clientListener = new UDPClientListener();
client->Init(0, false, systemPrincipal, true, 0);
client->Init(0, false, true, 0);
client->AsyncListen(clientListener);
// Write data to server

View File

@ -6,7 +6,6 @@ const UDPSocket = CC("@mozilla.org/network/udp-socket;1",
"nsIUDPSocket",
"init");
const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
Cu.import("resource://gre/modules/Services.jsm");
const ADDRESS_TEST1 = "224.0.0.200";
const ADDRESS_TEST2 = "224.0.0.201";
@ -33,8 +32,7 @@ function setup() {
}
function createSocketAndJoin(addr) {
let socket = new UDPSocket(-1, false,
Services.scriptSecurityManager.getSystemPrincipal());
let socket = new UDPSocket(-1, false);
socket.joinMulticast(addr);
return socket;
}

View File

@ -4,8 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
Cu.import("resource://gre/modules/Services.jsm");
const HELLO_WORLD = "Hello World";
add_test(function test_udp_message_raw_data() {
@ -13,7 +11,7 @@ add_test(function test_udp_message_raw_data() {
let socket = Cc["@mozilla.org/network/udp-socket;1"].createInstance(Ci.nsIUDPSocket);
socket.init(-1, true, Services.scriptSecurityManager.getSystemPrincipal());
socket.init(-1, true);
do_print("Port assigned : " + socket.port);
socket.asyncListen({
QueryInterface : XPCOMUtils.generateQI([Ci.nsIUDPSocketListener]),
@ -40,7 +38,7 @@ add_test(function test_udp_send_stream() {
let socket = Cc["@mozilla.org/network/udp-socket;1"].createInstance(Ci.nsIUDPSocket);
socket.init(-1, true, Services.scriptSecurityManager.getSystemPrincipal());
socket.init(-1, true);
socket.asyncListen({
QueryInterface : XPCOMUtils.generateQI([Ci.nsIUDPSocketListener]),
onPacketReceived : function(aSocket, aMessage){

View File

@ -78,7 +78,7 @@ function log(msg) {
function Transport(port) {
EventEmitter.decorate(this);
try {
this.socket = new UDPSocket(port, false, Services.scriptSecurityManager.getSystemPrincipal());
this.socket = new UDPSocket(port, false);
this.socket.joinMulticast(ADDRESS);
this.socket.asyncListen(this);
} catch(e) {

View File

@ -144,7 +144,7 @@ var SimpleServiceDiscovery = {
// Perform a UDP broadcast to search for SSDP devices
let socket = Cc["@mozilla.org/network/udp-socket;1"].createInstance(Ci.nsIUDPSocket);
try {
socket.init(SSDP_PORT, false, Services.scriptSecurityManager.getSystemPrincipal());
socket.init(SSDP_PORT, false);
socket.joinMulticast(SSDP_ADDRESS);
socket.asyncListen(this);
} catch (e) {