Backed out 3 changesets (bug 1234492) for frequent OSX test_presentation_dc_receiver.html failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sun, 24 Apr 2016 18:50:55 -0400
changeset 332595 18ff4b609573846d75245079f8e18e2a584ee89d
parent 332594 a4845199b1bbe3391d6d2bf6925cdb368cb09345
child 332596 8fd689511059100897e7a13cde1cd7f3809c9b80
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1234492
milestone48.0a1
backs out94ec70bf8c2297109611568159521fd8dfb3a98c
ac0e65743b5d8b64d22d7676f9f652d0c54076ff
801cac365dd931fd04d02fcae3dc5bc0c966f323
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 3 changesets (bug 1234492) for frequent OSX test_presentation_dc_receiver.html failures. Backed out changeset 94ec70bf8c22 (bug 1234492) Backed out changeset ac0e65743b5d (bug 1234492) Backed out changeset 801cac365dd9 (bug 1234492)
dom/ipc/ContentChild.cpp
dom/presentation/PresentationCallbacks.cpp
dom/presentation/PresentationConnection.cpp
dom/presentation/PresentationConnection.h
dom/presentation/PresentationDataChannelSessionTransport.js
dom/presentation/PresentationReceiver.cpp
dom/presentation/PresentationService.cpp
dom/presentation/PresentationService.h
dom/presentation/PresentationSessionInfo.cpp
dom/presentation/PresentationSessionInfo.h
dom/presentation/PresentationTCPSessionTransport.cpp
dom/presentation/PresentationTCPSessionTransport.h
dom/presentation/interfaces/nsIPresentationService.idl
dom/presentation/interfaces/nsIPresentationSessionTransportBuilder.idl
dom/presentation/ipc/PPresentation.ipdl
dom/presentation/ipc/PresentationIPCService.cpp
dom/presentation/ipc/PresentationParent.cpp
dom/presentation/ipc/PresentationParent.h
dom/presentation/tests/mochitest/PresentationSessionChromeScript.js
dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js
dom/presentation/tests/mochitest/file_presentation_1ua_receiver.html
dom/presentation/tests/mochitest/file_presentation_1ua_receiver_oop.html
dom/presentation/tests/mochitest/mochitest.ini
dom/presentation/tests/mochitest/test_presentation_1ua_sender_and_receiver.html
dom/presentation/tests/mochitest/test_presentation_1ua_sender_and_receiver_oop.html
dom/presentation/tests/mochitest/test_presentation_datachannel_sessiontransport.html
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1704,17 +1704,17 @@ ContentChild::RecvNotifyPresentationRece
 
 bool
 ContentChild::RecvNotifyPresentationReceiverCleanUp(const nsString& aSessionId)
 {
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   NS_WARN_IF(!service);
 
-  NS_WARN_IF(NS_FAILED(service->UntrackSessionInfo(aSessionId, nsIPresentationService::ROLE_RECEIVER)));
+  NS_WARN_IF(NS_FAILED(service->UntrackSessionInfo(aSessionId)));
 
   return true;
 }
 
 bool
 ContentChild::RecvNotifyGMPsChanged()
 {
   GMPDecoderModule::UpdateUsableCodecs();
--- a/dom/presentation/PresentationCallbacks.cpp
+++ b/dom/presentation/PresentationCallbacks.cpp
@@ -45,17 +45,16 @@ NS_IMETHODIMP
 PresentationRequesterCallback::NotifySuccess()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // At the sender side, this function must get called after the transport
   // channel is ready. So we simply set the connection state as connected.
   RefPtr<PresentationConnection> connection =
     PresentationConnection::Create(mRequest->GetOwner(), mSessionId,
-                                   nsIPresentationService::ROLE_CONTROLLER,
                                    PresentationConnectionState::Connected);
   if (NS_WARN_IF(!connection)) {
     mPromise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR);
     return NS_OK;
   }
 
   mPromise->MaybeResolve(connection);
 
--- a/dom/presentation/PresentationConnection.cpp
+++ b/dom/presentation/PresentationConnection.cpp
@@ -30,75 +30,68 @@ NS_IMPL_ADDREF_INHERITED(PresentationCon
 NS_IMPL_RELEASE_INHERITED(PresentationConnection, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PresentationConnection)
   NS_INTERFACE_MAP_ENTRY(nsIPresentationSessionListener)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 PresentationConnection::PresentationConnection(nsPIDOMWindowInner* aWindow,
                                                const nsAString& aId,
-                                               const uint8_t aRole,
                                                PresentationConnectionState aState)
   : DOMEventTargetHelper(aWindow)
   , mId(aId)
   , mState(aState)
 {
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
-  mRole = aRole;
 }
 
 /* virtual */ PresentationConnection::~PresentationConnection()
 {
 }
 
 /* static */ already_AddRefed<PresentationConnection>
 PresentationConnection::Create(nsPIDOMWindowInner* aWindow,
                                const nsAString& aId,
-                               const uint8_t aRole,
                                PresentationConnectionState aState)
 {
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
   RefPtr<PresentationConnection> connection =
-    new PresentationConnection(aWindow, aId, aRole, aState);
+    new PresentationConnection(aWindow, aId, aState);
   return NS_WARN_IF(!connection->Init()) ? nullptr : connection.forget();
 }
 
 bool
 PresentationConnection::Init()
 {
   if (NS_WARN_IF(mId.IsEmpty())) {
     return false;
   }
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if(NS_WARN_IF(!service)) {
     return false;
   }
 
-  nsresult rv = service->RegisterSessionListener(mId, mRole, this);
+  nsresult rv = service->RegisterSessionListener(mId, this);
   if(NS_WARN_IF(NS_FAILED(rv))) {
     return false;
   }
 
   return true;
 }
 
 void
 PresentationConnection::Shutdown()
 {
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return;
   }
 
-  nsresult rv = service->UnregisterSessionListener(mId, mRole);
+  nsresult rv = service->UnregisterSessionListener(mId);
   NS_WARN_IF(NS_FAILED(rv));
 }
 
 /* virtual */ void
 PresentationConnection::DisconnectFromOwner()
 {
   Shutdown();
   DOMEventTargetHelper::DisconnectFromOwner();
@@ -135,17 +128,17 @@ PresentationConnection::Send(const nsASt
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if(NS_WARN_IF(!service)) {
     aRv.Throw(NS_ERROR_DOM_OPERATION_ERR);
     return;
   }
 
-  nsresult rv = service->SendSessionMessage(mId, mRole, aData);
+  nsresult rv = service->SendSessionMessage(mId, aData);
   if(NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_OPERATION_ERR);
   }
 }
 
 void
 PresentationConnection::Close(ErrorResult& aRv)
 {
@@ -168,17 +161,17 @@ PresentationConnection::Terminate(ErrorR
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if(NS_WARN_IF(!service)) {
     aRv.Throw(NS_ERROR_DOM_OPERATION_ERR);
     return;
   }
 
-  NS_WARN_IF(NS_FAILED(service->TerminateSession(mId, mRole)));
+  NS_WARN_IF(NS_FAILED(service->TerminateSession(mId)));
 }
 
 NS_IMETHODIMP
 PresentationConnection::NotifyStateChange(const nsAString& aSessionId,
                                           uint16_t aState)
 {
   if (!aSessionId.Equals(mId)) {
     return NS_ERROR_INVALID_ARG;
@@ -209,17 +202,17 @@ PresentationConnection::NotifyStateChang
   // Unregister session listener if the session is no longer connected.
   if (mState == PresentationConnectionState::Terminated) {
     nsCOMPtr<nsIPresentationService> service =
       do_GetService(PRESENTATION_SERVICE_CONTRACTID);
     if (NS_WARN_IF(!service)) {
       return NS_ERROR_NOT_AVAILABLE;
     }
 
-    nsresult rv = service->UnregisterSessionListener(mId, mRole);
+    nsresult rv = service->UnregisterSessionListener(mId);
     if(NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   return DispatchStateChangeEvent();
 }
 
--- a/dom/presentation/PresentationConnection.h
+++ b/dom/presentation/PresentationConnection.h
@@ -20,17 +20,16 @@ class PresentationConnection final : pub
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationConnection,
                                            DOMEventTargetHelper)
   NS_DECL_NSIPRESENTATIONSESSIONLISTENER
 
   static already_AddRefed<PresentationConnection> Create(nsPIDOMWindowInner* aWindow,
                                                          const nsAString& aId,
-                                                         const uint8_t aRole,
                                                          PresentationConnectionState aState);
 
   virtual void DisconnectFromOwner() override;
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
   // WebIDL (public APIs)
@@ -46,30 +45,28 @@ public:
   void Terminate(ErrorResult& aRv);
 
   IMPL_EVENT_HANDLER(statechange);
   IMPL_EVENT_HANDLER(message);
 
 private:
   PresentationConnection(nsPIDOMWindowInner* aWindow,
                          const nsAString& aId,
-                         const uint8_t aRole,
                          PresentationConnectionState aState);
 
   ~PresentationConnection();
 
   bool Init();
 
   void Shutdown();
 
   nsresult DispatchStateChangeEvent();
 
   nsresult DispatchMessageEvent(JS::Handle<JS::Value> aData);
 
   nsString mId;
-  uint8_t mRole;
   PresentationConnectionState mState;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_PresentationConnection_h
--- a/dom/presentation/PresentationDataChannelSessionTransport.js
+++ b/dom/presentation/PresentationDataChannelSessionTransport.js
@@ -15,16 +15,17 @@ function log(aMsg) {
 }
 
 const PRESENTATIONTRANSPORT_CID = Components.ID("{dd2bbf2f-3399-4389-8f5f-d382afb8b2d6}");
 const PRESENTATIONTRANSPORT_CONTRACTID = "mozilla.org/presentation/datachanneltransport;1";
 
 const PRESENTATIONTRANSPORTBUILDER_CID = Components.ID("{215b2f62-46e2-4004-a3d1-6858e56c20f3}");
 const PRESENTATIONTRANSPORTBUILDER_CONTRACTID = "mozilla.org/presentation/datachanneltransportbuilder;1";
 
+
 function PresentationDataChannelDescription(aDataChannelSDP) {
   this._dataChannelSDP = JSON.stringify(aDataChannelSDP);
 }
 
 PresentationDataChannelDescription.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationChannelDescription]),
   get type() {
     return nsIPresentationChannelDescription.TYPE_DATACHANNEL;
@@ -35,70 +36,71 @@ PresentationDataChannelDescription.proto
   get tcpPort() {
     return null;
   },
   get dataChannelSDP() {
     return this._dataChannelSDP;
   }
 };
 
+
 function PresentationTransportBuilder() {
   log("PresentationTransportBuilder construct");
   this._isControlChannelNeeded = true;
 }
 
 PresentationTransportBuilder.prototype = {
   classID: PRESENTATIONTRANSPORTBUILDER_CID,
   contractID: PRESENTATIONTRANSPORTBUILDER_CONTRACTID,
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationDataChannelSessionTransportBuilder,
                                          Ci.nsIPresentationControlChannelListener,
                                          Ci.nsITimerCallback]),
 
-  buildDataChannelTransport: function(aRole, aWindow, aControlChannel, aListener) {
-    if (!aRole || !aWindow || !aControlChannel || !aListener) {
+  buildDataChannelTransport: function(aType, aWindow, aControlChannel, aListener) {
+    if (!aType || !aWindow || !aControlChannel || !aListener) {
       log("buildDataChannelTransport with illegal parameters");
       throw Cr.NS_ERROR_ILLEGAL_VALUE;
     }
 
     if (this._window) {
       log("buildDataChannelTransport has started.");
       throw Cr.NS_ERROR_UNEXPECTED;
     }
 
-    log("buildDataChannelTransport with role " + aRole);
-    this._role = aRole;
+    log("buildDataChannelTransport with type " + aType);
+    this._type = aType;
     this._window = aWindow;
     this._controlChannel = aControlChannel.QueryInterface(Ci.nsIPresentationControlChannel);
     this._controlChannel.listener = this;
     this._listener = aListener.QueryInterface(Ci.nsIPresentationSessionTransportBuilderListener);
 
     // TODO bug 1227053 set iceServers from |nsIPresentationDevice|
     this._peerConnection = new this._window.RTCPeerConnection();
 
     // |this._controlChannel == null| will throw since the control channel is
     // abnormally closed.
     this._peerConnection.onicecandidate = aEvent => aEvent.candidate &&
       this._controlChannel.sendIceCandidate(JSON.stringify(aEvent.candidate));
 
     this._peerConnection.onnegotiationneeded = () => {
-      log("onnegotiationneeded with role " + this._role);
+      log("onnegotiationneeded with type " + this._type);
       this._peerConnection.createOffer()
           .then(aOffer => this._peerConnection.setLocalDescription(aOffer))
           .then(() => this._controlChannel
                           .sendOffer(new PresentationDataChannelDescription(this._peerConnection.localDescription)))
           .catch(e => this._reportError(e));
     }
 
-    switch (this._role) {
-      case Ci.nsIPresentationService.ROLE_CONTROLLER:
+    switch (this._type) {
+      case Ci.nsIPresentationSessionTransportBuilder.TYPE_SENDER:
         this._dataChannel = this._peerConnection.createDataChannel("presentationAPI");
         this._setDataChannel();
         break;
 
-      case Ci.nsIPresentationService.ROLE_RECEIVER:
+      case Ci.nsIPresentationSessionTransportBuilder.TYPE_RECEIVER:
         this._peerConnection.ondatachannel = aEvent => {
           this._dataChannel = aEvent.channel;
           this._setDataChannel();
         }
         break;
       default:
        throw Cr.NS_ERROR_ILLEGAL_VALUE;
     }
@@ -126,17 +128,17 @@ PresentationTransportBuilder.prototype =
 
   _reportError: function(aError) {
     log("report Error " + aError.name + ":" + aError.message);
     this._cleanup(Cr.NS_ERROR_FAILURE);
   },
 
   _setDataChannel: function() {
     this._dataChannel.onopen = () => {
-      log("data channel is open, notify the listener, role " + this._role);
+      log("data channel is open, notify the listener, type " + this._type);
 
       // Handoff the ownership of _peerConnection and _dataChannel to
       // _sessionTransport
       this._sessionTransport = new PresentationTransport();
       this._sessionTransport.init(this._peerConnection, this._dataChannel);
       this._peerConnection = this._dataChannel = null;
 
       this._listener.onSessionTransport(this._sessionTransport);
@@ -161,17 +163,17 @@ PresentationTransportBuilder.prototype =
       this._dataChannel = null;
     }
 
     if (this._peerConnection) {
       this._peerConnection.close();
       this._peerConnection = null;
     }
 
-    this._role = null;
+    this._type = null;
     this._window = null;
 
     if (this._controlChannel) {
       this._controlChannel.close(aReason);
       this._controlChannel = null;
     }
 
     this._listener = null;
@@ -180,56 +182,56 @@ PresentationTransportBuilder.prototype =
     if (this._timer) {
       this._timer.cancel();
       this._timer = null;
     }
   },
 
   // nsIPresentationControlChannelListener
   onOffer: function(aOffer) {
-    if (this._role !== Ci.nsIPresentationService.ROLE_RECEIVER ||
+    if (this._type !== Ci.nsIPresentationSessionTransportBuilder.TYPE_RECEIVER ||
           this._sessionTransport) {
       log("onOffer status error");
       this._cleanup(Cr.NS_ERROR_FAILURE);
     }
 
-    log("onOffer: " + aOffer.dataChannelSDP + " with role " + this._role);
+    log("onOffer: " + aOffer.dataChannelSDP + " with type " + this._type);
 
     let offer = new this._window
                         .RTCSessionDescription(JSON.parse(aOffer.dataChannelSDP));
 
     this._peerConnection.setRemoteDescription(offer)
         .then(() => this._peerConnection.signalingState == "stable" ||
                       this._peerConnection.createAnswer())
         .then(aAnswer => this._peerConnection.setLocalDescription(aAnswer))
         .then(() => {
           this._isControlChannelNeeded = false;
           this._controlChannel
               .sendAnswer(new PresentationDataChannelDescription(this._peerConnection.localDescription))
         }).catch(e => this._reportError(e));
   },
 
   onAnswer: function(aAnswer) {
-    if (this._role !== Ci.nsIPresentationService.ROLE_CONTROLLER ||
+    if (this._type !== Ci.nsIPresentationSessionTransportBuilder.TYPE_SENDER ||
           this._sessionTransport) {
       log("onAnswer status error");
       this._cleanup(Cr.NS_ERROR_FAILURE);
     }
 
-    log("onAnswer: " + aAnswer.dataChannelSDP + " with role " + this._role);
+    log("onAnswer: " + aAnswer.dataChannelSDP + " with type " + this._type);
 
     let answer = new this._window
                          .RTCSessionDescription(JSON.parse(aAnswer.dataChannelSDP));
 
     this._peerConnection.setRemoteDescription(answer).catch(e => this._reportError(e));
     this._isControlChannelNeeded = false;
   },
 
   onIceCandidate: function(aCandidate) {
-    log("onIceCandidate: " + aCandidate + " with role " + this._role);
+    log("onIceCandidate: " + aCandidate + " with type " + this._type);
     let candidate = new this._window.RTCIceCandidate(JSON.parse(aCandidate));
     this._peerConnection.addIceCandidate(candidate).catch(e => this._reportError(e));
   },
 
   notifyOpened: function() {
     log("notifyOpened, should be opened beforehand");
   },
 
@@ -240,16 +242,17 @@ PresentationTransportBuilder.prototype =
       this._cleanup(aReason);
     } else if (this._isControlChannelNeeded) {
       this._cleanup(Cr.NS_ERROR_FAILURE);
     }
     this._controlChannel = null;
   },
 };
 
+
 function PresentationTransport() {
   this._messageQueue = [];
   this._closeReason = Cr.NS_OK;
 }
 
 PresentationTransport.prototype = {
   classID: PRESENTATIONTRANSPORT_CID,
   contractID: PRESENTATIONTRANSPORT_CONTRACTID,
@@ -279,16 +282,17 @@ PresentationTransport.prototype = {
       if (!this._enableDataNotification || !this._callback) {
         log("queue message");
         this._messageQueue.push(aEvent.data);
         return;
       }
       this._callback.notifyData(aEvent.data);
     };
 
+
     this._dataChannel.onerror = aError => {
       log("data channel onerror " + aError.name + ":" + aError.message);
       if (this._callback) {
         this._callback.notifyTransportClosed(Cr.NS_ERROR_FAILURE);
       }
       this._cleanup();
     }
   },
--- a/dom/presentation/PresentationReceiver.cpp
+++ b/dom/presentation/PresentationReceiver.cpp
@@ -167,17 +167,16 @@ PresentationReceiver::NotifySessionConne
   }
 
   if (NS_WARN_IF(aWindowId != GetOwner()->WindowID())) {
     return NS_ERROR_INVALID_ARG;
   }
 
   RefPtr<PresentationConnection> connection =
     PresentationConnection::Create(GetOwner(), aSessionId,
-                                   nsIPresentationService::ROLE_RECEIVER,
                                    PresentationConnectionState::Closed);
   if (NS_WARN_IF(!connection)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
   mConnections.AppendElement(connection);
 
   // Resolve pending |GetConnection| promises if any.
   if (!mPendingGetConnectionPromises.IsEmpty()) {
--- a/dom/presentation/PresentationService.cpp
+++ b/dom/presentation/PresentationService.cpp
@@ -1,10 +1,9 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ipc/PresentationIPCService.h"
 #include "mozilla/Services.h"
 #include "mozIApplication.h"
 #include "nsIAppsService.h"
@@ -96,18 +95,17 @@ PresentationDeviceRequest::Select(nsIPre
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Update device in the session info.
   RefPtr<PresentationSessionInfo> info =
-    static_cast<PresentationService*>(service.get())->
-      GetSessionInfo(mId, nsIPresentationService::ROLE_CONTROLLER);
+    static_cast<PresentationService*>(service.get())->GetSessionInfo(mId);
   if (NS_WARN_IF(!info)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
   info->SetDevice(aDevice);
 
   // Establish a control channel. If we failed to do so, the callback is called
   // with an error message.
   nsCOMPtr<nsIPresentationControlChannel> ctrlChannel;
@@ -130,18 +128,17 @@ PresentationDeviceRequest::Cancel()
 {
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   RefPtr<PresentationSessionInfo> info =
-    static_cast<PresentationService*>(service.get())->
-      GetSessionInfo(mId, nsIPresentationService::ROLE_CONTROLLER);
+    static_cast<PresentationService*>(service.get())->GetSessionInfo(mId);
   if (NS_WARN_IF(!info)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return info->ReplyError(NS_ERROR_DOM_ABORT_ERR);
 }
 
 /*
@@ -222,18 +219,17 @@ PresentationService::Observe(nsISupports
 
 void
 PresentationService::HandleShutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mAvailabilityListeners.Clear();
   mRespondingListeners.Clear();
-  mSessionInfoAtController.Clear();
-  mSessionInfoAtReceiver.Clear();
+  mSessionInfo.Clear();
   mRespondingSessionIds.Clear();
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   if (obs) {
     obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
     obs->RemoveObserver(this, PRESENTATION_DEVICE_CHANGE_TOPIC);
     obs->RemoveObserver(this, PRESENTATION_SESSION_REQUEST_TOPIC);
   }
@@ -310,32 +306,31 @@ PresentationService::HandleSessionReques
 
   if (NS_WARN_IF(isApp && !IsAppInstalled(uri))) {
     ctrlChannel->Close(NS_ERROR_DOM_NOT_FOUND_ERR);
     return NS_OK;
   }
 #endif
 
   // Create or reuse session info.
-  RefPtr<PresentationSessionInfo> info =
-    GetSessionInfo(sessionId, nsIPresentationService::ROLE_RECEIVER);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(sessionId);
   if (NS_WARN_IF(info)) {
     // TODO Bug 1195605. Update here after session join/resume becomes supported.
     ctrlChannel->Close(NS_ERROR_DOM_OPERATION_ERR);
     return NS_ERROR_DOM_ABORT_ERR;
   }
 
   info = new PresentationPresentingInfo(url, sessionId, device);
   rv = info->Init(ctrlChannel);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     ctrlChannel->Close(rv);
     return rv;
   }
 
-  mSessionInfoAtReceiver.Put(sessionId, info);
+  mSessionInfo.Put(sessionId, info);
 
   // Notify the receiver to launch.
   nsCOMPtr<nsIPresentationRequestUIGlue> glue =
     do_CreateInstance(PRESENTATION_REQUEST_UI_GLUE_CONTRACTID);
   if (NS_WARN_IF(!glue)) {
     ctrlChannel->Close(NS_ERROR_DOM_OPERATION_ERR);
     return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
   }
@@ -399,17 +394,17 @@ PresentationService::StartSession(const 
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aCallback);
   MOZ_ASSERT(!aSessionId.IsEmpty());
 
   // Create session info  and set the callback. The callback is called when the
   // request is finished.
   RefPtr<PresentationSessionInfo> info =
     new PresentationControllingInfo(aUrl, aSessionId, aCallback);
-  mSessionInfoAtController.Put(aSessionId, info);
+  mSessionInfo.Put(aSessionId, info);
 
   // Only track the info when an actual window ID, which would never be 0, is
   // provided (for an in-process sender page).
   if (aWindowId != 0) {
     mRespondingSessionIds.Put(aWindowId, new nsString(aSessionId));
     mRespondingWindowIds.Put(aSessionId, aWindowId);
   }
 
@@ -468,60 +463,51 @@ PresentationService::StartSession(const 
   }
 
   // Reject if designated device is not available.
   return info->ReplyError(NS_ERROR_DOM_NOT_FOUND_ERR);
 }
 
 NS_IMETHODIMP
 PresentationService::SendSessionMessage(const nsAString& aSessionId,
-                                        uint8_t aRole,
                                         const nsAString& aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!aData.IsEmpty());
   MOZ_ASSERT(!aSessionId.IsEmpty());
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
 
-  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId);
   if (NS_WARN_IF(!info)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return info->Send(aData);
 }
 
 NS_IMETHODIMP
-PresentationService::CloseSession(const nsAString& aSessionId,
-                                  uint8_t aRole)
+PresentationService::CloseSession(const nsAString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!aSessionId.IsEmpty());
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
 
-  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId);
   if (NS_WARN_IF(!info)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return info->Close(NS_OK, nsIPresentationSessionListener::STATE_CLOSED);
 }
 
 NS_IMETHODIMP
-PresentationService::TerminateSession(const nsAString& aSessionId,
-                                      uint8_t aRole)
+PresentationService::TerminateSession(const nsAString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!aSessionId.IsEmpty());
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
 
-  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId);
   if (NS_WARN_IF(!info)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return info->Close(NS_OK, nsIPresentationSessionListener::STATE_TERMINATED);
 }
 
 NS_IMETHODIMP
@@ -543,25 +529,22 @@ PresentationService::UnregisterAvailabil
   MOZ_ASSERT(NS_IsMainThread());
 
   mAvailabilityListeners.RemoveElement(aListener);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationService::RegisterSessionListener(const nsAString& aSessionId,
-                                             uint8_t aRole,
                                              nsIPresentationSessionListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aListener);
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
 
-  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId);
   if (NS_WARN_IF(!info)) {
     // Notify the listener of TERMINATED since no correspondent session info is
     // available possibly due to establishment failure. This would be useful at
     // the receiver side, since a presentation session is created at beginning
     // and here is the place to realize the underlying establishment fails.
     nsresult rv = aListener->NotifyStateChange(aSessionId,
                                                nsIPresentationSessionListener::STATE_TERMINATED);
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -569,27 +552,24 @@ PresentationService::RegisterSessionList
     }
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return info->SetListener(aListener);
 }
 
 NS_IMETHODIMP
-PresentationService::UnregisterSessionListener(const nsAString& aSessionId,
-                                               uint8_t aRole)
+PresentationService::UnregisterSessionListener(const nsAString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
 
-  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId);
   if (info) {
     NS_WARN_IF(NS_FAILED(info->Close(NS_OK, nsIPresentationSessionListener::STATE_TERMINATED)));
-    UntrackSessionInfo(aSessionId, aRole);
+    UntrackSessionInfo(aSessionId);
     return info->SetListener(nullptr);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationService::RegisterRespondingListener(uint64_t aWindowId,
                                                 nsIPresentationRespondingListener* aListener)
@@ -629,44 +609,36 @@ PresentationService::GetExistentSessionI
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationService::NotifyReceiverReady(const nsAString& aSessionId,
                                          uint64_t aWindowId)
 {
-  RefPtr<PresentationSessionInfo> info =
-    GetSessionInfo(aSessionId, nsIPresentationService::ROLE_RECEIVER);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId);
   if (NS_WARN_IF(!info)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Only track the responding info when an actual window ID, which would never
   // be 0, is provided (for an in-process receiver page).
   if (aWindowId != 0) {
     mRespondingSessionIds.Put(aWindowId, new nsString(aSessionId));
     mRespondingWindowIds.Put(aSessionId, aWindowId);
   }
 
   return static_cast<PresentationPresentingInfo*>(info.get())->NotifyResponderReady();
 }
 
 NS_IMETHODIMP
-PresentationService::UntrackSessionInfo(const nsAString& aSessionId,
-                                        uint8_t aRole)
+PresentationService::UntrackSessionInfo(const nsAString& aSessionId)
 {
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
   // Remove the session info.
-  if (nsIPresentationService::ROLE_CONTROLLER == aRole) {
-    mSessionInfoAtController.Remove(aSessionId);
-  } else {
-    mSessionInfoAtReceiver.Remove(aSessionId);
-  }
+  mSessionInfo.Remove(aSessionId);
 
   // Remove the in-process responding info if there's still any.
   uint64_t windowId = 0;
   if (mRespondingWindowIds.Get(aSessionId, &windowId)) {
     mRespondingWindowIds.Remove(aSessionId);
     mRespondingSessionIds.Remove(windowId);
   }
 
@@ -680,22 +652,19 @@ PresentationService::GetWindowIdBySessio
   if (mRespondingWindowIds.Get(aSessionId, aWindowId)) {
     return NS_OK;
   }
   return NS_ERROR_NOT_AVAILABLE;
 }
 
 bool
 PresentationService::IsSessionAccessible(const nsAString& aSessionId,
-                                         const uint8_t aRole,
                                          base::ProcessId aProcessId)
 {
-  MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-             aRole == nsIPresentationService::ROLE_RECEIVER);
-  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
+  RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId);
   if (NS_WARN_IF(!info)) {
     return false;
   }
   return info->IsAccessible(aProcessId);
 }
 
 already_AddRefed<nsIPresentationService>
 NS_CreatePresentationService()
--- a/dom/presentation/PresentationService.h
+++ b/dom/presentation/PresentationService.h
@@ -28,33 +28,24 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIPRESENTATIONSERVICE
 
   PresentationService();
   bool Init();
 
   already_AddRefed<PresentationSessionInfo>
-  GetSessionInfo(const nsAString& aSessionId, const uint8_t aRole)
+  GetSessionInfo(const nsAString& aSessionId)
   {
-    MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-               aRole == nsIPresentationService::ROLE_RECEIVER);
-
     RefPtr<PresentationSessionInfo> info;
-    if (aRole == nsIPresentationService::ROLE_CONTROLLER) {
-      return mSessionInfoAtController.Get(aSessionId, getter_AddRefs(info)) ?
-             info.forget() : nullptr;
-    } else {
-      return mSessionInfoAtReceiver.Get(aSessionId, getter_AddRefs(info)) ?
-             info.forget() : nullptr;
-    }
+    return mSessionInfo.Get(aSessionId, getter_AddRefs(info)) ?
+           info.forget() : nullptr;
   }
 
   bool IsSessionAccessible(const nsAString& aSessionId,
-                           const uint8_t aRole,
                            base::ProcessId aProcessId);
 
 private:
   ~PresentationService();
   void HandleShutdown();
   nsresult HandleDeviceChange();
   nsresult HandleSessionRequest(nsIPresentationSessionRequest* aRequest);
   void NotifyAvailableChange(bool aIsAvailable);
@@ -65,18 +56,17 @@ private:
 
   // Store the responding listener based on the window ID of the (in-process or
   // OOP) receiver page.
   // TODO Bug 1195605 - Support many-to-one session.
   // So far responding listeners are registered but |notifySessionConnect| hasn't
   // been called in any place until many-to-one session becomes supported.
   nsRefPtrHashtable<nsUint64HashKey, nsIPresentationRespondingListener> mRespondingListeners;
 
-  nsRefPtrHashtable<nsStringHashKey, PresentationSessionInfo> mSessionInfoAtController;
-  nsRefPtrHashtable<nsStringHashKey, PresentationSessionInfo> mSessionInfoAtReceiver;
+  nsRefPtrHashtable<nsStringHashKey, PresentationSessionInfo> mSessionInfo;
 
   // Store the mapping between the window ID of the in-process page and the ID
   // of the responding session. It's used for an in-process receiver page to
   // retrieve the correspondent session ID. Besides, also keep the mapping
   // between the responding session ID and the window ID to help look up the
   // window ID.
   nsClassHashtable<nsUint64HashKey, nsString> mRespondingSessionIds;
   nsDataHashtable<nsStringHashKey, uint64_t> mRespondingWindowIds;
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -320,17 +320,17 @@ PresentationSessionInfo::ReplyError(nsre
 /* virtual */ nsresult
 PresentationSessionInfo::UntrackFromService()
 {
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
-  static_cast<PresentationService*>(service.get())->UntrackSessionInfo(mSessionId, mRole);
+  static_cast<PresentationService*>(service.get())->UntrackSessionInfo(mSessionId);
 
   return NS_OK;
 }
 
 nsPIDOMWindowInner*
 PresentationSessionInfo::GetWindow()
 {
   nsCOMPtr<nsIPresentationService> service =
@@ -655,17 +655,17 @@ PresentationControllingInfo::NotifyOpene
 
   if (NS_WARN_IF(!builder)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   mBuilder = builder;
   mTransportType = nsIPresentationChannelDescription::TYPE_DATACHANNEL;
 
-  return builder->BuildDataChannelTransport(nsIPresentationService::ROLE_CONTROLLER,
+  return builder->BuildDataChannelTransport(nsIPresentationSessionTransportBuilder::TYPE_SENDER,
                                             GetWindow(),
                                             mControlChannel,
                                             this);
 
 }
 
 NS_IMETHODIMP
 PresentationControllingInfo::NotifyClosed(nsresult aReason)
@@ -869,17 +869,17 @@ PresentationPresentingInfo::InitTranspor
       do_CreateInstance("@mozilla.org/presentation/datachanneltransportbuilder;1");
 
     if (NS_WARN_IF(!builder)) {
       return NS_ERROR_NOT_AVAILABLE;
     }
 
     mBuilder = builder;
     mTransportType = nsIPresentationChannelDescription::TYPE_DATACHANNEL;
-    rv = builder->BuildDataChannelTransport(nsIPresentationService::ROLE_RECEIVER,
+    rv = builder->BuildDataChannelTransport(nsIPresentationSessionTransportBuilder::TYPE_RECEIVER,
                                             GetWindow(),
                                             mControlChannel,
                                             this);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     // delegate |onOffer| to builder
@@ -905,17 +905,17 @@ PresentationPresentingInfo::UntrackFromS
   }
 
   // Remove the session info (and the in-process responding info if there's any).
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
-  static_cast<PresentationService*>(service.get())->UntrackSessionInfo(mSessionId, mRole);
+  static_cast<PresentationService*>(service.get())->UntrackSessionInfo(mSessionId);
 
   return NS_OK;
 }
 
 bool
 PresentationPresentingInfo::IsAccessible(base::ProcessId aProcessId)
 {
   // Only the specific content process should access the responder info.
--- a/dom/presentation/PresentationSessionInfo.h
+++ b/dom/presentation/PresentationSessionInfo.h
@@ -33,49 +33,40 @@ class PresentationSessionInfo : public n
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPRESENTATIONSESSIONTRANSPORTCALLBACK
   NS_DECL_NSIPRESENTATIONSESSIONTRANSPORTBUILDERLISTENER
 
   PresentationSessionInfo(const nsAString& aUrl,
                           const nsAString& aSessionId,
-                          const uint8_t aRole,
                           nsIPresentationServiceCallback* aCallback)
     : mUrl(aUrl)
     , mSessionId(aSessionId)
     , mIsResponderReady(false)
     , mIsTransportReady(false)
     , mState(nsIPresentationSessionListener::STATE_CLOSED)
     , mCallback(aCallback)
   {
     MOZ_ASSERT(!mUrl.IsEmpty());
     MOZ_ASSERT(!mSessionId.IsEmpty());
-    MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
-               aRole == nsIPresentationService::ROLE_RECEIVER);
-    mRole = aRole;
   }
 
   virtual nsresult Init(nsIPresentationControlChannel* aControlChannel);
 
   const nsAString& GetUrl() const
   {
     return mUrl;
   }
 
   const nsAString& GetSessionId() const
   {
     return mSessionId;
   }
 
-  uint8_t GetRole() const
-  {
-    return mRole;
-  }
-
   void SetCallback(nsIPresentationServiceCallback* aCallback)
   {
     mCallback = aCallback;
   }
 
   nsresult SetListener(nsIPresentationSessionListener* aListener);
 
   void SetDevice(nsIPresentationDevice* aDevice)
@@ -141,19 +132,16 @@ protected:
 
   // Should be nsIPresentationChannelDescription::TYPE_TCP/TYPE_DATACHANNEL
   uint8_t mTransportType = 0;
 
   nsPIDOMWindowInner* GetWindow();
 
   nsString mUrl;
   nsString mSessionId;
-  // mRole should be nsIPresentationService::ROLE_CONTROLLER
-  //              or nsIPresentationService::ROLE_RECEIVER.
-  uint8_t mRole;
   bool mIsResponderReady;
   bool mIsTransportReady;
   uint32_t mState; // CONNECTED, CLOSED, TERMINATED
   nsCOMPtr<nsIPresentationServiceCallback> mCallback;
   nsCOMPtr<nsIPresentationSessionListener> mListener;
   nsCOMPtr<nsIPresentationDevice> mDevice;
   nsCOMPtr<nsIPresentationSessionTransport> mTransport;
   nsCOMPtr<nsIPresentationControlChannel> mControlChannel;
@@ -167,20 +155,17 @@ class PresentationControllingInfo final 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIPRESENTATIONCONTROLCHANNELLISTENER
   NS_DECL_NSISERVERSOCKETLISTENER
 
   PresentationControllingInfo(const nsAString& aUrl,
                               const nsAString& aSessionId,
                               nsIPresentationServiceCallback* aCallback)
-    : PresentationSessionInfo(aUrl,
-                              aSessionId,
-                              nsIPresentationService::ROLE_CONTROLLER,
-                              aCallback)
+    : PresentationSessionInfo(aUrl, aSessionId, aCallback)
   {
     MOZ_ASSERT(mCallback);
   }
 
   nsresult Init(nsIPresentationControlChannel* aControlChannel) override;
 
 private:
   ~PresentationControllingInfo()
@@ -218,22 +203,20 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIPRESENTATIONCONTROLCHANNELLISTENER
   NS_DECL_NSIPRESENTATIONSESSIONTRANSPORTBUILDERLISTENER
   NS_DECL_NSITIMERCALLBACK
 
   PresentationPresentingInfo(const nsAString& aUrl,
                              const nsAString& aSessionId,
                              nsIPresentationDevice* aDevice)
-    : PresentationSessionInfo(aUrl,
-                              aSessionId,
-                              nsIPresentationService::ROLE_RECEIVER,
-                              nullptr)
+    : PresentationSessionInfo(aUrl, aSessionId, nullptr)
   {
     MOZ_ASSERT(aDevice);
+
     SetDevice(aDevice);
   }
 
   nsresult Init(nsIPresentationControlChannel* aControlChannel) override;
 
   nsresult NotifyResponderReady();
 
   void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
--- a/dom/presentation/PresentationTCPSessionTransport.cpp
+++ b/dom/presentation/PresentationTCPSessionTransport.cpp
@@ -102,27 +102,28 @@ PresentationTCPSessionTransport::BuildTC
   }
   mListener = aListener;
 
   nsresult rv = CreateStream();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  mRole = nsIPresentationService::ROLE_CONTROLLER;
+  mType = nsIPresentationSessionTransportBuilder::TYPE_SENDER;
 
   nsCOMPtr<nsIPresentationSessionTransport> sessionTransport = do_QueryObject(this);
   nsCOMPtr<nsIRunnable> onSessionTransportRunnable =
     NS_NewRunnableMethodWithArgs
       <nsIPresentationSessionTransport*>(mListener,
                                          &nsIPresentationSessionTransportBuilderListener::OnSessionTransport,
                                          sessionTransport);
 
   NS_DispatchToCurrentThread(onSessionTransportRunnable);
 
+
   nsCOMPtr<nsIRunnable> setReadyStateRunnable =
     NS_NewRunnableMethodWithArgs<ReadyState>(this,
                                              &PresentationTCPSessionTransport::SetReadyState,
                                              ReadyState::OPEN);
   return NS_DispatchToCurrentThread(setReadyStateRunnable);
 }
 
 NS_IMETHODIMP
@@ -184,17 +185,17 @@ PresentationTCPSessionTransport::BuildTC
 
   mTransport->SetEventSink(this, mainThread);
 
   rv = CreateStream();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  mRole = nsIPresentationService::ROLE_RECEIVER;
+  mType = nsIPresentationSessionTransportBuilder::TYPE_RECEIVER;
 
   nsCOMPtr<nsIPresentationSessionTransport> sessionTransport = do_QueryObject(this);
   nsCOMPtr<nsIRunnable> runnable =
     NS_NewRunnableMethodWithArgs
       <nsIPresentationSessionTransport*>(mListener,
                                          &nsIPresentationSessionTransportBuilderListener::OnSessionTransport,
                                          sessionTransport);
   return NS_DispatchToCurrentThread(runnable);
--- a/dom/presentation/PresentationTCPSessionTransport.h
+++ b/dom/presentation/PresentationTCPSessionTransport.h
@@ -80,17 +80,17 @@ private:
     return mDataNotificationEnabled && mReadyState == ReadyState::OPEN;
   }
 
   ReadyState mReadyState;
   bool mAsyncCopierActive;
   nsresult mCloseStatus;
   bool mDataNotificationEnabled;
 
-  uint8_t mRole = 0;
+  uint8_t mType = 0;
 
   // Raw socket streams
   nsCOMPtr<nsISocketTransport> mTransport;
   nsCOMPtr<nsIInputStream> mSocketInputStream;
   nsCOMPtr<nsIOutputStream> mSocketOutputStream;
 
   // Input stream machinery
   nsCOMPtr<nsIInputStreamPump> mInputStreamPump;
--- a/dom/presentation/interfaces/nsIPresentationService.idl
+++ b/dom/presentation/interfaces/nsIPresentationService.idl
@@ -31,19 +31,16 @@ interface nsIPresentationServiceCallback
    * @param error: error message.
    */
   void notifyError(in nsresult error);
 };
 
 [scriptable, uuid(de42b741-5619-4650-b961-c2cebb572c95)]
 interface nsIPresentationService : nsISupports
 {
-  const unsigned short ROLE_CONTROLLER = 0x1;
-  const unsigned short ROLE_RECEIVER = 0x2;
-
   /*
    * Start a new presentation session and display a prompt box which asks users
    * to select a device.
    *
    * @param url: The url of presenting page.
    * @param sessionId: An ID to identify presentation session.
    * @param origin: The url of requesting page.
    * @param deviceId: The specified device of handling this request, null string
@@ -63,40 +60,34 @@ interface nsIPresentationService : nsISu
                     in DOMString deviceId,
                     in unsigned long long windowId,
                     in nsIPresentationServiceCallback callback);
 
   /*
    * Send the message to the session.
    *
    * @param sessionId: An ID to identify presentation session.
-   * @param role: Identify the function called by controller or receiver.
    * @param data: the message being sent out.
    */
   void sendSessionMessage(in DOMString sessionId,
-							            in uint8_t role,
                           in DOMString data);
 
   /*
    * Close the session.
    *
    * @param sessionId: An ID to identify presentation session.
-   * @param role: Identify the function called by controller or receiver.
    */
-  void closeSession(in DOMString sessionId,
-                    in uint8_t role);
+  void closeSession(in DOMString sessionId);
 
   /*
    * Terminate the session.
    *
    * @param sessionId: An ID to identify presentation session.
-   * @param role: Identify the function called by controller or receiver.
    */
-  void terminateSession(in DOMString sessionId,
-                        in uint8_t role);
+  void terminateSession(in DOMString sessionId);
 
   /*
    * Register an availability listener. Must be called from the main thread.
    *
    * @param listener: The listener to register.
    */
   void registerAvailabilityListener(in nsIPresentationAvailabilityListener listener);
 
@@ -105,31 +96,27 @@ interface nsIPresentationService : nsISu
    * @param listener: The listener to unregister.
    */
   void unregisterAvailabilityListener(in nsIPresentationAvailabilityListener listener);
 
   /*
    * Register a session listener. Must be called from the main thread.
    *
    * @param sessionId: An ID to identify presentation session.
-   * @param role: Identify the function called by controller or receiver.
    * @param listener: The listener to register.
    */
   void registerSessionListener(in DOMString sessionId,
-                               in uint8_t role,
                                in nsIPresentationSessionListener listener);
 
   /*
    * Unregister a session listener. Must be called from the main thread.
    *
    * @param sessionId: An ID to identify presentation session.
-   * @param role: Identify the function called by controller or receiver.
    */
-  void unregisterSessionListener(in DOMString sessionId,
-                                 in uint8_t role);
+  void unregisterSessionListener(in DOMString sessionId);
 
   /*
    * Register a responding listener. Must be called from the main thread.
    *
    * @param windowId: The window ID associated with the listener.
    * @param listener: The listener to register.
    */
   void registerRespondingListener(in unsigned long long windowId,
@@ -162,17 +149,16 @@ interface nsIPresentationService : nsISu
    */
   void notifyReceiverReady(in DOMString sessionId,
                            [optional] in unsigned long long windowId);
 
   /*
    * Untrack the relevant info about the presentation session if there's any.
    *
    * @param sessionId: An ID to identify presentation session.
-   * @param role: Identify the function called by controller or receiver.
    */
-  void untrackSessionInfo(in DOMString sessionId, in uint8_t role);
+  void untrackSessionInfo(in DOMString sessionId);
 
   /*
    * The windowId for building RTCDataChannel session transport
    */
   unsigned long long getWindowIdBySessionId(in DOMString sessionId);
 };
--- a/dom/presentation/interfaces/nsIPresentationSessionTransportBuilder.idl
+++ b/dom/presentation/interfaces/nsIPresentationSessionTransportBuilder.idl
@@ -17,16 +17,18 @@ interface nsIPresentationSessionTranspor
   void onSessionTransport(in nsIPresentationSessionTransport transport);
 
   void onError(in nsresult reason);
 };
 
 [scriptable, uuid(2fdbe67d-80f9-48dc-8237-5bef8fa19801)]
 interface nsIPresentationSessionTransportBuilder : nsISupports
 {
+  const unsigned short TYPE_SENDER = 1;
+  const unsigned short TYPE_RECEIVER = 2;
 };
 
 /**
  * Builder for TCP session transport
  */
 [scriptable, uuid(cde36d6e-f471-4262-a70d-f932a26b21d9)]
 interface nsIPresentationTCPSessionTransportBuilder : nsIPresentationSessionTransportBuilder
 {
--- a/dom/presentation/ipc/PPresentation.ipdl
+++ b/dom/presentation/ipc/PPresentation.ipdl
@@ -18,30 +18,27 @@ struct StartSessionRequest
   nsString sessionId;
   nsString origin;
   nsString deviceId;
 };
 
 struct SendSessionMessageRequest
 {
   nsString sessionId;
-  uint8_t role;
   nsString data;
 };
 
 struct CloseSessionRequest
 {
   nsString sessionId;
-  uint8_t role;
 };
 
 struct TerminateSessionRequest
 {
   nsString sessionId;
-  uint8_t role;
 };
 
 union PresentationIPCRequest
 {
   StartSessionRequest;
   SendSessionMessageRequest;
   CloseSessionRequest;
   TerminateSessionRequest;
@@ -59,18 +56,18 @@ child:
   async NotifySessionConnect(uint64_t aWindowId, nsString aSessionId);
 
 parent:
   async __delete__();
 
   async RegisterAvailabilityHandler();
   async UnregisterAvailabilityHandler();
 
-  async RegisterSessionHandler(nsString aSessionId, uint8_t aRole);
-  async UnregisterSessionHandler(nsString aSessionId, uint8_t aRole);
+  async RegisterSessionHandler(nsString aSessionId);
+  async UnregisterSessionHandler(nsString aSessionId);
 
   async RegisterRespondingHandler(uint64_t aWindowId);
   async UnregisterRespondingHandler(uint64_t aWindowId);
 
   async PPresentationRequest(PresentationIPCRequest aRequest);
 
   async NotifyReceiverReady(nsString aSessionId);
 };
--- a/dom/presentation/ipc/PresentationIPCService.cpp
+++ b/dom/presentation/ipc/PresentationIPCService.cpp
@@ -61,43 +61,39 @@ PresentationIPCService::StartSession(con
   return SendRequest(aCallback, StartSessionRequest(nsString(aUrl),
                                                     nsString(aSessionId),
                                                     nsString(aOrigin),
                                                     nsString(aDeviceId)));
 }
 
 NS_IMETHODIMP
 PresentationIPCService::SendSessionMessage(const nsAString& aSessionId,
-                                           uint8_t aRole,
                                            const nsAString& aData)
 {
   MOZ_ASSERT(!aSessionId.IsEmpty());
   MOZ_ASSERT(!aData.IsEmpty());
 
   return SendRequest(nullptr, SendSessionMessageRequest(nsString(aSessionId),
-                                                        aRole,
                                                         nsString(aData)));
 }
 
 NS_IMETHODIMP
-PresentationIPCService::CloseSession(const nsAString& aSessionId,
-                                     uint8_t aRole)
+PresentationIPCService::CloseSession(const nsAString& aSessionId)
 {
   MOZ_ASSERT(!aSessionId.IsEmpty());
 
-  return SendRequest(nullptr, CloseSessionRequest(nsString(aSessionId), aRole));
+  return SendRequest(nullptr, CloseSessionRequest(nsString(aSessionId)));
 }
 
 NS_IMETHODIMP
-PresentationIPCService::TerminateSession(const nsAString& aSessionId,
-                                         uint8_t aRole)
+PresentationIPCService::TerminateSession(const nsAString& aSessionId)
 {
   MOZ_ASSERT(!aSessionId.IsEmpty());
 
-  return SendRequest(nullptr, TerminateSessionRequest(nsString(aSessionId), aRole));
+  return SendRequest(nullptr, TerminateSessionRequest(nsString(aSessionId)));
 }
 
 nsresult
 PresentationIPCService::SendRequest(nsIPresentationServiceCallback* aCallback,
                                     const PresentationIPCRequest& aRequest)
 {
   if (sPresentationChild) {
     PresentationRequestChild* actor = new PresentationRequestChild(aCallback);
@@ -129,40 +125,38 @@ PresentationIPCService::UnregisterAvaila
   if (sPresentationChild) {
     NS_WARN_IF(!sPresentationChild->SendUnregisterAvailabilityHandler());
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::RegisterSessionListener(const nsAString& aSessionId,
-                                                uint8_t aRole,
                                                 nsIPresentationSessionListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aListener);
 
   mSessionListeners.Put(aSessionId, aListener);
   if (sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendRegisterSessionHandler(nsString(aSessionId), aRole));
+    NS_WARN_IF(!sPresentationChild->SendRegisterSessionHandler(nsString(aSessionId)));
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PresentationIPCService::UnregisterSessionListener(const nsAString& aSessionId,
-                                                  uint8_t aRole)
+PresentationIPCService::UnregisterSessionListener(const nsAString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  UntrackSessionInfo(aSessionId, aRole);
+  UntrackSessionInfo(aSessionId);
 
   mSessionListeners.Remove(aSessionId);
   if (sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendUnregisterSessionHandler(nsString(aSessionId), aRole));
+    NS_WARN_IF(!sPresentationChild->SendUnregisterSessionHandler(nsString(aSessionId)));
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::RegisterRespondingListener(uint64_t aWindowId,
                                                    nsIPresentationRespondingListener* aListener)
 {
@@ -279,18 +273,17 @@ PresentationIPCService::NotifyReceiverRe
 
   // Release mCallback after using aSessionId
   // because aSessionId is held by mCallback.
   mCallback = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PresentationIPCService::UntrackSessionInfo(const nsAString& aSessionId,
-                                           uint8_t aRole)
+PresentationIPCService::UntrackSessionInfo(const nsAString& aSessionId)
 {
   // Remove the OOP responding info (if it has never been used).
   uint64_t windowId = 0;
   if (mRespondingWindowIds.Get(aSessionId, &windowId)) {
     mRespondingWindowIds.Remove(aSessionId);
     mRespondingSessionIds.Remove(windowId);
   }
 
--- a/dom/presentation/ipc/PresentationParent.cpp
+++ b/dom/presentation/ipc/PresentationParent.cpp
@@ -40,27 +40,20 @@ PresentationParent::Init()
   return NS_WARN_IF(!mService) ? false : true;
 }
 
 void
 PresentationParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   mActorDestroyed = true;
 
-  for (uint32_t i = 0; i < mSessionIdsAtController.Length(); i++) {
-    NS_WARN_IF(NS_FAILED(mService->
-      UnregisterSessionListener(mSessionIdsAtController[i], nsIPresentationService::ROLE_CONTROLLER)));
+  for (uint32_t i = 0; i < mSessionIds.Length(); i++) {
+    NS_WARN_IF(NS_FAILED(mService->UnregisterSessionListener(mSessionIds[i])));
   }
-  mSessionIdsAtController.Clear();
-
-  for (uint32_t i = 0; i < mSessionIdsAtReceiver.Length(); i++) {
-    NS_WARN_IF(NS_FAILED(mService->
-      UnregisterSessionListener(mSessionIdsAtReceiver[i], nsIPresentationService::ROLE_RECEIVER)));
-  }
-  mSessionIdsAtReceiver.Clear();
+  mSessionIds.Clear();
 
   for (uint32_t i = 0; i < mWindowIds.Length(); i++) {
     NS_WARN_IF(NS_FAILED(mService->UnregisterRespondingListener(mWindowIds[i])));
   }
   mWindowIds.Clear();
 
   mService->UnregisterAvailabilityListener(this);
   mService = nullptr;
@@ -130,48 +123,38 @@ bool
 PresentationParent::RecvUnregisterAvailabilityHandler()
 {
   MOZ_ASSERT(mService);
   NS_WARN_IF(NS_FAILED(mService->UnregisterAvailabilityListener(this)));
   return true;
 }
 
 /* virtual */ bool
-PresentationParent::RecvRegisterSessionHandler(const nsString& aSessionId,
-                                               const uint8_t& aRole)
+PresentationParent::RecvRegisterSessionHandler(const nsString& aSessionId)
 {
   MOZ_ASSERT(mService);
 
   // Validate the accessibility (primarily for receiver side) so that a
   // compromised child process can't fake the ID.
   if (NS_WARN_IF(!static_cast<PresentationService*>(mService.get())->
-                  IsSessionAccessible(aSessionId, aRole, OtherPid()))) {
+                  IsSessionAccessible(aSessionId, OtherPid()))) {
     return true;
   }
 
-  if (nsIPresentationService::ROLE_CONTROLLER == aRole) {
-    mSessionIdsAtController.AppendElement(aSessionId);
-  } else {
-    mSessionIdsAtReceiver.AppendElement(aSessionId);
-  }
-  NS_WARN_IF(NS_FAILED(mService->RegisterSessionListener(aSessionId, aRole, this)));
+  mSessionIds.AppendElement(aSessionId);
+  NS_WARN_IF(NS_FAILED(mService->RegisterSessionListener(aSessionId, this)));
   return true;
 }
 
 /* virtual */ bool
-PresentationParent::RecvUnregisterSessionHandler(const nsString& aSessionId,
-                                                 const uint8_t& aRole)
+PresentationParent::RecvUnregisterSessionHandler(const nsString& aSessionId)
 {
   MOZ_ASSERT(mService);
-  if (nsIPresentationService::ROLE_CONTROLLER == aRole) {
-    mSessionIdsAtController.RemoveElement(aSessionId);
-  } else {
-    mSessionIdsAtReceiver.RemoveElement(aSessionId);
-  }
-  NS_WARN_IF(NS_FAILED(mService->UnregisterSessionListener(aSessionId, aRole)));
+  mSessionIds.RemoveElement(aSessionId);
+  NS_WARN_IF(NS_FAILED(mService->UnregisterSessionListener(aSessionId)));
   return true;
 }
 
 /* virtual */ bool
 PresentationParent::RecvRegisterRespondingHandler(const uint64_t& aWindowId)
 {
   MOZ_ASSERT(mService);
 
@@ -279,61 +262,60 @@ PresentationRequestParent::DoRequest(con
 nsresult
 PresentationRequestParent::DoRequest(const SendSessionMessageRequest& aRequest)
 {
   MOZ_ASSERT(mService);
 
   // Validate the accessibility (primarily for receiver side) so that a
   // compromised child process can't fake the ID.
   if (NS_WARN_IF(!static_cast<PresentationService*>(mService.get())->
-                  IsSessionAccessible(aRequest.sessionId(), aRequest.role(), OtherPid()))) {
+                  IsSessionAccessible(aRequest.sessionId(), OtherPid()))) {
     return NotifyError(NS_ERROR_DOM_SECURITY_ERR);
   }
 
   nsresult rv = mService->SendSessionMessage(aRequest.sessionId(),
-                                             aRequest.role(),
                                              aRequest.data());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return NotifyError(rv);
   }
   return NotifySuccess();
 }
 
 nsresult
 PresentationRequestParent::DoRequest(const CloseSessionRequest& aRequest)
 {
   MOZ_ASSERT(mService);
 
   // Validate the accessibility (primarily for receiver side) so that a
   // compromised child process can't fake the ID.
   if (NS_WARN_IF(!static_cast<PresentationService*>(mService.get())->
-                  IsSessionAccessible(aRequest.sessionId(), aRequest.role(), OtherPid()))) {
+                  IsSessionAccessible(aRequest.sessionId(), OtherPid()))) {
     return NotifyError(NS_ERROR_DOM_SECURITY_ERR);
   }
 
-  nsresult rv = mService->CloseSession(aRequest.sessionId(), aRequest.role());
+  nsresult rv = mService->CloseSession(aRequest.sessionId());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return NotifyError(rv);
   }
   return NotifySuccess();
 }
 
 nsresult
 PresentationRequestParent::DoRequest(const TerminateSessionRequest& aRequest)
 {
   MOZ_ASSERT(mService);
 
   // Validate the accessibility (primarily for receiver side) so that a
   // compromised child process can't fake the ID.
   if (NS_WARN_IF(!static_cast<PresentationService*>(mService.get())->
-                  IsSessionAccessible(aRequest.sessionId(), aRequest.role(), OtherPid()))) {
+                  IsSessionAccessible(aRequest.sessionId(), OtherPid()))) {
     return NotifyError(NS_ERROR_DOM_SECURITY_ERR);
   }
 
-  nsresult rv = mService->TerminateSession(aRequest.sessionId(), aRequest.role());
+  nsresult rv = mService->TerminateSession(aRequest.sessionId());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return NotifyError(rv);
   }
   return NotifySuccess();
 }
 
 NS_IMETHODIMP
 PresentationRequestParent::NotifySuccess()
--- a/dom/presentation/ipc/PresentationParent.h
+++ b/dom/presentation/ipc/PresentationParent.h
@@ -43,35 +43,32 @@ public:
   DeallocPPresentationRequestParent(PPresentationRequestParent* aActor) override;
 
   virtual bool Recv__delete__() override;
 
   virtual bool RecvRegisterAvailabilityHandler() override;
 
   virtual bool RecvUnregisterAvailabilityHandler() override;
 
-  virtual bool RecvRegisterSessionHandler(const nsString& aSessionId,
-                                          const uint8_t& aRole) override;
+  virtual bool RecvRegisterSessionHandler(const nsString& aSessionId) override;
 
-  virtual bool RecvUnregisterSessionHandler(const nsString& aSessionId,
-                                            const uint8_t& aRole) override;
+  virtual bool RecvUnregisterSessionHandler(const nsString& aSessionId) override;
 
   virtual bool RecvRegisterRespondingHandler(const uint64_t& aWindowId) override;
 
   virtual bool RecvUnregisterRespondingHandler(const uint64_t& aWindowId) override;
 
   virtual bool RecvNotifyReceiverReady(const nsString& aSessionId) override;
 
 private:
   virtual ~PresentationParent();
 
   bool mActorDestroyed;
   nsCOMPtr<nsIPresentationService> mService;
-  nsTArray<nsString> mSessionIdsAtController;
-  nsTArray<nsString> mSessionIdsAtReceiver;
+  nsTArray<nsString> mSessionIds;
   nsTArray<uint64_t> mWindowIds;
 };
 
 class PresentationRequestParent final : public PPresentationRequestParent
                                       , public nsIPresentationServiceCallback
 {
   friend class PresentationParent;
 
--- a/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js
+++ b/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js
@@ -222,46 +222,46 @@ const mockedSessionTransport = {
     return this._callback;
   },
   get selfAddress() {
     return this._selfAddress;
   },
   buildTCPSenderTransport: function(transport, listener) {
     sendAsyncMessage('data-transport-initialized');
     this._listener = listener;
-    this._role = Ci.nsIPresentationService.ROLE_CONTROLLER;
+    this._type = Ci.nsIPresentationSessionTransportBuilder.TYPE_SENDER;
 
     setTimeout(()=>{
       this._listener.onSessionTransport(this);
       this._listener = null;
       this.simulateTransportReady();
     }, 0);
   },
   buildTCPReceiverTransport: function(description, listener) {
     this._listener = listener;
-    this._role = Ci.nsIPresentationService.ROLE_CONTROLLER;
+    this._type = Ci.nsIPresentationSessionTransportBuilder.TYPE_RECEIVER;
 
     var addresses = description.QueryInterface(Ci.nsIPresentationChannelDescription).tcpAddress;
     this._selfAddress = {
       QueryInterface: XPCOMUtils.generateQI([Ci.nsINetAddr]),
       address: (addresses.length > 0) ?
                 addresses.queryElementAt(0, Ci.nsISupportsCString).data : "",
       port: description.QueryInterface(Ci.nsIPresentationChannelDescription).tcpPort,
     };
 
     setTimeout(()=>{
       this._listener.onSessionTransport(this);
       this._listener = null;
     }, 0);
   },
   // in-process case
-  buildDataChannelTransport: function(role, window, controlChannel, listener) {
+  buildDataChannelTransport: function(type, window, controlChannel, listener) {
     dump("build data channel transport\n");
     this._listener = listener;
-    this._role = role;
+    this._type = type;
 
     var hasNavigator = window ? (typeof window.navigator != "undefined") : false;
     sendAsyncMessage('check-navigator', hasNavigator);
 
     setTimeout(()=>{
       this._listener.onSessionTransport(this);
       this._listener = null;
       this.simulateTransportReady();
deleted file mode 100644
--- a/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js
+++ /dev/null
@@ -1,409 +0,0 @@
-/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-'use strict';
-
-const { classes: Cc, interfaces: Ci, manager: Cm, utils: Cu, results: Cr } = Components;
-
-Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-
-function debug(str) {
-  // dump('DEBUG -*- PresentationSessionChromeScript1UA -*-: ' + str + '\n');
-}
-
-const originalFactoryData = [];
-const sessionId = 'test-session-id';
-const address = Cc["@mozilla.org/supports-cstring;1"]
-                  .createInstance(Ci.nsISupportsCString);
-address.data = "127.0.0.1";
-const addresses = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-addresses.appendElement(address, false);
-
-function mockChannelDescription(role) {
-  this.QueryInterface = XPCOMUtils.generateQI([Ci.nsIPresentationChannelDescription]);
-  this.role = role;
-  this.type = Ci.nsIPresentationChannelDescription.TYPE_TCP;
-  this.tcpAddress = addresses;
-  this.tcpPort = (role === 'sender' ? 1234 : 4321); // either sender or receiver
-}
-
-const mockChannelDescriptionOfSender   = new mockChannelDescription('sender');
-const mockChannelDescriptionOfReceiver = new mockChannelDescription('receiver');
-
-const mockServerSocket = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIServerSocket,
-                                         Ci.nsIFactory]),
-  createInstance: function(aOuter, aIID) {
-    if (aOuter) {
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    }
-    return this.QueryInterface(aIID);
-  },
-  get port() {
-    return this._port;
-  },
-  set listener(listener) {
-    this._listener = listener;
-  },
-  init: function(port, loopbackOnly, backLog) {
-    this._port = (port == -1 ? 5678 : port);
-  },
-  asyncListen: function(listener) {
-    this._listener = listener;
-  },
-  close: function() {
-    this._listener.onStopListening(this, Cr.NS_BINDING_ABORTED);
-  },
-  onSocketAccepted: function(serverSocket, socketTransport) {
-    this._listener.onSocketAccepted(serverSocket, socketTransport);
-  }
-};
-
-// mockSessionTransport
-var mockSessionTransportOfSender   = undefined;
-var mockSessionTransportOfReceiver = undefined;
-
-function mockSessionTransport() {}
-
-mockSessionTransport.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationSessionTransport,
-                                         Ci.nsIPresentationTCPSessionTransportBuilder]),
-  set callback(callback) {
-    this._callback = callback;
-  },
-  get callback() {
-    return this._callback;
-  },
-  get selfAddress() {
-    return this._selfAddress;
-  },
-  buildTCPSenderTransport: function(transport, listener) {
-    mockSessionTransportOfSender = this;
-    this._listener = listener;
-    this._role = Ci.nsIPresentationService.ROLE_CONTROLLER;
-
-    this._listener.onSessionTransport(this);
-    this._listener = null;
-    this.simulateTransportReady();
-  },
-  buildTCPReceiverTransport: function(description, listener) {
-    mockSessionTransportOfReceiver = this;
-    this._listener = listener;
-    this._role = Ci.nsIPresentationService.ROLE_RECEIVER;
-
-    var addresses = description.QueryInterface(Ci.nsIPresentationChannelDescription)
-                               .tcpAddress;
-    this._selfAddress = {
-      QueryInterface: XPCOMUtils.generateQI([Ci.nsINetAddr]),
-      address: (addresses.length > 0) ?
-                addresses.queryElementAt(0, Ci.nsISupportsCString).data : '',
-      port: description.QueryInterface(Ci.nsIPresentationChannelDescription)
-                       .tcpPort,
-    };
-
-    this._listener.onSessionTransport(this);
-    this._listener = null;
-  },
-  enableDataNotification: function() {
-  },
-  send: function(data) {
-    debug('Send message: ' + data);
-    if (this._role === Ci.nsIPresentationService.ROLE_CONTROLLER) {
-      mockSessionTransportOfReceiver._callback.notifyData(data);
-    }
-    if (this._role === Ci.nsIPresentationService.ROLE_RECEIVER) {
-      mockSessionTransportOfSender._callback.notifyData(data);
-    }
-  },
-  close: function(reason) {
-    sendAsyncMessage('data-transport-closed', reason);
-    this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportClosed(reason);
-  },
-  simulateTransportReady: function() {
-    this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportReady();
-  },
-};
-
-const mockSessionTransportFactory = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
-  createInstance: function(aOuter, aIID) {
-    if (aOuter) {
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    }
-    var result = new mockSessionTransport();
-    return result.QueryInterface(aIID);
-  }
-}
-
-const mockSocketTransport = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISocketTransport]),
-};
-
-// control channel of sender
-const mockControlChannelOfSender = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlChannel]),
-  set listener(listener) {
-    // PresentationControllingInfo::SetControlChannel
-    if (listener) {
-      debug('set listener for mockControlChannelOfSender without null');
-    } else {
-      debug('set listener for mockControlChannelOfSender with null');
-    }
-    this._listener = listener;
-  },
-  get listener() {
-    return this._listener;
-  },
-  notifyOpened: function() {
-    // send offer after notifyOpened immediately
-    this._listener
-        .QueryInterface(Ci.nsIPresentationControlChannelListener)
-        .notifyOpened();
-  },
-  sendOffer: function(offer) {
-    sendAsyncMessage('offer-sent');
-  },
-  onAnswer: function(answer) {
-    this._listener
-        .QueryInterface(Ci.nsIPresentationControlChannelListener)
-        .onAnswer(answer);
-  },
-  close: function(reason) {
-    this._listener
-        .QueryInterface(Ci.nsIPresentationControlChannelListener)
-        .notifyClosed(reason);
-    mockControlChannelOfReceiver.close();
-  }
-};
-
-// control channel of receiver
-const mockControlChannelOfReceiver = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlChannel]),
-  set listener(listener) {
-    // PresentationPresentingInfo::SetControlChannel
-    if (listener) {
-      debug('set listener for mockControlChannelOfReceiver without null');
-    } else {
-      debug('set listener for mockControlChannelOfReceiver with null');
-    }
-    this._listener = listener;
-  },
-  get listener() {
-    return this._listener;
-  },
-  notifyOpened: function() {
-    // do nothing
-    this._listener
-        .QueryInterface(Ci.nsIPresentationControlChannelListener)
-        .notifyOpened();
-  },
-  onOffer: function(offer) {
-    this._listener
-        .QueryInterface(Ci.nsIPresentationControlChannelListener)
-        .onOffer(offer);
-  },
-  sendAnswer: function(answer) {
-    this._listener
-        .QueryInterface(Ci.nsIPresentationSessionTransportCallback)
-        .notifyTransportReady();
-    sendAsyncMessage('answer-sent');
-  },
-  close: function(reason) {
-    this._listener
-        .QueryInterface(Ci.nsIPresentationControlChannelListener)
-        .notifyClosed(reason);
-    sendAsyncMessage('control-channel-receiver-closed', reason);
-  }
-};
-
-const mockDevice = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationDevice]),
-  id:   'id',
-  name: 'name',
-  type: 'type',
-  establishControlChannel: function(url, presentationId) {
-    sendAsyncMessage('control-channel-established');
-    return mockControlChannelOfSender;
-  },
-};
-
-const mockDevicePrompt = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationDevicePrompt,
-                                         Ci.nsIFactory]),
-  createInstance: function(aOuter, aIID) {
-    if (aOuter) {
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    }
-    return this.QueryInterface(aIID);
-  },
-  set request(request) {
-    this._request = request;
-  },
-  get request() {
-    return this._request;
-  },
-  promptDeviceSelection: function(request) {
-    this._request = request;
-    sendAsyncMessage('device-prompt');
-  },
-  simulateSelect: function() {
-    this._request.select(mockDevice);
-  },
-  simulateCancel: function() {
-    this._request.cancel();
-  }
-};
-
-const mockRequestUIGlue = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationRequestUIGlue,
-                                         Ci.nsIFactory]),
-  set promise(aPromise) {
-    this._promise = aPromise
-  },
-  get promise() {
-    return this._promise;
-  },
-  createInstance: function(aOuter, aIID) {
-    if (aOuter) {
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    }
-    return this.QueryInterface(aIID);
-  },
-  sendRequest: function(aUrl, aSessionId) {
-    return this.promise;
-  },
-};
-
-function initMockAndListener() {
-
-  function registerMockFactory(contractId, mockClassId, mockFactory) {
-    var originalClassId, originalFactory;
-
-    var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
-    if (!registrar.isCIDRegistered(mockClassId)) {
-      try {
-        originalClassId = registrar.contractIDToCID(contractId);
-        originalFactory = Cm.getClassObject(Cc[contractId], Ci.nsIFactory);
-      } catch (ex) {
-        originalClassId = "";
-        originalFactory = null;
-      }
-      if (originalFactory) {
-        registrar.unregisterFactory(originalClassId, originalFactory);
-      }
-      registrar.registerFactory(mockClassId, "", contractId, mockFactory);
-    }
-
-    return { contractId: contractId,
-             mockClassId: mockClassId,
-             mockFactory: mockFactory,
-             originalClassId: originalClassId,
-             originalFactory: originalFactory };
-  }
-  // Register mock factories.
-  const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
-                        .getService(Ci.nsIUUIDGenerator);
-  originalFactoryData.push(registerMockFactory("@mozilla.org/presentation-device/prompt;1",
-                                               uuidGenerator.generateUUID(),
-                                               mockDevicePrompt));
-  originalFactoryData.push(registerMockFactory("@mozilla.org/network/server-socket;1",
-                                               uuidGenerator.generateUUID(),
-                                               mockServerSocket));
-  originalFactoryData.push(registerMockFactory("@mozilla.org/presentation/presentationtcpsessiontransport;1",
-                                               uuidGenerator.generateUUID(),
-                                               mockSessionTransportFactory));
-  originalFactoryData.push(registerMockFactory("@mozilla.org/presentation/requestuiglue;1",
-                                               uuidGenerator.generateUUID(),
-                                               mockRequestUIGlue));
-
-  addMessageListener('trigger-device-add', function() {
-    debug('Got message: trigger-device-add');
-    var deviceManager = Cc['@mozilla.org/presentation-device/manager;1']
-                        .getService(Ci.nsIPresentationDeviceManager);
-    deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener)
-                 .addDevice(mockDevice);
-  });
-
-  addMessageListener('trigger-device-prompt-select', function() {
-    debug('Got message: trigger-device-prompt-select');
-    mockDevicePrompt.simulateSelect();
-  });
-
-  addMessageListener('trigger-on-session-request', function(url) {
-    debug('Got message: trigger-on-session-request');
-    var deviceManager = Cc['@mozilla.org/presentation-device/manager;1']
-                          .getService(Ci.nsIPresentationDeviceManager);
-    deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener)
-                 .onSessionRequest(mockDevice,
-                                   url,
-                                   sessionId,
-                                   mockControlChannelOfReceiver);
-  });
-
-  addMessageListener('trigger-control-channel-open', function(reason) {
-    debug('Got message: trigger-control-channel-open');
-    mockControlChannelOfSender.notifyOpened();
-    mockControlChannelOfReceiver.notifyOpened();
-  });
-
-  addMessageListener('trigger-on-offer', function() {
-    debug('Got message: trigger-on-offer');
-    mockControlChannelOfReceiver.onOffer(mockChannelDescriptionOfSender);
-    mockServerSocket.onSocketAccepted(mockServerSocket, mockSocketTransport);
-  });
-
-  addMessageListener('trigger-on-answer', function() {
-    debug('Got message: trigger-on-answer');
-    mockControlChannelOfSender.onAnswer(mockChannelDescriptionOfReceiver);
-  });
-
-  // Used to call sendAsyncMessage in chrome script from receiver.
-  addMessageListener('forward-command', function(command_data) {
-    let command = JSON.parse(command_data);
-    sendAsyncMessage(command.name, command.data);
-  });
-
-  addMessageListener('teardown', teardown);
-
-  var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
-  obs.addObserver(function setupRequestPromiseHandler(aSubject, aTopic, aData) {
-    debug('Got observer: setup-request-promise');
-    obs.removeObserver(setupRequestPromiseHandler, aTopic);
-    mockRequestUIGlue.promise = aSubject;
-    sendAsyncMessage('promise-setup-ready');
-  }, 'setup-request-promise', false);
-}
-
-function teardown() {
-
-  function registerOriginalFactory(contractId, mockedClassId, mockedFactory, originalClassId, originalFactory) {
-    if (originalFactory) {
-      registrar.unregisterFactory(mockedClassId, mockedFactory);
-      registrar.registerFactory(originalClassId, "", contractId, originalFactory);
-    }
-  }
-
-  mockRequestUIGlue.promise               = null;
-  mockServerSocket.listener               = null;
-  mockSessionTransportOfSender.callback   = null;
-  mockSessionTransportOfReceiver.callback = null;
-  mockControlChannelOfSender.listener     = null;
-  mockControlChannelOfReceiver.listener   = null;
-  mockDevicePrompt.request                = null;
-
-  var deviceManager = Cc['@mozilla.org/presentation-device/manager;1']
-                      .getService(Ci.nsIPresentationDeviceManager);
-  deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener)
-               .removeDevice(mockDevice);
-  // Register original factories.
-  for (var data in originalFactoryData) {
-    registerOriginalFactory(data.contractId, data.mockClassId,
-                            data.mockFactory, data.originalClassId,
-                            data.originalFactory);
-  }
-  sendAsyncMessage('teardown-complete');
-}
-
-initMockAndListener();
deleted file mode 100644
--- a/dom/presentation/tests/mochitest/file_presentation_1ua_receiver.html
+++ /dev/null
@@ -1,137 +0,0 @@
-<!DOCTYPE HTML>
-<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: -->
-<html>
-  <head>
-    <meta charset="utf-8">
-    <title>Test for B2G PresentationReceiver at receiver side</title>
-  </head>
-  <body>
-    <div id="content"></div>
-<script type="application/javascript;version=1.7">
-
-"use strict";
-
-function is(a, b, msg) {
-  if (a === b) {
-    window.parent.postMessage('OK ' + msg, '*');
-  } else {
-    window.parent.postMessage('KO ' + msg + ' | reason: ' + a + ' != ' + b, '*');
-  }
-}
-
-function ok(a, msg) {
-  window.parent.postMessage((a ? 'OK ' : 'KO ') + msg, '*');
-}
-
-function info(msg) {
-  window.parent.postMessage('INFO ' + msg, '*');
-}
-
-function command(name, data) {
-  window.parent.postMessage('COMMAND ' + JSON.stringify({name: name, data: data}), '*');
-}
-
-function finish() {
-  window.parent.postMessage('DONE', '*');
-}
-
-var connection;
-
-function testConnectionAvailable() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testConnectionAvailable ---');
-    ok(navigator.presentation, "Receiver: navigator.presentation should be available.");
-    // FIXME Sometimes navigator.presentation.receiver is initialized lately.
-    // See bug 1234128 - navigator.presentation.receiver is null in 1-UA use case.
-    // https://bugzilla.mozilla.org/show_bug.cgi?id=1234128
-    while (!navigator.presentation.receiver) {
-      info('Receiver: navigator.presentation.receiver is null, see Bug 1234128');
-    }
-    ok(navigator.presentation.receiver, "Receiver: navigator.presentation.receiver should be available.");
-    navigator.presentation.receiver.getConnection()
-    .then((aConnection) => {
-      connection = aConnection;
-      ok(connection.id, "Receiver: Connection ID should be set: " + connection.id);
-      is(connection.state, "closed", "Connection state at receiver side should be closed by default.");
-      aResolve();
-    })
-    .catch((aError) => {
-      ok(false, "Receiver: Error occurred when getting the connection: " + aError);
-      finish();
-      aReject();
-    });
-  });
-}
-
-function testConnectionReady() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testConnectionReady ---');
-    connection.onstatechange = function() {
-      connection.onstatechange = null;
-      is(connection.state, "connected", "Receiver: Connection state should become connected.");
-      aResolve();
-    };
-    if (connection.state === "connected") {
-      connection.onstatechange = null;
-      is(connection.state, "connected", "Receiver: Connection state should become connected.");
-      aResolve();
-    }
-  });
-}
-
-function testIncomingMessage() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testIncomingMessage ---');
-    connection.addEventListener('message', function messageHandler(evt) {
-      connection.removeEventListener('message', messageHandler);
-      let msg = evt.data;
-      is(msg, 'msg-sender-to-receiver', 'Receiver: Receiver should receive message from sender.');
-      command('forward-command', JSON.stringify({ name: 'message-from-sender-received' }));
-      aResolve();
-    });
-    command('forward-command', JSON.stringify({ name: 'trigger-message-from-sender' }));
-  });
-}
-
-function testSendMessage() {
-  return new Promise(function(aResolve, aReject) {
-    window.addEventListener('message', function messageHandler(evt) {
-      var message = evt.data;
-      if (message.type === 'trigger-message-from-receiver') {
-        info('Receiver: --- testSendMessage ---');
-        connection.send('msg-receiver-to-sender');
-      }
-      if (message.type === 'message-from-receiver-received') {
-        window.removeEventListener('message', messageHandler);
-        aResolve();
-      }
-    });
-  });
-}
-
-function testTerminateConnection() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testTerminateConnection ---');
-    connection.onstatechange = function() {
-      connection.onstatechange = null;
-      is(connection.state, "terminated", "Receiver: Connection should be terminated.");
-      aResolve();
-    };
-    connection.terminate();
-  });
-}
-
-function runTests() {
-  testConnectionAvailable()
-  .then(testConnectionReady)
-  .then(testIncomingMessage)
-  .then(testSendMessage)
-  .then(testTerminateConnection)
-  .then(finish);
-}
-
-runTests();
-
-</script>
-  </body>
-</html>
deleted file mode 100644
--- a/dom/presentation/tests/mochitest/file_presentation_1ua_receiver_oop.html
+++ /dev/null
@@ -1,137 +0,0 @@
-<!DOCTYPE HTML>
-<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: -->
-<html>
-  <head>
-    <meta charset="utf-8">
-    <title>Test for B2G PresentationReceiver at receiver side</title>
-  </head>
-  <body>
-    <div id="content"></div>
-<script type="application/javascript;version=1.7">
-
-"use strict";
-
-function is(a, b, msg) {
-  if (a === b) {
-    alert('OK ' + msg);
-  } else {
-    alert('KO ' + msg + ' | reason: ' + a + ' != ' + b);
-  }
-}
-
-function ok(a, msg) {
-  alert((a ? 'OK ' : 'KO ') + msg);
-}
-
-function info(msg) {
-  alert('INFO ' + msg);
-}
-
-function command(name, data) {
-  alert('COMMAND ' + JSON.stringify({name: name, data: data}));
-}
-
-function finish() {
-  alert('DONE');
-}
-
-var connection;
-
-function testConnectionAvailable() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testConnectionAvailable ---');
-    ok(navigator.presentation, "Receiver: navigator.presentation should be available.");
-    // FIXME Sometimes navigator.presentation.receiver is initialized lately.
-    // See bug 1234128 - navigator.presentation.receiver is null in 1-UA use case.
-    // https://bugzilla.mozilla.org/show_bug.cgi?id=1234128
-    while (!navigator.presentation.receiver) {
-      info('Receiver: navigator.presentation.receiver is null, see Bug 1234128');
-    }
-    ok(navigator.presentation.receiver, "Receiver: navigator.presentation.receiver should be available.");
-    navigator.presentation.receiver.getConnection()
-    .then((aConnection) => {
-      connection = aConnection;
-      ok(connection.id, "Receiver: Connection ID should be set: " + connection.id);
-      is(connection.state, "closed", "Connection state at receiver side should be closed by default.");
-      aResolve();
-    })
-    .catch((aError) => {
-      ok(false, "Receiver: Error occurred when getting the connection: " + aError);
-      finish();
-      aReject();
-    });
-  });
-}
-
-function testConnectionReady() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testConnectionReady ---');
-    connection.onstatechange = function() {
-      connection.onstatechange = null;
-      is(connection.state, "connected", "Receiver: Connection state should become connected.");
-      aResolve();
-    };
-    if (connection.state === "connected") {
-      connection.onstatechange = null;
-      is(connection.state, "connected", "Receiver: Connection state should become connected.");
-      aResolve();
-    }
-  });
-}
-
-function testIncomingMessage() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testIncomingMessage ---');
-    connection.addEventListener('message', function messageHandler(evt) {
-      connection.removeEventListener('message', messageHandler);
-      let msg = evt.data;
-      is(msg, 'msg-sender-to-receiver', 'Receiver: Receiver should receive message from sender.');
-      command('forward-command', JSON.stringify({ name: 'message-from-sender-received' }));
-      aResolve();
-    });
-    command('forward-command', JSON.stringify({ name: 'trigger-message-from-sender' }));
-  });
-}
-
-function testSendMessage() {
-  return new Promise(function(aResolve, aReject) {
-    window.addEventListener('hashchange', function hashchangeHandler(evt) {
-      var message = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
-      if (message.type === 'trigger-message-from-receiver') {
-        info('Receiver: --- testSendMessage ---');
-        connection.send('msg-receiver-to-sender');
-      }
-      if (message.type === 'message-from-receiver-received') {
-        window.removeEventListener('hashchange', hashchangeHandler);
-        aResolve();
-      }
-    });
-  });
-}
-
-function testTerminateConnection() {
-  return new Promise(function(aResolve, aReject) {
-    info('Receiver: --- testTerminateConnection ---');
-    connection.onstatechange = function() {
-      connection.onstatechange = null;
-      is(connection.state, "terminated", "Receiver: Connection should be terminated.");
-      aResolve();
-    };
-    connection.terminate();
-  });
-}
-
-function runTests() {
-  testConnectionAvailable()
-  .then(testConnectionReady)
-  .then(testIncomingMessage)
-  .then(testSendMessage)
-  .then(testTerminateConnection)
-  .then(finish);
-}
-
-runTests();
-
-</script>
-  </body>
-</html>
--- a/dom/presentation/tests/mochitest/mochitest.ini
+++ b/dom/presentation/tests/mochitest/mochitest.ini
@@ -1,30 +1,24 @@
 [DEFAULT]
 support-files =
   PresentationDeviceInfoChromeScript.js
   PresentationSessionChromeScript.js
-  PresentationSessionChromeScript1UA.js
-  file_presentation_1ua_receiver.html
-  file_presentation_1ua_receiver_oop.html
-  file_presentation_non_receiver_inner_iframe_oop.html
+  file_presentation_receiver.html
+  file_presentation_receiver_oop.html
   file_presentation_non_receiver_oop.html
-  file_presentation_receiver.html
   file_presentation_receiver_establish_connection_error.html
   file_presentation_receiver_inner_iframe_oop.html
-  file_presentation_receiver_oop.html
+  file_presentation_non_receiver_inner_iframe_oop.html
+
 
 [test_presentation_dc_sender.html]
 skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785
 [test_presentation_dc_receiver.html]
 skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785
-[test_presentation_1ua_sender_and_receiver.html]
-skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785
-[test_presentation_1ua_sender_and_receiver_oop.html]
-skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785
 [test_presentation_device_info.html]
 [test_presentation_device_info_permission.html]
 [test_presentation_sender_startWithDevice.html]
 skip-if = toolkit == 'android' # Bug 1129785
 [test_presentation_tcp_sender_disconnect.html]
 skip-if = toolkit == 'android' # Bug 1129785
 [test_presentation_tcp_sender_establish_connection_error.html]
 skip-if = toolkit == 'android' # Bug 1129785
deleted file mode 100644
--- a/dom/presentation/tests/mochitest/test_presentation_1ua_sender_and_receiver.html
+++ /dev/null
@@ -1,212 +0,0 @@
-<!DOCTYPE HTML>
-<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: -->
-<html>
-  <!-- Any copyright is dedicated to the Public Domain.
-    - http://creativecommons.org/publicdomain/zero/1.0/ -->
-  <head>
-    <meta charset="utf-8">
-    <title>Test for B2G Presentation API when sender and receiver at the same side</title>
-    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  </head>
-  <body>
-    <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1234492">
-      Test for B2G Presentation API when sender and receiver at the same side</a>
-    <script type="application/javascript;version=1.8">
-
-'use strict';
-
-function debug(str) {
-  // info(str);
-}
-
-var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript1UA.js'));
-var receiverUrl = SimpleTest.getTestFileURL('file_presentation_1ua_receiver.html');
-var request;
-var connection;
-var receiverIframe;
-
-// This event is triggered when the iframe calls "postMessage".
-window.addEventListener('message', function messageHandler(evt) {
-  var message = evt.data;
-  if (/^OK /.exec(message)) {
-    ok(true, message.replace(/^OK /, ''));
-  } else if (/^KO /.exec(message)) {
-    ok(false, message.replace(/^KO /, ''));
-  } else if (/^INFO /.exec(message)) {
-    info(message.replace(/^INFO /, ''));
-  } else if (/^COMMAND /.exec(message)) {
-    var command = JSON.parse(message.replace(/^COMMAND /, ''));
-    gScript.sendAsyncMessage(command.name, command.data);
-  } else if (/^DONE$/.exec(message)) {
-    window.removeEventListener('message', messageHandler);
-    teardown();
-  }
-}, false);
-
-function postMessageToIframe(aType) {
-  receiverIframe.contentWindow.postMessage({ type: aType }, '*');
-}
-
-function setup() {
-
-  gScript.addMessageListener('device-prompt', function devicePromptHandler() {
-    debug('Got message: device-prompt');
-    gScript.removeMessageListener('device-prompt', devicePromptHandler);
-    gScript.sendAsyncMessage('trigger-device-prompt-select');
-  });
-
-  gScript.addMessageListener('control-channel-established', function controlChannelEstablishedHandler() {
-    debug('Got message: control-channel-established');
-    gScript.removeMessageListener('control-channel-established', controlChannelEstablishedHandler);
-    receiverIframe = document.createElement('iframe');
-    receiverIframe.setAttribute('src', receiverUrl);
-    receiverIframe.onload = function() {
-      info('Receiver loaded.');
-      gScript.sendAsyncMessage('trigger-control-channel-open');
-    };
-
-    var promise = new Promise(function(aResolve, aReject) {
-      document.body.appendChild(receiverIframe);
-      aResolve(receiverIframe);
-    });
-
-    var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
-                           .getService(SpecialPowers.Ci.nsIObserverService);
-    obs.notifyObservers(promise, 'setup-request-promise', null);
-  });
-
-  gScript.addMessageListener('promise-setup-ready', function promiseSetupReadyHandler() {
-    debug('Got message: promise-setup-ready');
-    gScript.removeMessageListener('promise-setup-ready', promiseSetupReadyHandler);
-    gScript.sendAsyncMessage('trigger-on-session-request', receiverUrl);
-  });
-
-  gScript.addMessageListener('offer-sent', function offerSentHandler() {
-    debug('Got message: offer-sent');
-    gScript.removeMessageListener('offer-sent', offerSentHandler);
-    gScript.sendAsyncMessage('trigger-on-offer');
-  });
-
-  gScript.addMessageListener('answer-sent', function answerSentHandler() {
-    debug('Got message: answer-sent');
-    gScript.removeMessageListener('answer-sent', answerSentHandler);
-    gScript.sendAsyncMessage('trigger-on-answer');
-  });
-
-  return Promise.resolve();
-}
-
-function testCreateRequest() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testCreateRequest ---');
-    request = new PresentationRequest("http://example.com");
-    request.getAvailability().then((aAvailability) => {
-      aAvailability.onchange = function() {
-        aAvailability.onchange = null;
-        ok(aAvailability.value, "Sender: Device should be available.");
-        aResolve();
-      }
-    }).catch((aError) => {
-      ok(false, "Sender: Error occurred when getting availability: " + aError);
-      teardown();
-      aReject();
-    });
-
-    gScript.sendAsyncMessage('trigger-device-add');
-  });
-}
-
-function testStartConnection() {
-  return new Promise(function(aResolve, aReject) {
-    request.start().then((aConnection) => {
-      connection = aConnection;
-      ok(connection, "Sender: Connection should be available.");
-      ok(connection.id, "Sender: Connection ID should be set.");
-      is(connection.state, "connected", "Sender: Connection state at sender side should be connected by default.");
-      aResolve();
-    }).catch((aError) => {
-      ok(false, "Sender: Error occurred when establishing a connection: " + aError);
-      teardown();
-      aReject();
-    });
-  });
-}
-
-function testSendMessage() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testSendMessage ---');
-    gScript.addMessageListener('trigger-message-from-sender', function triggerMessageFromSenderHandler() {
-      debug('Got message: trigger-message-from-sender');
-      gScript.removeMessageListener('trigger-message-from-sender', triggerMessageFromSenderHandler);
-      info('Send message to receiver');
-      connection.send('msg-sender-to-receiver');
-    });
-
-    gScript.addMessageListener('message-from-sender-received', function messageFromSenderReceivedHandler() {
-      debug('Got message: message-from-sender-received');
-      gScript.removeMessageListener('message-from-sender-received', messageFromSenderReceivedHandler);
-      aResolve();
-    });
-  });
-}
-
-function testIncomingMessage() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testIncomingMessage ---');
-    connection.addEventListener('message', function messageHandler(evt) {
-      connection.removeEventListener('message', messageHandler);
-      let msg = evt.data;
-      is(msg, "msg-receiver-to-sender", "Sender: Sender should receive message from Receiver");
-      postMessageToIframe('message-from-receiver-received');
-      aResolve();
-    });
-    postMessageToIframe('trigger-message-from-receiver');
-  });
-}
-
-function testTerminateConnection() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testTerminateConnection ---');
-    connection.onstatechange = function() {
-      connection.onstatechange = null;
-      is(connection.state, "terminated", "Sender: Connection should be terminated.");
-      aResolve();
-    };
-    connection.terminate();
-  });
-}
-
-function teardown() {
-  gScript.addMessageListener('teardown-complete', function teardownCompleteHandler() {
-    debug('Got message: teardown-complete');
-    gScript.removeMessageListener('teardown-complete', teardownCompleteHandler);
-    gScript.destroy();
-    SimpleTest.finish();
-  });
-
-  gScript.sendAsyncMessage('teardown');
-}
-
-function runTests() {
-  setup().then(testCreateRequest)
-         .then(testStartConnection)
-         .then(testSendMessage)
-         .then(testIncomingMessage)
-         .then(testTerminateConnection);
-}
-
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPermissions([
-  {type: 'presentation-device-manage', allow: false, context: document},
-  {type: 'presentation', allow: true, context: document},
-], () => {
-  SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
-                                     ["dom.presentation.test.enabled", true],
-                                     ["dom.presentation.test.stage", 0]]},
-                            runTests);
-});
-
-    </script>
-  </body>
-</html>
deleted file mode 100644
--- a/dom/presentation/tests/mochitest/test_presentation_1ua_sender_and_receiver_oop.html
+++ /dev/null
@@ -1,224 +0,0 @@
-<!DOCTYPE HTML>
-<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: -->
-<html>
-<!-- Any copyright is dedicated to the Public Domain.
-   - http://creativecommons.org/publicdomain/zero/1.0/ -->
-  <head>
-    <meta charset="utf-8">
-    <title>Test for B2G Presentation API when sender and receiver at the same side (OOP ver.)</title>
-    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  </head>
-  <body>
-    <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1234492">
-    Test for B2G Presentation API when sender and receiver at the same side (OOP ver.)</a>
-<script type="application/javascript;version=1.8">
-
-'use strict';
-
-var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript1UA.js'));
-var receiverUrl = SimpleTest.getTestFileURL('file_presentation_1ua_receiver_oop.html');
-var request;
-var connection;
-var receiverIframe;
-
-function debug(str) {
-  // info(str);
-}
-
-function postMessageToIframe(aType) {
-  receiverIframe.src = receiverUrl + "#" +
-                       encodeURIComponent(JSON.stringify({ type: aType }));
-}
-
-function setup() {
-
-  gScript.addMessageListener('device-prompt', function devicePromptHandler() {
-    debug('Got message: device-prompt');
-    gScript.removeMessageListener('device-prompt', devicePromptHandler);
-    gScript.sendAsyncMessage('trigger-device-prompt-select');
-  });
-
-  gScript.addMessageListener('control-channel-established', function controlChannelEstablishedHandler() {
-    debug('Got message: control-channel-established');
-    gScript.removeMessageListener('control-channel-established',
-                                  controlChannelEstablishedHandler);
-    receiverIframe = document.createElement('iframe');
-    receiverIframe.setAttribute("remote", "true");
-    receiverIframe.setAttribute("mozbrowser", "true");
-    receiverIframe.setAttribute('src', receiverUrl);
-    receiverIframe.addEventListener("mozbrowserloadend", function mozbrowserloadendHander() {
-      receiverIframe.removeEventListener("mozbrowserloadend", mozbrowserloadendHander);
-      info("Receiver loaded.");
-      gScript.sendAsyncMessage("trigger-control-channel-open");
-    });
-
-    // This event is triggered when the iframe calls "alert".
-    receiverIframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(evt) {
-      var message = evt.detail.message;
-      if (/^OK /.exec(message)) {
-        ok(true, message.replace(/^OK /, ""));
-      } else if (/^KO /.exec(message)) {
-        ok(false, message.replace(/^KO /, ""));
-      } else if (/^INFO /.exec(message)) {
-        info(message.replace(/^INFO /, ""));
-      } else if (/^COMMAND /.exec(message)) {
-        var command = JSON.parse(message.replace(/^COMMAND /, ""));
-        gScript.sendAsyncMessage(command.name, command.data);
-      } else if (/^DONE$/.exec(message)) {
-        receiverIframe.removeEventListener("mozbrowsershowmodalprompt",
-                                            receiverListener);
-        teardown();
-      }
-    }, false);
-
-    var promise = new Promise(function(aResolve, aReject) {
-      document.body.appendChild(receiverIframe);
-      aResolve(receiverIframe);
-    });
-
-    var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
-                           .getService(SpecialPowers.Ci.nsIObserverService);
-    obs.notifyObservers(promise, 'setup-request-promise', null);
-  });
-
-  gScript.addMessageListener('promise-setup-ready', function promiseSetupReadyHandler() {
-    debug('Got message: promise-setup-ready');
-    gScript.removeMessageListener('promise-setup-ready',
-                                  promiseSetupReadyHandler);
-    gScript.sendAsyncMessage('trigger-on-session-request', receiverUrl);
-  });
-
-  gScript.addMessageListener('offer-sent', function offerSentHandler() {
-    debug('Got message: offer-sent');
-    gScript.removeMessageListener('offer-sent', offerSentHandler);
-    gScript.sendAsyncMessage('trigger-on-offer');
-  });
-
-  gScript.addMessageListener('answer-sent', function answerSentHandler() {
-    debug('Got message: answer-sent');
-    gScript.removeMessageListener('answer-sent', answerSentHandler);
-    gScript.sendAsyncMessage('trigger-on-answer');
-  });
-
-  return Promise.resolve();
-}
-
-function testCreateRequest() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testCreateRequest ---');
-    request = new PresentationRequest("http://example.com");
-    request.getAvailability()
-      .then((aAvailability) => {
-        aAvailability.onchange = function() {
-          aAvailability.onchange = null;
-          ok(aAvailability.value, "Sender: Device should be available.");
-          aResolve();
-        }
-      })
-      .catch((aError) => {
-        ok(false, "Sender: Error occurred when getting availability: " + aError);
-        teardown();
-        aReject();
-      });
-
-    gScript.sendAsyncMessage('trigger-device-add');
-  });
-}
-
-function testStartConnection() {
-  return new Promise(function(aResolve, aReject) {
-    request.start()
-    .then((aConnection) => {
-      connection = aConnection;
-      ok(connection, "Sender: Connection should be available.");
-      ok(connection.id, "Sender: Connection ID should be set.");
-      is(connection.state, "connected", "Sender: Connection state at sender side should be connected by default.");
-      aResolve();
-    })
-    .catch((aError) => {
-      ok(false, "Sender: Error occurred when establishing a connection: " + aError);
-      teardown();
-      aReject();
-    });
-  });
-}
-
-function testSendMessage() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testSendMessage ---');
-    gScript.addMessageListener('trigger-message-from-sender', function triggerMessageFromSenderHandler() {
-      gScript.removeMessageListener('trigger-message-from-sender', triggerMessageFromSenderHandler);
-      info('Send message to receiver');
-      connection.send('msg-sender-to-receiver');
-    });
-
-    gScript.addMessageListener('message-from-sender-received', function messageFromSenderReceivedHandler() {
-      gScript.removeMessageListener('message-from-sender-received', messageFromSenderReceivedHandler);
-      aResolve();
-    });
-  });
-}
-
-function testIncomingMessage() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testIncomingMessage ---');
-    connection.addEventListener('message', function messageHandler(evt) {
-      connection.removeEventListener('message', messageHandler);
-      let msg = evt.data;
-      is(msg, "msg-receiver-to-sender", "Sender: Sender should receive message from Receiver");
-      postMessageToIframe('message-from-receiver-received');
-      aResolve();
-    });
-    postMessageToIframe('trigger-message-from-receiver');
-  });
-}
-
-function testTerminateConnection() {
-  return new Promise(function(aResolve, aReject) {
-    info('Sender: --- testTerminateConnection ---');
-    connection.onstatechange = function() {
-      connection.onstatechange = null;
-      is(connection.state, "terminated", "Sender: Connection should be terminated.");
-      aResolve();
-    };
-    connection.terminate();
-  });
-}
-
-function teardown() {
-  gScript.addMessageListener('teardown-complete', function teardownCompleteHandler() {
-    gScript.removeMessageListener('teardown-complete', teardownCompleteHandler);
-    gScript.destroy();
-    SimpleTest.finish();
-  });
-
-  gScript.sendAsyncMessage('teardown');
-}
-
-function runTests() {
-  setup()
-  .then(testCreateRequest)
-  .then(testStartConnection)
-  .then(testSendMessage)
-  .then(testIncomingMessage)
-  .then(testTerminateConnection);
-}
-
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPermissions([
-  {type: 'presentation-device-manage', allow: false, context: document},
-  {type: 'presentation', allow: true, context: document},
-  {type: "browser", allow: true, context: document},
-], () => {
-  SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
-		                                  ["dom.presentation.test.enabled", true],
-    	                                ["dom.presentation.test.stage", 0],
-                                      ["dom.mozBrowserFramesEnabled", true],
-                                      ["dom.ipc.browser_frames.oop_by_default", true]]},
-    	                      runTests);
-});
-
-</script>
-  </body>
-</html>
--- a/dom/presentation/tests/mochitest/test_presentation_datachannel_sessiontransport.html
+++ b/dom/presentation/tests/mochitest/test_presentation_datachannel_sessiontransport.html
@@ -15,16 +15,17 @@
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 
+
 const loadingTimeoutPref = "presentation.receiver.loading.timeout";
 
 var clientBuilder;
 var serverBuilder;
 var clientTransport;
 var serverTransport;
 var clientControlChannel;
 var serverControlChannel;
@@ -117,16 +118,17 @@ const serverCallback = {
     }
   },
   notifyData: function(aData) {
     is(aData, clientMessage, "Server transport receives data.");
     gResolve()
   },
 };
 
+
 const clientListener = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationSessionTransportBuilderListener]),
   onSessionTransport: function(aTransport) {
     info("Client Transport is built.");
     clientTransport = aTransport;
     clientTransport.callback = clientCallback;
   },
   onError: function(aError)  {
@@ -142,39 +144,40 @@ const serverListener = {
     serverTransport.callback = serverCallback;
     serverTransport.enableDataNotification();
   },
   onError: function(aError)  {
     ok(false, "server's builder reports error " + aError);
   }
 }
 
+
 function testBuilder() {
   return new Promise(function(aResolve, aReject) {
     gResolve = aResolve;
     gReject = aReject;
 
     clientControlChannel = new TestControlChannel();
     serverControlChannel = new TestControlChannel();
     clientControlChannel.remote = serverControlChannel;
     serverControlChannel.remote = clientControlChannel;
 
     clientBuilder = Cc["@mozilla.org/presentation/datachanneltransportbuilder;1"]
                       .createInstance(Ci.nsIPresentationDataChannelSessionTransportBuilder);
     serverBuilder = Cc["@mozilla.org/presentation/datachanneltransportbuilder;1"]
                       .createInstance(Ci.nsIPresentationDataChannelSessionTransportBuilder);
 
     clientBuilder
-      .buildDataChannelTransport(Ci.nsIPresentationService.ROLE_CONTROLLER,
+      .buildDataChannelTransport(Ci.nsIPresentationSessionTransportBuilder.TYPE_SENDER,
                                  window,
                                  clientControlChannel,
                                  clientListener);
 
     serverBuilder
-      .buildDataChannelTransport(Ci.nsIPresentationService.ROLE_RECEIVER,
+      .buildDataChannelTransport(Ci.nsIPresentationSessionTransportBuilder.TYPE_RECEIVER,
                                  window,
                                  serverControlChannel,
                                  serverListener);
   });
 }
 
 function testClientSendMessage() {
   return new Promise(function(aResolve, aReject) {
@@ -223,16 +226,17 @@ function runTests() {
 
   testBuilder()
   .then(testClientSendMessage)
   .then(testServerSendMessage)
   .then(testCloseSessionTransport)
   .then(finish)
   .catch(error);
 
+
 }
 
 window.addEventListener("load", function() {
   runTests();
 });
 
 </script>
 </pre>