Closed Bug 1081006 Opened 10 years ago Closed 10 years ago

Improve windows.waitForWindowState to also accept ID of the window to catch

Categories

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

defect

Tracking

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

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

People

(Reporter: danisielm, Assigned: danisielm)

References

Details

(Whiteboard: [sprint])

Attachments

(1 file, 4 obsolete files)

As I've seen in bug 908649, on the unknownContentType dialog, this doesn't have a specific type but an ID. There might be also other dialogs for which would be great to wait for the ID.

Let's improve the waitForWindowState to also accept catching the windows by their ID.
Attached patch fix.patch (obsolete) — Splinter Review
Here is the fix.
Attachment #8503008 - Flags: review?(andrei.eftimie)
Attachment #8503008 - Flags: review?(andreea.matei)
Attached patch fix_updated.patch (obsolete) — Splinter Review
Updated the comment a bit.
Attachment #8503008 - Attachment is obsolete: true
Attachment #8503008 - Flags: review?(andrei.eftimie)
Attachment #8503008 - Flags: review?(andreea.matei)
Attachment #8503011 - Flags: review?(andrei.eftimie)
Attachment #8503011 - Flags: review?(andreea.matei)
Attached patch fix_2.patch (obsolete) — Splinter Review
Working on this I just noticed we missed to add curly braces in that if statement when implementing the method. :D

Added it here.
Attachment #8503011 - Attachment is obsolete: true
Attachment #8503011 - Flags: review?(andrei.eftimie)
Attachment #8503011 - Flags: review?(andreea.matei)
Attachment #8503024 - Flags: review?(andrei.eftimie)
Attachment #8503024 - Flags: review?(andreea.matei)
Depends on: 1006996
No longer depends on: 1047235
Blocks: 1081047
Comment on attachment 8503024 [details] [diff] [review]
fix_2.patch

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

lgtm.

As noted below, if you can add a short test for the ID as well it would be great.
With that ask a review from Henrik please.

::: lib/windows.js
@@ +215,5 @@
>        assert.waitFor(() => {
>          return observer.getWindows().some(aWindow => {
>            var windowType = aWindow.document.documentElement.getAttribute("windowtype");
> +          var windowId = aWindow.document.documentElement.id;
> +          if (windowType === aSpec.type || windowId === aSpec.id) {

It would be great to also have a short test for ID (if it's feasible).
Attachment #8503024 - Flags: review?(andrei.eftimie)
Attachment #8503024 - Flags: review?(andreea.matei)
Attachment #8503024 - Flags: review+
Attached patch fix_v2.patch (obsolete) — Splinter Review
Thanks, updated!
Attachment #8503024 - Attachment is obsolete: true
Attachment #8504095 - Flags: review?(hskupin)
Comment on attachment 8504095 [details] [diff] [review]
fix_v2.patch

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

::: lib/windows.js
@@ +180,5 @@
>   *        Callback function that triggers the window's state changing
>   * @param {object} aSpec
>   *        Information about the window to handle
> + * @param {string} [aSpec.id]
> + *        Id of the window to wait for

remove 'to wait for'.

@@ +195,5 @@
>  
>    var aEventType = OBSERVER_WINDOW_READY;
>    if (aSpec.state === WINDOW_STATES.open) {
> +    assert.ok(aSpec.type || aSpec.id,
> +              "Type or Id of the window to open has been specified");

'ID'

@@ +215,5 @@
>        assert.waitFor(() => {
>          return observer.getWindows().some(aWindow => {
>            var windowType = aWindow.document.documentElement.getAttribute("windowtype");
> +          var windowId = aWindow.document.documentElement.id;
> +          if (windowType === aSpec.type || windowId === aSpec.id) {

What if the window doesn't have a type (undefined) set, and the call to this method also passes in undefined for aSpec.type? We would get the wrong window. Actually we even missed this with the original landing, but given that type was required for open it was not that terrible. Here we have to fix that for sure.
Attachment #8504095 - Flags: review?(hskupin) → review-
(In reply to Henrik Skupin (:whimboo) from comment #6)
> What if the window doesn't have a type (undefined) set, and the call to this
> method also passes in undefined for aSpec.type? We would get the wrong
> window. Actually we even missed this with the original landing, but given
> that type was required for open it was not that terrible. Here we have to
> fix that for sure.

Definitively worth looking into. From my (limited) testing if `windowtype` does not exist, we get `null`, not `undefined`. So this might be a non issue.

> document.documentElement.getAttribute("windowtype") // null
Indeed getAttribute returns null or "" in case the attribute doesn't exist, so the comparison will return false as expected.
https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute

Thanks Andrei and Henrik for review! Will update shortly.
Attached patch fix_v3.patchSplinter Review
Fixed those 2 nits.
Attachment #8504095 - Attachment is obsolete: true
Attachment #8504549 - Flags: review?(andrei.eftimie)
Attachment #8504549 - Flags: review?(andreea.matei)
Comment on attachment 8504549 [details] [diff] [review]
fix_v3.patch

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

Passing the r flag back to Henrik for comment 7 and comment 8 regarding undefined vs null windowtype
Attachment #8504549 - Flags: review?(hskupin)
Attachment #8504549 - Flags: review?(andrei.eftimie)
Attachment #8504549 - Flags: review?(andreea.matei)
Attachment #8504549 - Flags: review+
Whiteboard: [sprint]
Attachment #8504549 - Flags: review?(hskupin) → review+
Comment on attachment 8504549 [details] [diff] [review]
fix_v3.patch

Applies cleanly on all branches (default, aurora & beta).
Attachment #8504549 - Flags: checkin?(andrei.eftimie)
Attachment #8504549 - Flags: checkin?(andrei.eftimie) → checkin+
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: