Bug 1093793 - desktop call recipient declining incoming call leaves link-clicker's camera on. r=dmose a=loop-only
authorJared Wein <jwein@mozilla.com>
Wed, 05 Nov 2014 13:47:52 -0500
changeset 235120 7e49e9a80a0166a8f988d0d3236bf35fbd2f1332
parent 235119 13c96ad43e4da4140aa825fa15cbd46308709973
child 235121 139182aee28755bcc827a6b9c66cef7e3e8f2b02
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmose, loop-only
bugs1093793
milestone35.0a2
Bug 1093793 - desktop call recipient declining incoming call leaves link-clicker's camera on. r=dmose a=loop-only
browser/components/loop/standalone/content/js/webapp.js
browser/components/loop/standalone/content/js/webapp.jsx
browser/components/loop/test/standalone/webapp_test.js
--- a/browser/components/loop/standalone/content/js/webapp.js
+++ b/browser/components/loop/standalone/content/js/webapp.js
@@ -22,17 +22,17 @@ loop.webapp = (function($, _, OT, mozL10
 
   var multiplexGum = loop.standaloneMedia.multiplexGum;
 
   /**
    * Homepage view.
    */
   var HomeView = React.createClass({displayName: 'HomeView',
     render: function() {
-      loop.standaloneMedia.multiplexGum.reset();
+      multiplexGum.reset();
       return (
         React.DOM.p(null, mozL10n.get("welcome", {clientShortname: mozL10n.get("clientShortname2")}))
       );
     }
   });
 
   /**
    * Unsupported Browsers view.
@@ -286,17 +286,17 @@ loop.webapp = (function($, _, OT, mozL10
     },
 
     _handleRingingProgress: function() {
       this.play("ringing", {loop: true});
       this.setState({callState: "ringing"});
     },
 
     _cancelOutgoingCall: function() {
-      loop.standaloneMedia.multiplexGum.reset();
+      multiplexGum.reset();
       this.props.websocket.cancel();
     },
 
     render: function() {
       var callState = mozL10n.get("call_progress_" + this.state.callState + "_description");
       return (
         React.DOM.div({className: "container"}, 
           React.DOM.div({className: "container-box"}, 
@@ -833,16 +833,18 @@ loop.webapp = (function($, _, OT, mozL10
 
     /**
      * Handles call rejection.
      *
      * @param {String} reason The reason the call was terminated (reject, busy,
      *                        timeout, cancel, media-fail, user-unknown, closed)
      */
     _handleCallTerminated: function(reason) {
+      multiplexGum.reset();
+
       if (reason === "cancel") {
         this.setState({callStatus: "start"});
         return;
       }
       // XXX later, we'll want to display more meaningfull messages (needs UX)
       this.props.notifications.errorL10n("call_timeout_notification_text");
       this.setState({callStatus: "failure"});
     },
--- a/browser/components/loop/standalone/content/js/webapp.jsx
+++ b/browser/components/loop/standalone/content/js/webapp.jsx
@@ -22,17 +22,17 @@ loop.webapp = (function($, _, OT, mozL10
 
   var multiplexGum = loop.standaloneMedia.multiplexGum;
 
   /**
    * Homepage view.
    */
   var HomeView = React.createClass({
     render: function() {
-      loop.standaloneMedia.multiplexGum.reset();
+      multiplexGum.reset();
       return (
         <p>{mozL10n.get("welcome", {clientShortname: mozL10n.get("clientShortname2")})}</p>
       );
     }
   });
 
   /**
    * Unsupported Browsers view.
@@ -286,17 +286,17 @@ loop.webapp = (function($, _, OT, mozL10
     },
 
     _handleRingingProgress: function() {
       this.play("ringing", {loop: true});
       this.setState({callState: "ringing"});
     },
 
     _cancelOutgoingCall: function() {
-      loop.standaloneMedia.multiplexGum.reset();
+      multiplexGum.reset();
       this.props.websocket.cancel();
     },
 
     render: function() {
       var callState = mozL10n.get("call_progress_" + this.state.callState + "_description");
       return (
         <div className="container">
           <div className="container-box">
@@ -833,16 +833,18 @@ loop.webapp = (function($, _, OT, mozL10
 
     /**
      * Handles call rejection.
      *
      * @param {String} reason The reason the call was terminated (reject, busy,
      *                        timeout, cancel, media-fail, user-unknown, closed)
      */
     _handleCallTerminated: function(reason) {
+      multiplexGum.reset();
+
       if (reason === "cancel") {
         this.setState({callStatus: "start"});
         return;
       }
       // XXX later, we'll want to display more meaningfull messages (needs UX)
       this.props.notifications.errorL10n("call_timeout_notification_text");
       this.setState({callStatus: "failure"});
     },
--- a/browser/components/loop/test/standalone/webapp_test.js
+++ b/browser/components/loop/test/standalone/webapp_test.js
@@ -226,16 +226,30 @@ describe("loop.webapp", function() {
                 state: "terminated",
                 reason: "reject"
               });
 
               TestUtils.findRenderedComponentWithType(ocView,
                 loop.webapp.FailedConversationView);
             });
 
+            it("should reset multiplexGum when a call is rejected",
+              function() {
+                var multiplexGum = new standaloneMedia._MultiplexGum();
+                standaloneMedia.setSingleton(multiplexGum);
+                sandbox.stub(standaloneMedia._MultiplexGum.prototype, "reset");
+
+                ocView._websocket.trigger("progress", {
+                  state: "terminated",
+                  reason: "reject"
+                });
+
+                sinon.assert.calledOnce(multiplexGum.reset);
+              });
+
             it("should display an error message if the reason is not 'cancel'",
               function() {
                 ocView._websocket.trigger("progress", {
                   state: "terminated",
                   reason: "reject"
                 });
 
                 sinon.assert.calledOnce(notifications.errorL10n);