Closed Bug 573808 Opened 14 years ago Closed 14 years ago

"domWin is null" error with new prompting backend and no active window

Categories

(Core :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b1

People

(Reporter: davemgarrett, Assigned: Dolske)

References

Details

(Keywords: regression, testcase)

Attachments

(1 file, 2 obsolete files)

The new prompting backend will throw the JavaScript error "domWin is null" (from nsPrompter.js line 391) in some instances. If the given domWin is null ModalPrompter.openPrompt resorts to Services.ww.activeWindow, which would also be null on startup and possibly also when called from other odd places. (I was also getting this when called by a pref listener)
Here's a minimal testcase for the startup prompt error. Will give a prompt on startup under Firefox 3.6 and an error console message under current Trunk.
Keywords: testcase
Looks like the only code that actually relies on a non-null domWin is dead code - fireEvent isn't called, and winUtils is unused (and removed by the WIP patch in bug 573649).
Blocks: 573369
Attached patch remove dead code (obsolete) — Splinter Review
Assignee: nobody → gavin.sharp
Status: NEW → ASSIGNED
Attachment #453543 - Flags: review?(dolske)
Attached patch Patch v.1Splinter Review
Assignee: gavin.sharp → dolske
Attachment #453160 - Attachment is obsolete: true
Attachment #453543 - Attachment is obsolete: true
Attachment #453557 - Flags: review?(gavin.sharp)
Attachment #453543 - Flags: review?(dolske)
Attachment #453557 - Attachment is patch: true
Attachment #453557 - Attachment mime type: application/octet-stream → text/plain
Bah, we were both working on this. Mine added a test, though. So neener-neener. ;-)
Comment on attachment 453557 [details] [diff] [review]
Patch v.1

>diff --git a/toolkit/components/prompts/src/nsPrompter.js b/toolkit/components/prompts/src/nsPrompter.js

>     openPrompt : function (uri, args) {

>+        // XXX domWin may still be null here if there are _no_ windows open.

Don't think this is necessary (or at least not the "XXX" marker)

>diff --git a/toolkit/components/prompts/test/test_modal_prompts.html b/toolkit/components/prompts

>+// ===== test 29  =====
>+// Alert, no window
>+testNum++;
>+startCallbackTimer();
>+prompter.alert(null, "TestTitle", "This is the alert text.");
>+ok(didDialog, "handleDialog was invoked");

This doesn't actually cover the current failure case here, does it? I would expect activeWindow to be non-null when these tests are running. Doesn't hurt to add it anyways, though.
Attachment #453557 - Flags: review?(gavin.sharp) → review+
Pushed http://hg.mozilla.org/mozilla-central/rev/e7b4fc236003
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
OS: Linux → All
Hardware: x86 → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a6
(In reply to comment #6)

> >+ok(didDialog, "handleDialog was invoked");
> 
> This doesn't actually cover the current failure case here, does it? I would
> expect activeWindow to be non-null when these tests are running. Doesn't hurt
> to add it anyways, though.

Oops, saw you comments after the push. :/

Yeah, the tests don't test this particular failure (and I'm not too sure how they could). But I did make sure they catch it if a future change removes the "if no domWin then use activeWindow" code, and it's good to have at least one case of window == null in the test.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: