Closed Bug 1166774 Opened 9 years ago Closed 9 years ago

Stop using applyingModification in styleinspector tests

Categories

(DevTools :: Inspector, defect)

defect
Not set
normal

Tracking

(firefox42 fixed)

RESOLVED FIXED
Firefox 42
Tracking Status
firefox42 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 7 obsolete files)

http://mxr.mozilla.org/mozilla-central/search?string=applyingModification
There is quite a bunch of them! And it is very error prone!
From what I've seen many tests are wrong, and either do not wait or are pretenting to wait whereas there is no actual modification being made!

Instead, like many other tests (and even some of these tests), we should be listening for ruleview-changed.

The issue with this transient attribute is:
- it is private,
- deep, in ruleview.rule
- transient and sometimes null, and that's the main error we have!
  Sometimes we do `yield view.rule.applyingModication`, whereas it is null and so, do not wait. In many cases, we fetch applyingModification promise *before* running the code that will actually create it, so we are saving nothing and then yield on undefined/null, so that we don't wait. I've even seen wrong assertions after that. Asserting for wrong values, because we weren't waiting for the actual state modification :s

I think we can get rid of all test usages!
Also, we should add some new wait, in order to correctly wait for test end,
as it broke my toolbox cleanup patch from bug 1161072.
Component: Developer Tools: Framework → Developer Tools: Inspector
Assignee: nobody → poirot.alex
Attached patch patch (obsolete) — Splinter Review
rebased.
Attachment #8608696 - Attachment is obsolete: true
Comment on attachment 8608777 [details] [diff] [review]
patch

You may discover in this patch that there is more ruleview updates than expected,
this isn't the goal of this patch to address that. The only mission here is to have sane tests, without any pending requests!
I picked you randomly as inspector expert and all things related to it,
but feel free to redirect the upcoming reviews...
Attachment #8608777 - Flags: review?(pbrosset)
Comment on attachment 8608777 [details] [diff] [review]
patch

Review of attachment 8608777 [details] [diff] [review]:
-----------------------------------------------------------------

This all looks pretty good.
Can you just take a look at whether we can introduce a new event instead of waiting for several "changed" events in a row (see comment below).

::: browser/devtools/styleinspector/rule-view.js
@@ +716,5 @@
> +                 .then(() => {
> +                   // Ensure dispatching a ruleview-changed event
> +                   // also for previews
> +                   this.elementStyle._changed()
> +                 });

This seems like the right fix to do, but the formatting is odd, why not:

modifications.apply().then(() => {
  // Make sure we dispatch a ruleview-changed event also for previews.
  this.elementStyle._changed();
});

Also, missing semicolon after _changed()

(yes this is very nit, but I'm working on adding eslint at the moment, so I look at this a lot :) )

::: browser/devtools/styleinspector/test/browser_ruleview_edit-property-commit.js
@@ +66,2 @@
>    is(inplaceEditor(propEditor.valueSpan), editor, "Focused editor should be the value span.");
> +  // Focusing the input dispatch a "starts editing" event

s/dispatch/dispatches

@@ +66,3 @@
>    is(inplaceEditor(propEditor.valueSpan), editor, "Focused editor should be the value span.");
> +  // Focusing the input dispatch a "starts editing" event
> +  // and so update the property value

s/update/updates

::: browser/devtools/styleinspector/test/browser_ruleview_edit-property-increments.js
@@ +153,2 @@
>    let editor = yield focusEditableField(propertyEditor.valueSpan);
> +  yield onRuleViewChanged;

It looks like this should be done inside focusEditableField instead. A lot of other tests need this and may get it wrong too.

::: browser/devtools/styleinspector/test/browser_ruleview_filtereditor-appears-on-swatch-click.js
@@ +22,3 @@
>    swatch.click();
>    yield onShow;
> +  // Clicking on swatch run a preview of the current value

s/run/runs

@@ +22,4 @@
>    swatch.click();
>    yield onShow;
> +  // Clicking on swatch run a preview of the current value
> +  // and update the rule-view

s/update/updates

::: browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_01.js
@@ +37,3 @@
>  function* testCreateNewMultiUnfinished(inspector, ruleEditor, view) {
>    let onMutation = inspector.once("markupmutation");
> +  // There is 6 rule-view updates, one for the rule view creation,

Shouldn't we introduce a new event in rule-view that fires at the end of it all? Waiting for 6 events seems random and prone to break in the future.
Attachment #8608777 - Flags: review?(pbrosset)
Blocks: 1168369
Attached patch patch v2 (obsolete) — Splinter Review
https://treeherder.mozilla.org/#/jobs?repo=try&revision=d5e810968376

(In reply to Patrick Brosset [:pbrosset] [:patrick] [:pbro] from comment #4)
> Comment on attachment 8608777 [details] [diff] [review]
> :::
> browser/devtools/styleinspector/test/browser_ruleview_edit-property-
> increments.js
> @@ +153,2 @@
> >    let editor = yield focusEditableField(propertyEditor.valueSpan);
> > +  yield onRuleViewChanged;
> 
> It looks like this should be done inside focusEditableField instead. A lot
> of other tests need this and may get it wrong too.

Yep... I also did same thing for simulateColorPickerChange!
I end up modifying much more tests in the patch.

> :::
> browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-
> unfinished_01.js
> @@ +37,3 @@
> >  function* testCreateNewMultiUnfinished(inspector, ruleEditor, view) {
> >    let onMutation = inspector.once("markupmutation");
> > +  // There is 6 rule-view updates, one for the rule view creation,
> 
> Shouldn't we introduce a new event in rule-view that fires at the end of it
> all? Waiting for 6 events seems random and prone to break in the future.

I think that's ok, the test is just highlighting the facts.
The rule-view is updates too many times!
I opened bug 1168369 in order to figure this out.
Attachment #8608777 - Attachment is obsolete: true
Attachment #8610540 - Flags: review?(pbrosset)
Comment on attachment 8610540 [details] [diff] [review]
patch v2

Review of attachment 8610540 [details] [diff] [review]:
-----------------------------------------------------------------

The interdiff looks nice, thanks for this. And, as discussed, I'm ok to deal with the 6-times updating problem in the follow-up bug you filed.

::: browser/devtools/styleinspector/test/head.js
@@ +425,5 @@
> +  let onEdit = inplaceEditor(editable.ownerDocument.activeElement);
> +
> +  // Focusing the name or value input is going to fire a preview and update the rule view
> +  if (editable.classList.contains("ruleview-propertyname") ||
> +      editable.classList.contains("ruleview-propertyvalue")) {

nit: Could you create a boolean var for this condition so you can also use it to wrap the onRuleViewChanged initialization. I guess you don't even want to listen once to "ruleview-changed" if that's falsy.
Attachment #8610540 - Flags: review?(pbrosset) → review+
Attachment #8610570 - Flags: review+
Backed out in https://hg.mozilla.org/integration/fx-team/rev/25932df8b78c for frequent e10s failures in browser_ruleview_colorpicker-edit-gradient.js like https://treeherder.mozilla.org/logviewer.html#?job_id=3222807&repo=fx-team
Can't reproduce locally, nor on try :x
  https://treeherder.mozilla.org/#/jobs?repo=try&revision=c304991e2998
Unless that's related to some very recent change to master as this try is on top of yesterday's tip

Another try with some debug logs, on top of more recent tip, still pending:
  https://treeherder.mozilla.org/#/jobs?repo=try&revision=7747bdb84f11
No longer blocks: 1139058
Attached patch 1166774.patch (obsolete) — Splinter Review
Since bug 1139058 landed ahead of this, I added a patch that will adjust the tests touched in bug 1139058 to the new style. 

Interdiff: https://bugzilla.mozilla.org/attachment.cgi?oldid=8610570&action=interdiff&newid=8612136&headers=1
Attached patch patch v4 (obsolete) — Splinter Review
Rebased with attachment 8612136 [details] [diff] [review].
Attachment #8610570 - Attachment is obsolete: true
Attachment #8612136 - Attachment is obsolete: true
A triggerred many mochitest-devtools and couldn't reproduce this intermittent once,
so I'm trying to reland it.
I've been fooled again by treeherder readability!
But philor helped me by highlighting that's not a try vs fx-team issue...
It's failing on e10s while I wasn't asking for e10s mochitest-devtools to run on try.
New try:
  https://treeherder.mozilla.org/#/jobs?repo=try&revision=5b4619fbcc94
I'm not able to reproduce this failure locally, last time I push to try it was also passing :/
Attached patch patch v5 (obsolete) — Splinter Review
Tentative fix...

https://treeherder.mozilla.org/#/jobs?repo=try&revision=56287ffdbcea
Attachment #8612357 - Attachment is obsolete: true
Comment on attachment 8631491 [details] [diff] [review]
patch v6

Review of attachment 8631491 [details] [diff] [review]:
-----------------------------------------------------------------

Brian, Do you mind stamping this patch?
I highlighter the only one change I made compared to the patch Patrick reviewed.

::: browser/devtools/styleinspector/test/browser_ruleview_colorpicker-edit-gradient.js
@@ +66,5 @@
> +    element: content.document.body,
> +    name: "backgroundImage",
> +    value: "linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)"
> +  };
> +  yield simulateColorPickerChange(view, cPicker, [1, 1, 1, 1], change);

I just added this `change` callback, to ensure blocking on simulateColorPickerChange until the change is applied to the remote content document.
Attachment #8631491 - Flags: review?(bgrinstead)
Comment on attachment 8631491 [details] [diff] [review]
patch v6

Review of attachment 8631491 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/devtools/styleinspector/test/browser_ruleview_colorpicker-edit-gradient.js
@@ +66,5 @@
> +    element: content.document.body,
> +    name: "backgroundImage",
> +    value: "linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)"
> +  };
> +  yield simulateColorPickerChange(view, cPicker, [1, 1, 1, 1], change);

rs=me assuming this is the only change (interdiff isn't working unfortunately: https://bugzilla.mozilla.org/attachment.cgi?oldid=8630425&action=interdiff&newid=8631491&headers=1)
Attachment #8631491 - Flags: review?(bgrinstead) → review+
Try looks really green, let's try to land this new patch...
  https://treeherder.mozilla.org/#/jobs?repo=try&revision=fb77c999f083
https://hg.mozilla.org/mozilla-central/rev/d9cd99380d06
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 42
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: