Closed Bug 309232 Opened 20 years ago Closed 19 years ago

[FIX]nsWebBrowser::AddWebBrowserListener always returns NS_ERROR_INVALID_ARG if called before window is created

Categories

(Core Graveyard :: Embedding: APIs, defect, P3)

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: gschmidt, Assigned: bzbarsky)

Details

(Keywords: fixed1.8.1)

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 Build Identifier: GRE release 1.7.8 (unchanged in CVS) In nsWebBrowser::AddWebBrowserListener in nswebbrowser.cpp, rv is initialized to NS_ERROR_INVALID_ARG. Then there are two branches of control, after which rv is returned to the caller. One branch handles the case where the window has already been created; it sets rv to the return value of BindListener. The other branch handles the case where the window hasn't been created. It queues the listener object until window creation. However, it does not set rv, so even if everything goes fine NS_ERROR_INVALID_ARG is returned. If this is the correct behavior (it is supposed to be an error to add a listener before calling InitWindow) this should be documented. Reproducible: Always Steps to Reproduce: 1. Instantiate NS_WEBBROWSER_CONTRACTID; get the nsIWebBrowser interface. 2. Call AddWebBrowserListener on it, passing NS_GET_IID(nsIWebProgressListener) and a weak reference to an object that implements nsIWebProgressListener. Actual Results: AddWebBrowserListener returns NS_ERROR_INVALID_ARG. Haven't checked to see if notifications are delivered anyway. Expected Results: Expected return value is NS_OK.
Attached patch This should fix it (obsolete) — Splinter Review
Assignee: adamlock → bzbarsky
Status: UNCONFIRMED → ASSIGNED
Attachment #207796 - Flags: superreview?(darin)
Attachment #207796 - Flags: review?(darin)
OS: Windows XP → All
Priority: -- → P3
Hardware: PC → All
Summary: nsWebBrowser::AddWebBrowserListener always returns NS_ERROR_INVALID_ARG if called before window is created → [FIX]nsWebBrowser::AddWebBrowserListener always returns NS_ERROR_INVALID_ARG if called before window is created
Target Milestone: --- → mozilla1.8.1
Comment on attachment 207796 [details] [diff] [review] This should fix it Perhaps it would be better to use nsAutoPtr<nsWebBrowserListenerState> to avoid having to insert all of those NS_DELETEXPCOM(state) calls. You could just do a .forget() if AppendElement succeeds.
Attachment #207796 - Flags: superreview?(darin)
Attachment #207796 - Flags: superreview+
Attachment #207796 - Flags: review?(darin)
Attachment #207796 - Flags: review+
Attachment #207796 - Attachment is obsolete: true
Fixed on trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment on attachment 208019 [details] [diff] [review] Updated to review comments I think it's worth taking this on the 1.8 branch. This just makes us not throw in a non-error case in our embedding API...
Attachment #208019 - Flags: approval1.8.1?
Attachment #208019 - Flags: approval1.8.1? → branch-1.8.1+
Fixed on branch.
Keywords: fixed1.8.1
Target Milestone: mozilla1.8.1 → mozilla1.9alpha
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: