Closed Bug 1067411 Opened 10 years ago Closed 10 years ago

Enable waiting for popup animations as bug 994117 is fixed and expose the method as a more general one

Categories

(Mozilla QA Graveyard :: Mozmill Tests, defect, P1)

defect

Tracking

(firefox32 wontfix, firefox33 fixed, firefox34 fixed, firefox35 fixed, firefox-esr31 wontfix)

RESOLVED FIXED
Tracking Status
firefox32 --- wontfix
firefox33 --- fixed
firefox34 --- fixed
firefox35 --- fixed
firefox-esr31 --- wontfix

People

(Reporter: danisielm, Assigned: danisielm)

References

Details

Attachments

(1 file, 4 obsolete files)

As we were fixing bug 994040, we did a workaround for waiting for panels/popups as the animations were broken due to bug 994117. That was to disable them.

But now that was fixed, the old animations are back in place, so we can update our code to wait for a popup using the correct events.

We really need this especially for bug 908649, where the panel is not initialized at firefox start-up for memory saving, so in this case we don't actually have the element loaded before.
Summary: Enable waiting for popup anumations as bug 994117 was fixed → Enable waiting for popup animations as bug 994117 is fixed
Well, the dependency has been already fixed for Firefox 33.0, so the code is in the tree for about 2 months now. For stability reasons I would consider to backport it down to beta, as where the patch originally landed.
Attached patch v1.patch (obsolete) — Splinter Review
Waiting for "popupshown" & "popuphidden" is now enough to wait for the panels.
I've moved the function outside the locationBar scope so we can call it for every popup panel (e.g.: the downloads panel)

Also ran our all testruns on all platforms and I got no failure. 
(https://pastebin.mozilla.org/6526459)
Attachment #8490689 - Flags: review?(andrei.eftimie)
Attachment #8490689 - Flags: review?(andreea.matei)
Summary: Enable waiting for popup animations as bug 994117 is fixed → Enable waiting for popup animations as bug 994117 is fixed and expose the method as a more general one
Comment on attachment 8490689 [details] [diff] [review]
v1.patch

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

In general this looks good, a few notes inline.

::: firefox/lib/toolbars.js
@@ +868,5 @@
> + * Waits for a notification popup panel
> + *
> + * @param {function} aCallback
> + *        Function that triggers the panel to open/close
> + * @param {object} aSpec

This is also optional.

@@ +877,5 @@
> + *        Element to use for waiting for the events (usually same as the panel)
> + * @param {boolean} [aSpec.open=true]
> + *        True if the notification should be open
> + */
> +function waitForNotification(aCallback, aSpec) {

If you want to be able to use this outside of the locationbar you will also need to export it, otherwise it will only be available in this file. I guess this will be fine if the download panel (or any other consumers) will also live here.

@@ +882,5 @@
> +  var spec = aSpec || {};
> +
> +  assert.equal(typeof aCallback, "function", "Callback function is defined");
> +
> +  var open = (spec.open == undefined) ? true : spec.open;

Since we have a binary state (open|closed) we should assert that we are in the opposite state of the requested state. Otherwise it might get hard to track down a failure.
Attachment #8490689 - Flags: review?(andrei.eftimie)
Attachment #8490689 - Flags: review?(andreea.matei)
Attachment #8490689 - Flags: review-
(In reply to Andrei Eftimie from comment #3)
> ::: firefox/lib/toolbars.js
> @@ +868,5 @@
> > + * Waits for a notification popup panel
> > + *
> > + * @param {function} aCallback
> > + *        Function that triggers the panel to open/close
> > + * @param {object} aSpec
> 
> This is also optional.
> 

Actually it's not optional. I made spec.panel optional by mistake. 
I will also make an assert for it.

I did it this way so we can handle the case where panel is not initialized & we can add a parent element on which the event propagates. But we can make panel mandatory so we pass a MozMillElement even before it is initialized.

> @@ +882,5 @@
> > +  var spec = aSpec || {};
> > +
> > +  assert.equal(typeof aCallback, "function", "Callback function is defined");
> > +
> > +  var open = (spec.open == undefined) ? true : spec.open;
> 
> Since we have a binary state (open|closed) we should assert that we are in
> the opposite state of the requested state. Otherwise it might get hard to
> track down a failure.

We have Bug 1044987 to handle this. 
What we actually need to do is to first check that the element is initialized and if it is, we have to check that is open (in the case we want to close it) or if it's closed (in case we want to open it).

Otherwise, it's surely closed.
Attached patch v1.1.patch (obsolete) — Splinter Review
Attachment #8490689 - Attachment is obsolete: true
Attachment #8490747 - Flags: review?(andrei.eftimie)
Attachment #8490747 - Flags: review?(andreea.matei)
Comment on attachment 8490747 [details] [diff] [review]
v1.1.patch

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

I would like to get a couple improvements here. With those fixed I'll get this landed.
I'm thinking whether to also get bug 1044987 included here - we don't seem to make much progress over there... but this is not a blocker, so either way is fine for me.

::: firefox/lib/toolbars.js
@@ +883,5 @@
> +
> +  assert.equal(typeof aCallback, "function", "Callback function is defined");
> +  assert.ok(spec.panel, "Panel has to be specified");
> +
> +  var open = (spec.open == undefined) ? true : spec.open;

If we're already here we should improve this a bit.
- to check for undefined we should use typeof
- we can replace the ternary operator with the or operator since the first evaluation already returns `true`
- we should cast the received value as a boolean

> var open = typeof spec.open === "undefined" || !!spec.open;

@@ +885,5 @@
> +  assert.ok(spec.panel, "Panel has to be specified");
> +
> +  var open = (spec.open == undefined) ? true : spec.open;
> +  var eventType = open ? "popupshown" : "popuphidden";
> +  var parent = spec.parent ? spec.parent : spec.panel.getNode();

Can be simplified:
> var parent = spec.parent || spec.panel.getNode();
Attachment #8490747 - Flags: review?(andrei.eftimie)
Attachment #8490747 - Flags: review?(andreea.matei)
Attachment #8490747 - Flags: review-
Attached patch v1.2.patch (obsolete) — Splinter Review
Updated as requested.
Attachment #8490747 - Attachment is obsolete: true
Attachment #8491421 - Flags: review?(andrei.eftimie)
Attachment #8491421 - Flags: review?(hskupin)
Attachment #8491421 - Flags: review?(andrei.eftimie)
Attachment #8491421 - Flags: review+
Comment on attachment 8491421 [details] [diff] [review]
v1.2.patch

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

::: firefox/lib/toolbars.js
@@ +822,5 @@
>      switch (spec.type) {
>        case "notification":
>          panel = this.getElement({type: "notification_popup"});
>          break;
>        case "bookmark":

This should also be moved out here. This doesn't belong to the location bar. Please file a separate bug for it.

@@ +883,5 @@
> +
> +  assert.equal(typeof aCallback, "function", "Callback function is defined");
> +  assert.ok(spec.panel, "Panel has to be specified");
> +
> +  var open = typeof spec.open === "undefined" || !!spec.open;

Something I mention nearly each time, please put () brackes around the comparison.

I do not understand why we have to do the !!spec.open here, given that we already require a boolean to be passed in.

@@ +890,5 @@
> +  if (open) {
> +    if (spec.panel.getNode()) {
> +      expect.equal(spec.panel.getNode().state, "closed",
> +                   "Panel is in the correct state");
> +    }

Why the if condition here? If it can be that the panel doesn't exist, line 902 will also fail in case no parent is given.
Attachment #8491421 - Flags: review?(hskupin) → review-
(In reply to Henrik Skupin (:whimboo) from comment #8) 
> @@ +883,5 @@
> > +
> > +  assert.equal(typeof aCallback, "function", "Callback function is defined");
> > +  assert.ok(spec.panel, "Panel has to be specified");
> > +
> > +  var open = typeof spec.open === "undefined" || !!spec.open;
> 
> Something I mention nearly each time, please put () brackes around the
> comparison.

This was my suggestion.
I still can't really see the use of braces that don't serve any purpose... One might argue that they provide more readability, but that's not really the case. It's pretty clear what is happening here.

I won't fight it though.

> I do not understand why we have to do the !!spec.open here, given that we
> already require a boolean to be passed in.

We don't actually check or enforce that anywhere else...
Blocks: 1069325
Attached patch v1.3.patch (obsolete) — Splinter Review
Patch updated based on review so I guess we can get it landed.
Attachment #8491421 - Attachment is obsolete: true
Attachment #8491491 - Flags: review?(andrei.eftimie)
(In reply to Henrik Skupin (:whimboo) from comment #8)
> Comment on attachment 8491421 [details] [diff] [review]
> v1.2.patch
> 
> Review of attachment 8491421 [details] [diff] [review]:
> -----------------------------------------------------------------
> @@ +890,5 @@
> > +  if (open) {
> > +    if (spec.panel.getNode()) {
> > +      expect.equal(spec.panel.getNode().state, "closed",
> > +                   "Panel is in the correct state");
> > +    }
> 
> Why the if condition here? If it can be that the panel doesn't exist, line
> 902 will also fail in case no parent is given.

For that case when panel node is not already loaded in the DOM, like the DownloadsPanel.
So in case "spec.panel.getNode()" is null, parent should be defined!
I added this test.
(In reply to Andrei Eftimie from comment #9)
> I still can't really see the use of braces that don't serve any purpose...
> One might argue that they provide more readability, but that's not really
> the case. It's pretty clear what is happening here.

The thing here is that you have 3 operands in this single expression. It's indeed not necessary for evaluating it correctly, but what we always agreed on in the past, is that it improves the readability a lot.

> > I do not understand why we have to do the !!spec.open here, given that we
> > already require a boolean to be passed in.
> 
> We don't actually check or enforce that anywhere else...

That's only the problem of Javascript, because it has no strong type definitions. It should already raise when the consumer uses a wrong calling convention and e.g. uses a string here. If we would try to start testing for the right type, we would have to change a lot of files in our repository.

I would say as long as the method declares the type of the parameter correctly, the consumer has to use the right type.
Status: NEW → ASSIGNED
Comment on attachment 8491491 [details] [diff] [review]
v1.3.patch

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

Looks and works fine, fixed what Henrik requested prior.
Attachment #8491491 - Flags: review?(hskupin)
Attachment #8491491 - Flags: review?(andrei.eftimie)
Attachment #8491491 - Flags: review+
Comment on attachment 8491491 [details] [diff] [review]
v1.3.patch

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

Looks good. If all runs fine please get it landed.
Attachment #8491491 - Flags: review?(hskupin) → review+
Attached patch v1.4.patchSplinter Review
Updated the commit message.

Testruns with Nightly on Mac, Linux & Windows runs fine.
I suggest we first land this on nightly, wait for 1-2 days to see how it's working and then backport on Aurora & Beta.
Attachment #8491491 - Attachment is obsolete: true
Attachment #8493142 - Flags: checkin?(andrei.eftimie)
Comment on attachment 8493142 [details] [diff] [review]
v1.4.patch

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

Landed:
https://hg.mozilla.org/qa/mozmill-tests/rev/326852e464c1 (default)
Attachment #8493142 - Flags: review+
Attachment #8493142 - Flags: checkin?(andrei.eftimie)
Attachment #8493142 - Flags: checkin+
All works fine on Aurora as well.

Transplanted:
https://hg.mozilla.org/qa/mozmill-tests/rev/006824b75a28 (mozilla-aurora)
All tests work fine against Beta as well, lets close this issue.

Transplanted:
https://hg.mozilla.org/qa/mozmill-tests/rev/d6ff18ef0ecf (mozilla-beta)

Thanks Daniel for the work here.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Blocks: 1076741
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: