Bug 1284259 - Prevent exception while dismissing event tooltip details. r=jdescottes draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 13 Jul 2016 13:15:01 +0200
changeset 387171 5b59319ed5b9790957fc2c1d30ab49d191fb6b76
parent 387029 b6edea2fa69057a42c7c24e76e583bb9bad86f98
child 387172 eb47f8c887f8d2235617ef6a092304d3f6120af4
child 387183 a0add460c4dbdaaf012c9879cceb023a0159f9c7
push id22900
push userjdescottes@mozilla.com
push dateWed, 13 Jul 2016 13:52:39 +0000
reviewersjdescottes
bugs1284259
milestone50.0a1
Bug 1284259 - Prevent exception while dismissing event tooltip details. r=jdescottes MozReview-Commit-ID: 4BjCwSv8QdB
devtools/client/inspector/markup/markup.js
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -2640,35 +2640,33 @@ function MarkupElementContainer(markupVi
   } else {
     throw new Error("Invalid node for MarkupElementContainer");
   }
 
   this.tagLine.appendChild(this.editor.elt);
 }
 
 MarkupElementContainer.prototype = Heritage.extend(MarkupContainer.prototype, {
-  _buildEventTooltipContent: function (target, tooltip) {
+  _buildEventTooltipContent: Task.async(function* (target, tooltip) {
     if (target.hasAttribute("data-event")) {
-      tooltip.hide(target);
-
-      this.node.getEventListenerInfo().then(listenerInfo => {
-        let toolbox = this.markup._inspector.toolbox;
-        setEventTooltip(tooltip, listenerInfo, toolbox);
-        // Disable the image preview tooltip while we display the event details
-        this.markup._disableImagePreviewTooltip();
-        tooltip.once("hidden", () => {
-          // Enable the image preview tooltip after closing the event details
-          this.markup._enableImagePreviewTooltip();
-        });
-        tooltip.show(target);
+      yield tooltip.hide();
+
+      let listenerInfo = yield this.node.getEventListenerInfo();
+
+      let toolbox = this.markup._inspector.toolbox;
+      setEventTooltip(tooltip, listenerInfo, toolbox);
+      // Disable the image preview tooltip while we display the event details
+      this.markup._disableImagePreviewTooltip();
+      tooltip.once("hidden", () => {
+        // Enable the image preview tooltip after closing the event details
+        this.markup._enableImagePreviewTooltip();
       });
-      return true;
+      tooltip.show(target);
     }
-    return undefined;
-  },
+  }),
 
   /**
    * Generates the an image preview for this Element. The element must be an
    * image or canvas (@see isPreviewable).
    *
    * @return {Promise} that is resolved with an object of form
    *         { data, size: { naturalWidth, naturalHeight, resizeRatio } } where
    *         - data is the data-uri for the image preview.