Bug 1358267 - Abort RDM set size when closing. r=gl draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 01 Jun 2017 09:48:42 -0500
changeset 588319 b5dc26b031ed97a45b8c90d255794e7dc8bf61f5
parent 586536 39d5cc0fda5e16c49a59d29d4ca186a5534cc88b
child 631546 2dbbcf5e95334dd0bb5d05895ff5c1f14a10fa61
push id62003
push userbmo:jryans@gmail.com
push dateFri, 02 Jun 2017 17:52:05 +0000
reviewersgl
bugs1358267
milestone55.0a1
Bug 1358267 - Abort RDM set size when closing. r=gl MozReview-Commit-ID: 9noch5Bgu9q
devtools/client/responsivedesign/responsivedesign.jsm
--- a/devtools/client/responsivedesign/responsivedesign.jsm
+++ b/devtools/client/responsivedesign/responsivedesign.jsm
@@ -358,17 +358,19 @@ ResponsiveUI.prototype = {
                 "max-height: none;" +
                 "min-height: 0;";
     debug("RESET STACK SIZE");
     this.stack.setAttribute("style", style);
 
     // Wait for resize message before stopping in the child when testing,
     // but only if we should expect to still get a message.
     if (flags.testing && this.tab.linkedBrowser.messageManager) {
+      debug("CLOSE: WAIT ON CONTENT RESIZE");
       yield this.waitForMessage("ResponsiveMode:OnContentResize");
+      debug("CLOSE: CONTENT RESIZE DONE");
     }
 
     if (this.isResizing) {
       this.stopResizing();
     }
 
     // Remove listeners.
     this.menulist.removeEventListener("select", this.boundPresetSelected, true);
@@ -400,29 +402,34 @@ ResponsiveUI.prototype = {
     this.container.removeAttribute("responsivemode");
     this.stack.removeAttribute("responsivemode");
 
     ActiveTabs.delete(this.tab);
     if (this.touchEventSimulator) {
       this.touchEventSimulator.stop();
     }
 
+    debug("CLOSE: WAIT ON CLIENT CLOSE");
     yield this.client.close();
+    debug("CLOSE: CLIENT CLOSE DONE");
     this.client = this.emulationFront = null;
 
     this._telemetry.toolClosed("responsive");
 
     if (this.tab.linkedBrowser && this.tab.linkedBrowser.messageManager) {
       let stopped = this.waitForMessage("ResponsiveMode:Stop:Done");
       this.tab.linkedBrowser.messageManager.sendAsyncMessage("ResponsiveMode:Stop");
+      debug("CLOSE: WAIT ON STOP");
       yield stopped;
+      debug("CLOSE: STOP DONE");
     }
 
     this.hideNewUINotification();
 
+    debug("CLOSE: DONE, EMIT OFF");
     this.inited = null;
     ResponsiveUIManager.emit("off", { tab: this.tab });
   }),
 
   waitForMessage(message) {
     return new Promise(resolve => {
       let listener = () => {
         this.mm.removeMessageListener(message, listener);
@@ -1124,16 +1131,20 @@ ResponsiveUI.prototype = {
     };
   },
 
   /**
    * Change the size of the viewport.
    */
   setViewportSize({ width, height }) {
     debug(`SET SIZE TO ${width} x ${height}`);
+    if (this.closing) {
+      debug(`ABORT SET SIZE, CLOSING`);
+      return;
+    }
     if (width) {
       this.setWidth(width);
     }
     if (height) {
       this.setHeight(height);
     }
   },