mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 625302 - Add JS API to trigger cycle collection (without garbage collection), r=jst
This commit is contained in:
parent
002ad973d9
commit
df5a1fc0ea
@ -721,6 +721,19 @@ nsDOMWindowUtils::GarbageCollect(nsICycleCollectorListener *aListener)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::CycleCollect(nsICycleCollectorListener *aListener)
|
||||
{
|
||||
// Always permit this in debug builds.
|
||||
#ifndef DEBUG
|
||||
if (!IsUniversalXPConnectCapable()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsJSContext::CycleCollectNow(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::ProcessUpdates()
|
||||
|
@ -66,7 +66,7 @@ interface nsITransferable;
|
||||
interface nsIQueryContentEventResult;
|
||||
interface nsIDOMWindow;
|
||||
|
||||
[scriptable, uuid(b46050ea-6f18-11e0-bf00-f389b7004a12)]
|
||||
[scriptable, uuid(d95fac68-4f0d-430f-9580-6dd8041f177e)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -363,6 +363,18 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
*/
|
||||
void garbageCollect([optional] in nsICycleCollectorListener aListener);
|
||||
|
||||
/**
|
||||
* Force a cycle collection without garbage collection.
|
||||
*
|
||||
* Will throw a DOM security error if called without UniversalXPConnect
|
||||
* privileges in non-debug builds. Available to all callers in debug builds.
|
||||
*
|
||||
* @param aListener listener that receives information about the CC graph
|
||||
* (see @mozilla.org/cycle-collector-logger;1 for a logger
|
||||
* component)
|
||||
*/
|
||||
void cycleCollect([optional] in nsICycleCollectorListener aListener);
|
||||
|
||||
/**
|
||||
* Force processing of any queued paints
|
||||
*/
|
||||
|
@ -66,6 +66,7 @@ _TEST_FILES = \
|
||||
DOMWindowCreated_chrome.xul \
|
||||
DOMWindowCreated_content.html \
|
||||
test_sandbox_image.xul \
|
||||
test_cyclecollector.xul \
|
||||
test_resize_move_windows.xul \
|
||||
test_popup_blocker_chrome.xul \
|
||||
$(NULL)
|
||||
|
46
dom/tests/mochitest/chrome/test_cyclecollector.xul
Normal file
46
dom/tests/mochitest/chrome/test_cyclecollector.xul
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
-->
|
||||
<window title="Mozilla Bug "
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id="
|
||||
target="_blank">Mozilla Bug </a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug **/
|
||||
var obs = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
var didCall = false;
|
||||
var observer = {
|
||||
QueryInterface: function QueryInterface(aIID) {
|
||||
if (aIID.equals(Components.interfaces.nsIObserver) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
observe: function(subject, topic, data) {
|
||||
obs.removeObserver(observer, "cycle-collector-begin");
|
||||
observer = null;
|
||||
didCall = true;
|
||||
}
|
||||
};
|
||||
|
||||
obs.addObserver(observer, "cycle-collector-begin", false);
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils).cycleCollect();
|
||||
|
||||
ok(didCall, "Observer should have been called!");
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
Loading…
Reference in New Issue
Block a user