Closed Bug 529701 Opened 15 years ago Closed 15 years ago

nsCategoryCache could add a category observer twice in some situation.

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
status1.9.2 --- beta5-fixed

People

(Reporter: mak, Assigned: Biesinger)

References

Details

Attachments

(1 file)

I'm still trying to completely understand what happens here, but this is what i can see so far.

I have a category called "history-observers".
i have a component that is registered as an "history-observers" entry through XPCOMUtils.
This component also implements nsIObserver.
History to notify changes enumerates observers through a categoryCache.

I have a test that executes some history stuff, my category observer is correctly enumerated and notified once.

then i Cc[my_component].getService(Ci.nsIObserver).notify(null, some_custom_notification, null);

at this point i see that nsCategoryCache receives an entry added notification from the category manager, the entry is then added again to the hash, History enumerates entries and notifies my component TWICE.

Doing some debugging i've seen that when nsCategoryCache starts it adds all entries that have been loaded so far (they come from compreg.dat at this point), but then when i run the above test it adds the entry again.

I'm trying to argue if i'm doing something wrong or there's a problem here.
Blocks: 520165
actually, looks like i see the double addition even without the getService thing, i just execute a method that will cause a notification to be fired, the notification instantiates the component, that is registered again.

this is my test
http://mozilla.pastebin.com/m50a35910

i call removeAllPages, that will notify onClearHistory to "history-observers", expiration components should be instantiated at this point since it's in the category cache, and it will fire "places-expiration-finished".

Running this test i see that the entry is added twice, any history change from now on is notified twice to my component.
Assignee: nobody → cbiesinger
Status: NEW → ASSIGNED
Attachment #413325 - Flags: review? → review?(benjamin)
Attachment #413325 - Flags: review?(benjamin) → review+
I'd like a test as well... I think it can be done with xpcshell
Flags: in-testsuite?
Urgh... if the category cache is exposed to xpcshell at all.
Nope, it's a C++-only API.
Comment on attachment 413325 [details] [diff] [review]
patch

a192=beltzner mostly because I <3 biesi so much.
Attachment #413325 - Flags: approval1.9.2+
marking checkin-needed in case anybody gets around to do it tonight, otherwise I'll do it tomorrow
Keywords: checkin-needed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: