Bug 1141059: ignore attempts to share e10s tabs in a Hello conversation. r=Standard8, a=lsblakk
authorMike de Boer <mdeboer@mozilla.com>
Tue, 10 Mar 2015 10:43:44 +0100
changeset 248120 6c5849a66b1ac07ce819846a578b44d1e8ba8b87
parent 248119 4037672fcc2adb6af5e821560bdb8defd62afe60
child 248121 8acc69cac05d31cfa5d9ef9aaaaece3be8fce29f
push id7762
push usermdeboer@mozilla.com
push dateMon, 16 Mar 2015 15:07:09 +0000
treeherdermozilla-aurora@9b59f3a2743d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, lsblakk
bugs1141059
milestone38.0a2
Bug 1141059: ignore attempts to share e10s tabs in a Hello conversation. r=Standard8, a=lsblakk
browser/components/loop/MozLoopAPI.jsm
browser/components/loop/content/shared/js/activeRoomStore.js
browser/components/loop/test/shared/activeRoomStore_test.js
--- a/browser/components/loop/MozLoopAPI.jsm
+++ b/browser/components/loop/MozLoopAPI.jsm
@@ -287,16 +287,25 @@ function injectLoopAPI(targetWindow) {
         if (!win || !browser) {
           // This may happen when an undocked conversation window is the only
           // window left.
           let err = new Error("No tabs available to share.");
           MozLoopService.log.error(err);
           listener(cloneValueInto(err, targetWindow));
           return;
         }
+        if (browser.getAttribute("remote") == "true") {
+          // Tab sharing is not supported yet for e10s-enabled browsers. This will
+          // be fixed in bug 1137634.
+          let err = new Error("Tab sharing is not supported for e10s-enabled browsers");
+          MozLoopService.log.error(err);
+          listener(cloneValueInto(err, targetWindow));
+          return;
+        }
+
         win.LoopUI.addBrowserSharingListener(listener);
 
         savedWindowListeners.set(listener, Cu.getWeakReference(win));
       }
     },
 
     /**
      * Removes a listener that was previously added.
--- a/browser/components/loop/content/shared/js/activeRoomStore.js
+++ b/browser/components/loop/content/shared/js/activeRoomStore.js
@@ -416,16 +416,19 @@ loop.store.ActiveRoomStore = (function()
      * Handles switching browser (aka tab) sharing to a new window. Should
      * only be used for browser sharing.
      *
      * @param {Number} windowId  The new windowId to start sharing.
      */
     _handleSwitchBrowserShare: function(err, windowId) {
       if (err) {
         console.error("Error getting the windowId: " + err);
+        this.dispatchAction(new sharedActions.ScreenSharingState({
+          state: SCREEN_SHARE_STATES.INACTIVE
+        }));
         return;
       }
 
       var screenSharingState = this.getStoreState().screenSharingState;
 
       if (screenSharingState === SCREEN_SHARE_STATES.INACTIVE) {
         // Screen sharing is still pending, so assume that we need to kick it off.
         var options = {
--- a/browser/components/loop/test/shared/activeRoomStore_test.js
+++ b/browser/components/loop/test/shared/activeRoomStore_test.js
@@ -826,16 +826,28 @@ describe("loop.store.ActiveRoomStore", f
     });
 
     it("should update the SDK driver when a new window id is received", function() {
       listener(null, 72);
 
       sinon.assert.calledOnce(fakeSdkDriver.switchAcquiredWindow);
       sinon.assert.calledWithExactly(fakeSdkDriver.switchAcquiredWindow, 72);
     });
+
+    it("should end the screen sharing session when the listener receives an error", function() {
+      listener(new Error("foo"));
+
+      // The dispatcher was already called once in beforeEach().
+      sinon.assert.calledTwice(dispatcher.dispatch);
+      sinon.assert.calledWith(dispatcher.dispatch,
+        new sharedActions.ScreenSharingState({
+          state: SCREEN_SHARE_STATES.INACTIVE
+        }));
+      sinon.assert.notCalled(fakeSdkDriver.switchAcquiredWindow);
+    });
   });
 
   describe("#endScreenShare", function() {
     it("should set the state to 'inactive'", function() {
       store.endScreenShare();
 
       sinon.assert.calledOnce(dispatcher.dispatch);
       sinon.assert.calledWith(dispatcher.dispatch,