Closed Bug 642993 Opened 13 years ago Closed 13 years ago

Create SpecialPowers version of "Components.utils.forceGC()" and/or "nsIDOMWindowUtils::garbageCollect()"

Categories

(Core :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: dholbert, Unassigned)

Details

(Whiteboard: [MemShrink])

Attachments

(1 file)

I've written a mochitest for a security bug that requires a garbage-collection in order to trigger an object to be destructed and then a subsequent crash.

I can achieve this with:
> netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

and then either of the following:
> Components.utils.forceGC();
or
> var wu =  window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
>                  .getInterface(Components.interfaces.nsIDOMWindowUtils);
> wu.garbageCollect();

I'm trying to convert my mochitest to use SpecialPowers, per jst's m.d.platform post "No more enablePrivilege(*) in tests from now on":
http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/efb5638caac46e8c
but as soon as I stick either of the above calls behind a SpecialPowers method, they stop triggering the destructor that I'm interested in.  (though I've verified that the former call *does* still trigger a printf that I put in nsXPCComponents_Utils::ForceGC, as a sanity-check.)

Jesse suggested that this might be due to Compartments boundaries.  I'm not sure how to get this to work -- any thoughts?
Here's what I attempted to get this to work.  I've included a debugging NS_WARNING in the C++ implementations of both gc methods that I call, just to be sure that they're actually invoked.

But this doesn't work -- when I apply this patch and call
> SpecialPowers.forceGC()
in my test, then I trigger the NS_WARNINGSs (so the gc methods are invoked), but I don't trigger the destructor that I'm interested in.

On the other hand, if I replace "SpecialPowers.forceGC()" with an enablePrivilege & a direct call to either wu.garbageCollect or Components.utils.forceGC(), then I *do* trigger the destructor that I'm interested in.

So SpecialPowers isn't doing what I'd like it to, at least not right now. :-(  Am I doing something wrong, or is this a known limitation to SpecialPowers?
Bug 643803 should bring *all* the DOMWindowUtil features to SpecialPowers
Whiteboard: [MemShrink]
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: