Bug 1265796 - allow inspector test cases to wait for pending edits to complete draft
authorTom Tromey <tom@tromey.com>
Thu, 15 Sep 2016 13:06:37 -0600
changeset 414621 9b723538ab85040fafed94043a9a91ed7322a44d
parent 414620 0514aa5341f153151d7b19520391f10d75305c4b
child 531488 bf814c126fdd4e2700bb0460d495e8011ad3c086
push id29724
push userbmo:ttromey@mozilla.com
push dateFri, 16 Sep 2016 21:16:12 +0000
bugs1265796
milestone51.0a1
Bug 1265796 - allow inspector test cases to wait for pending edits to complete MozReview-Commit-ID: CKyDRdZ4lhd
devtools/client/inspector/rules/rules.js
devtools/client/inspector/rules/test/head.js
--- a/devtools/client/inspector/rules/rules.js
+++ b/devtools/client/inspector/rules/rules.js
@@ -808,33 +808,44 @@ CssRuleView.prototype = {
         this._stopSelectingElement();
         this._clearRules();
       }
       console.error(e);
     });
   },
 
   /**
+   * Return a promise that is resolved when any pending edits have
+   * been settled.
+   */
+  waitForPendingEdits: function () {
+    let promises = [];
+
+    if (this._elementStyle) {
+      for (let rule of this._elementStyle.rules) {
+        if (rule._applyingModifications) {
+          promises.push(rule._applyingModifications);
+        }
+      }
+    }
+
+    return promise.all(promises);
+  },
+
+  /**
    * Update the rules for the currently highlighted element.
    */
   refreshPanel: function () {
     // Ignore refreshes during editing or when no element is selected.
     if (this.isEditing || !this._elementStyle) {
       return promise.resolve(undefined);
     }
 
     // Repopulate the element style once the current modifications are done.
-    let promises = [];
-    for (let rule of this._elementStyle.rules) {
-      if (rule._applyingModifications) {
-        promises.push(rule._applyingModifications);
-      }
-    }
-
-    return promise.all(promises).then(() => {
+    return this.waitForPendingEdits().then(() => {
       return this._populate();
     });
   },
 
   /**
    * Clear the pseudo class options panel by removing the checked and disabled
    * attributes for each checkbox.
    */
--- a/devtools/client/inspector/rules/test/head.js
+++ b/devtools/client/inspector/rules/test/head.js
@@ -181,16 +181,17 @@ var focusEditableField = Task.async(func
  * @param {CSSRuleView} view
  */
 function* hideTooltipAndWaitForRuleViewChanged(editorTooltip, view) {
   let onModified = view.once("ruleview-changed");
   let onHidden = editorTooltip.tooltip.once("hidden");
   editorTooltip.hide();
   yield onModified;
   yield onHidden;
+  yield view.waitForPendingEdits();
 }
 
 /**
  * Polls a given generator function waiting for it to return true.
  *
  * @param {Function} validatorFn
  *        A validator generator function that returns a boolean.
  *        This is called every few milliseconds to check if the result is true.