Bug 1209295 - Ensure browser_ruleview_add-property-cancel_02.js waits for the correct change notification. r?pbrosset draft
authorSami Jaktholm <sjakthol@outlook.com>
Tue, 22 Dec 2015 21:58:16 +0200
changeset 317185 122e8d9d27cb7f34aceb173e8121bc4edb331d41
parent 317010 3cc8559d0d65d5704eedc72238a82c09b4b630cd
child 512270 ffc941b3a1dfb3eb812edd7ca29b7a5e31b02e7e
push id8668
push usersjakthol@outlook.com
push dateWed, 23 Dec 2015 06:14:38 +0000
reviewerspbrosset
bugs1209295
milestone46.0a1
Bug 1209295 - Ensure browser_ruleview_add-property-cancel_02.js waits for the correct change notification. r?pbrosset
devtools/client/styleinspector/test/browser_ruleview_add-property-cancel_02.js
--- a/devtools/client/styleinspector/test/browser_ruleview_add-property-cancel_02.js
+++ b/devtools/client/styleinspector/test/browser_ruleview_add-property-cancel_02.js
@@ -49,16 +49,28 @@ add_task(function*() {
   is(elementRuleEditor.propertyList.children.length, 2,
     "Created a property editor.");
   is(editor, inplaceEditor(textProp.editor.valueSpan),
     "Editing the value span now.");
 
   info("Entering a property value");
   editor.input.value = "red";
 
+  // Setting the input value above schedules a preview to be shown in 10ms
+  // which triggers a ruleview-changed event. If the event arrives at just the
+  // right moment after pressing escape but before the new property is removed
+  // from the rule view (it's done after a tick), the test continues too soon
+  // and the assertions below fail as the new property is still there (bug
+  // 1209295).
+  //
+  // Thus, wait for the ruleview-changed event triggered by the preview before
+  // continuing to discard the new property.
+  info("Waiting for preview to be applied.");
+  yield view.once("ruleview-changed");
+
   info("Escaping out of the field");
   onRuleViewChanged = view.once("ruleview-changed");
   EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
   yield onRuleViewChanged;
 
   is(view.styleDocument.body, view.styleDocument.activeElement,
     "Correct element has focus");