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

RESOLVED WORKSFORME

Status

()

Core
General
RESOLVED WORKSFORME
7 years ago
7 years ago

People

(Reporter: dholbert, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [MemShrink])

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
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?
(Reporter)

Comment 1

7 years ago
Created attachment 520322 [details] [diff] [review]
attempted obvious patch (doesn't work)

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?

Comment 2

7 years ago
Bug 643803 should bring *all* the DOMWindowUtil features to SpecialPowers

Updated

7 years ago
Whiteboard: [MemShrink]
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.