Closed Bug 479311 Opened 15 years ago Closed 15 years ago

Modal dialogs stops execution of MozMill tests

Categories

(Testing Graveyard :: Mozmill, defect, P1)

defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: whimboo, Assigned: cmtalbert)

References

(Blocks 1 open bug)

Details

(Whiteboard: [mozmill-1.2])

Attachments

(3 files, 2 obsolete files)

Attached file MozMill test
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20090219 Shiretoko/3.1b3pre ID:20090219020454 and MozMill 1.0.2

The execution of tests in MozMill, which call a modal dialog (sheet), will stop  when the dialog is opened. That makes it impossible to run any action in those dialogs. After the dialog gets closed manually the execution continuous.

See the attached MozMill test.
Just to clarify, this is NOT an OS level modal dialog, it is drawn in XUL.

If you bring back up the mozmill window you can actually inspect the new window, so it is accessible it's just somehow blocking the execution of the code in our test.
Blocks: 479314
Spent a chunk of time on this, pretty lost as to how to debug this -- Clint could you check this out and see if you have any idea what's going on here?
What's the best way to debug the MozMill extension? Venkman? If yes, which function should be checked in detail?
Try to get this in for 1.1.  Not sure if it will make it.
Whiteboard: [mozmill-1.1]
My attempts at jumpstarting the thread have led to nothing but cursing.

I think we're gonna have to try to generalize Clint's solution instead.
Whiteboard: [mozmill-1.1] → [mozmill-1.2]
Blocks: 487380
That blocks a lot of us from creating tests. Especially the Thunderbird folks seems to be stopped here. Marking as blocker.
Severity: major → blocker
Priority: -- → P1
This is the test to enter private browsing mode which requires the user to accept a modal dialog.
Attachment #372146 - Flags: review?(hskupin)
This is the heart of the modal dialog shared resource.  It basically works like this:

1. It is instantiated by a tester and given a callback to the function that will deal with the dialog in some way.
2. Then it starts a timer
3. Once the timer fires, the observer is called, but if the dialog cannot be found, then the timer starts again
4. Once the dialog is found, the callback function is called and control is returned to the original test.
Assignee: nobody → ctalbert
Status: NEW → ASSIGNED
Attachment #372149 - Flags: review?(hskupin)
(In reply to comment #9)
> 1. It is instantiated by a tester and given a callback to the function that
> will deal with the dialog in some way.
> 2. Then it starts a timer
> 3. Once the timer fires, the observer is called, but if the dialog cannot be
> found, then the timer starts again
> 4. Once the dialog is found, the callback function is called and control is
> returned to the original test.

What I don't quite see is what prevents MozMill from assuming the tests are finished during the time we're waiting for the dialog? i.e. between steps 3 and 4.

If I've understood MozMill correctly once testModalDialog finishes, it'll go straight onto the next test* function. So how would we do something like:

testModalDialog
handleDialog (clicks cancel)
testNextStep

where testNextStep needs to happen after handleDialog is called?
(In reply to comment #10)
> What I don't quite see is what prevents MozMill from assuming the tests are
> finished during the time we're waiting for the dialog? i.e. between steps 3 and
> 4.

That's simple. Calling a modal dialog stops Mozmill from further processing a test. This can be seen right now when you open a modal dialog from within your test. So the test will be processed after the handleDialog execution has been finished.

> testModalDialog
> handleDialog (clicks cancel)
> testNextStep
> 
> where testNextStep needs to happen after handleDialog is called?

This is safe sequence. See my answer above.
Attachment #372149 - Attachment mime type: application/x-javascript → text/plain
Comment on attachment 372149 [details]
The shared resource for dealing with modal dialogs

Clint, it works perfectly! I just can say wow. I only have one concern here:

>  observe : function (subject, topic, data) {
>    var doc = this.docFinder();
>    if (doc)
>      this.handler(doc);

I'ld like to see a controller here which we pass to the handler. We are running functional tests so we also wanna test those clicks instead of calling functions like dialog.acceptDialog() directly.

I made those changes and also updated the test to demonstrate how several modal dialogs in a row can be handled. Additionally tests will wait as expected.

I'll attach the new files right now.
Attachment #372149 - Flags: review?(hskupin) → review-
Comment on attachment 372146 [details]
The Test for using a modal dialog (enters private browsing mode)

>function handleDialog(doc) {
>  var dialog = doc.getElementById("commonDialog");
>  dialog.acceptDialog();
>}

As said, using a controller to simulate real clicks should be preferred here. New test upcoming.
Attachment #372146 - Flags: review?(hskupin) → review-
Attached file modal dialog module v2
Attachment #372149 - Attachment is obsolete: true
Attached file test for modal dialogs
Attachment #372146 - Attachment is obsolete: true
Attachment #372943 - Attachment mime type: application/x-javascript → text/plain
Attachment #372943 - Flags: review?(ctalbert)
Attachment #372946 - Attachment mime type: application/x-javascript → text/plain
Attachment #372946 - Flags: review?(ctalbert)
Comment on attachment 372946 [details]
test for modal dialogs

looks great
Attachment #372946 - Flags: review?(ctalbert) → review+
Comment on attachment 372943 [details]
modal dialog module v2

Great idea Henrik.  I love this change.  I'm going to take out the modalDialog.setup() call as that is unneeded now that we are setting handleDialog callback on instantiation.
Attachment #372943 - Flags: review?(ctalbert) → review+
Pushed 9:b1154ea90d51
--> FIXED
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Works fantastic. Marking bug as verified. Thanks Clint!
Status: RESOLVED → VERIFIED
Depends on: 492136
Blocks: 486407
Blocks: 802990
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: