Bug 1287717 - Part 1, enter closed state while fail to connect. r=smaug.
authorShih-Chiang Chien <schien@mozilla.com>
Tue, 02 Aug 2016 18:40:00 +0200
changeset 308192 025466d995ef6bfb19b19495816c9fce10296965
parent 308191 6e875e1462fc68ee5deef2ce1923d4e351982d03
child 308193 734a7d13d2855ff89d6ee3c0c3da88170a639dc9
push id80272
push usercbook@mozilla.com
push dateThu, 04 Aug 2016 14:32:56 +0000
treeherdermozilla-inbound@6fc40ec6d00d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1287717
milestone51.0a1
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
Bug 1287717 - Part 1, enter closed state while fail to connect. r=smaug. MozReview-Commit-ID: L3gacVfSlcd
dom/presentation/PresentationSessionInfo.cpp
dom/presentation/tests/mochitest/test_presentation_tcp_sender_establish_connection_error.html
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -853,18 +853,20 @@ PresentationControllingInfo::NotifyDisco
   }
 
   // Unset control channel here so it won't try to re-close it in potential
   // subsequent |Shutdown| calls.
   SetControlChannel(nullptr);
 
   if (NS_WARN_IF(NS_FAILED(aReason) || !mIsResponderReady)) {
     // The presentation session instance may already exist.
-    // Change the state to TERMINATED since it never succeeds.
-    SetStateWithReason(nsIPresentationSessionListener::STATE_TERMINATED, aReason);
+    // Change the state to CLOSED if it is not terminated.
+    if (nsIPresentationSessionListener::STATE_TERMINATED != mState) {
+      SetStateWithReason(nsIPresentationSessionListener::STATE_CLOSED, aReason);
+    }
 
     // Reply error for an abnormal close.
     return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
   }
 
   return NS_OK;
 }
 
--- a/dom/presentation/tests/mochitest/test_presentation_tcp_sender_establish_connection_error.html
+++ b/dom/presentation/tests/mochitest/test_presentation_tcp_sender_establish_connection_error.html
@@ -100,19 +100,19 @@ function testStartConnectionUnexpectedCo
       gScript.removeMessageListener('offer-sent', offerSentHandler);
       ok(aIsValid, "A valid offer is sent out.");
       gScript.sendAsyncMessage('trigger-control-channel-close', SpecialPowers.Cr.NS_ERROR_FAILURE);
     });
 
     request.start().then(
       function(aConnection) {
         is(aConnection.state, "connecting", "The initial state should be connecting.");
-        aConnection.onterminate = function() {
-          aConnection.onterminate = null;
-          is(aConnection.state, "terminated", "Connection should be terminated.");
+        aConnection.onclose = function() {
+          aConnection.onclose = null;
+          is(aConnection.state, "closed", "Connection should be closed.");
           aResolve();
         };
       },
       function(aError) {
         ok(false, "Error occurred when establishing a connection: " + aError);
         teardown();
         aReject();
       }
@@ -148,19 +148,19 @@ function testStartConnectionUnexpectedCo
       gScript.removeMessageListener('offer-sent', offerSentHandler);
       ok(aIsValid, "A valid offer is sent out.");
       gScript.sendAsyncMessage('trigger-control-channel-close', SpecialPowers.Cr.NS_OK);
     });
 
     request.start().then(
       function(aConnection) {
         is(aConnection.state, "connecting", "The initial state should be connecting.");
-        aConnection.onterminate = function() {
-          aConnection.onterminate = null;
-          is(aConnection.state, "terminated", "Connection should be terminated.");
+        aConnection.onclose = function() {
+          aConnection.onclose = null;
+          is(aConnection.state, "closed", "Connection should be closed.");
           aResolve();
         };
       },
       function(aError) {
         ok(false, "Error occurred when establishing a connection: " + aError);
         teardown();
         aReject();
       }
@@ -207,19 +207,19 @@ function testStartConnectionUnexpectedCo
     gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) {
       gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler);
       info("The data transport is closed. " + aReason);
     });
 
     request.start().then(
       function(aConnection) {
         is(aConnection.state, "connecting", "The initial state should be connecting.");
-        aConnection.onterminate = function() {
-          aConnection.onterminate = null;
-          is(aConnection.state, "terminated", "Connection should be terminated.");
+        aConnection.onclose = function() {
+          aConnection.onclose = null;
+          is(aConnection.state, "closed", "Connection should be closed.");
           aResolve();
         };
       },
       function(aError) {
         ok(false, "Error occurred when establishing a connection: " + aError);
         teardown();
         aReject();
       }
@@ -266,19 +266,19 @@ function testStartConnectionUnexpectedCo
     gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) {
       gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler);
       info("The data transport is closed. " + aReason);
     });
 
     request.start().then(
       function(aConnection) {
         is(aConnection.state, "connecting", "The initial state should be connecting.");
-        aConnection.onterminate = function() {
-          aConnection.onterminate = null;
-          is(aConnection.state, "terminated", "Connection should be terminated.");
+        aConnection.onclose = function() {
+          aConnection.onclose = null;
+          is(aConnection.state, "closed", "Connection should be closed.");
           aResolve();
         };
       },
       function(aError) {
         ok(false, "Error occurred when establishing a connection: " + aError);
         teardown();
         aReject();
       }
@@ -325,19 +325,19 @@ function testStartConnectionUnexpectedDa
     gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) {
       gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler);
       info("The data transport is closed. " + aReason);
     });
 
     request.start().then(
       function(aConnection) {
         is(aConnection.state, "connecting", "The initial state should be connecting.");
-        aConnection.onterminate = function() {
-          aConnection.onterminate = null;
-          is(aConnection.state, "terminated", "Connection should be terminated.");
+        aConnection.onclose = function() {
+          aConnection.onclose = null;
+          is(aConnection.state, "closed", "Connection should be closed.");
           aResolve();
         };
       },
       function(aError) {
         ok(false, "Error occurred when establishing a connection: " + aError);
         teardown();
         aReject();
       }