Bug 1241707 - [e10s] Web Console should restore focus to proper place when closed. r=jryans,r=bgrins
authorLin Clark <lclark@mozilla.com>
Tue, 16 Feb 2016 14:37:45 -0800
changeset 284498 b8003b4c63c378bd43065f6faf540b5288d9f617
parent 284497 39742e742b69087a03366c396d365e03e5df997d
child 284499 d5b329a9cd6bf24394d62a489991362d16973276
push id30004
push usercbook@mozilla.com
push dateWed, 17 Feb 2016 11:07:54 +0000
treeherdermozilla-central@c007ec81b75a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans, bgrins
bugs1241707
milestone47.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 1241707 - [e10s] Web Console should restore focus to proper place when closed. r=jryans,r=bgrins MozReview-Commit-ID: JlcJPGygm5F
devtools/client/webconsole/hudservice.js
devtools/server/actors/webbrowser.js
devtools/shared/client/main.js
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -7,16 +7,17 @@
 "use strict";
 
 const {Cc, Ci, Cu} = require("chrome");
 
 var WebConsoleUtils = require("devtools/shared/webconsole/utils").Utils;
 var Heritage = require("sdk/core/heritage");
 var {TargetFactory} = require("devtools/client/framework/target");
 var {Tools} = require("devtools/client/definitions");
+const { Task } = require("resource://gre/modules/Task.jsm");
 var promise = require("promise");
 
 loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
 loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
 loader.lazyRequireGetter(this, "WebConsoleFrame", "devtools/client/webconsole/webconsole", true);
 loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
 loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
 loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/main", true);
@@ -582,29 +583,28 @@ WebConsole.prototype = {
     if (this.chromeUtilsWindow && this.mainPopupSet) {
       let popupset = this.mainPopupSet;
       let panels = popupset.querySelectorAll("panel[hudId=" + this.hudId + "]");
       for (let panel of panels) {
         panel.hidePopup();
       }
     }
 
-    let onDestroy = function WC_onDestroyUI() {
+    let onDestroy = Task.async(function*() {
       try {
-        let tabWindow = this.target.isLocalTab ? this.target.window : null;
-        tabWindow && tabWindow.focus();
+        yield this.target.activeTab.focus()
       }
       catch (ex) {
         // Tab focus can fail if the tab or target is closed.
       }
 
       let id = WebConsoleUtils.supportsString(this.hudId);
       Services.obs.notifyObservers(id, "web-console-destroyed", null);
       this._destroyer.resolve(null);
-    }.bind(this);
+    }.bind(this));
 
     if (this.ui) {
       this.ui.destroy().then(onDestroy);
     }
     else {
       onDestroy();
     }
 
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -1395,16 +1395,26 @@ TabActor.prototype = {
     if (!this._detach()) {
       return { error: "wrongState" };
     }
 
     return { type: "detached" };
   },
 
   /**
+   * Bring the tab's window to front.
+   */
+  onFocus: function() {
+    if (this.window) {
+      this.window.focus();
+    }
+    return {};
+  },
+
+  /**
    * Reload the page in this tab.
    */
   onReload: function(aRequest) {
     let force = aRequest && aRequest.options && aRequest.options.force;
     // Wait a tick so that the response packet can be dispatched before the
     // subsequent navigation event packet.
     Services.tm.currentThread.dispatch(DevToolsUtils.makeInfallible(() => {
       // This won't work while the browser is shutting down and we don't really
@@ -1895,16 +1905,17 @@ TabActor.prototype = {
 };
 
 /**
  * The request types this actor can handle.
  */
 TabActor.prototype.requestTypes = {
   "attach": TabActor.prototype.onAttach,
   "detach": TabActor.prototype.onDetach,
+  "focus": TabActor.prototype.onFocus,
   "reload": TabActor.prototype.onReload,
   "navigateTo": TabActor.prototype.onNavigateTo,
   "reconfigure": TabActor.prototype.onReconfigure,
   "switchToFrame": TabActor.prototype.onSwitchToFrame,
   "listFrames": TabActor.prototype.onListFrames,
   "listWorkers": TabActor.prototype.onListWorkers
 };
 
--- a/devtools/shared/client/main.js
+++ b/devtools/shared/client/main.js
@@ -1311,16 +1311,23 @@ TabClient.prototype = {
     after: function (aResponse) {
       this.client.unregisterClient(this);
       return aResponse;
     },
     telemetry: "TABDETACH"
   }),
 
   /**
+   * Bring the window to the front.
+   */
+  focus: DebuggerClient.requester({
+    type: "focus"
+  }, {}),
+
+  /**
    * Reload the page in this tab.
    *
    * @param [optional] object options
    *        An object with a `force` property indicating whether or not
    *        this reload should skip the cache
    */
   reload: function(options = { force: false }) {
     return this._reload(options);