Bug 1265796 - allow inspector test cases to wait for pending edits to complete
MozReview-Commit-ID: CKyDRdZ4lhd
--- 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.