зеркало из https://github.com/mozilla/gecko-dev.git
Back out e6761635f9cf (bug 695292) for Android mochitest bustage on a CLOSED TREE
This commit is contained in:
Родитель
4c3388ad0a
Коммит
9208a5089e
|
@ -118,7 +118,7 @@ interface ScheduledGCCallback : nsISupports
|
|||
/**
|
||||
* interface of Components.utils
|
||||
*/
|
||||
[scriptable, uuid(25442383-a1f5-440c-9e18-a2a1cdb8a638)]
|
||||
[scriptable, uuid(cc7ef3b0-339d-4317-927b-fdc8f0664927)]
|
||||
interface nsIXPCComponents_Utils : nsISupports
|
||||
{
|
||||
|
||||
|
@ -329,14 +329,6 @@ interface nsIXPCComponents_Utils : nsISupports
|
|||
[implicit_jscontext]
|
||||
void recomputeWrappers([optional] in jsval vobj);
|
||||
|
||||
/*
|
||||
* Dispatches a runnable to the current/main thread. If |scope| is passed,
|
||||
* the runnable will be dispatch in the compartment of |scope|, which
|
||||
* affects which error reporter gets called.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void dispatch(in jsval runnable, [optional] in jsval scope);
|
||||
|
||||
/*
|
||||
* To be called from JS only.
|
||||
*
|
||||
|
|
|
@ -4339,33 +4339,6 @@ nsXPCComponents_Utils::RecomputeWrappers(const jsval &vobj, JSContext *cx)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::Dispatch(const jsval &runnable_, const jsval &scope,
|
||||
JSContext *cx)
|
||||
{
|
||||
// Enter the given compartment, if any, and rewrap runnable.
|
||||
JSAutoEnterCompartment ac;
|
||||
js::Value runnable = runnable_;
|
||||
if (scope.isObject()) {
|
||||
JSObject *scopeObj = js::UnwrapObject(&scope.toObject());
|
||||
if (!scopeObj || !ac.enter(cx, scopeObj) || !JS_WrapValue(cx, &runnable))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get an XPCWrappedJS for |runnable|.
|
||||
if (!runnable.isObject())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
nsCOMPtr<nsIRunnable> run;
|
||||
nsresult rv = nsXPConnect::GetXPConnect()->WrapJS(cx, &runnable.toObject(),
|
||||
NS_GET_IID(nsIRunnable),
|
||||
getter_AddRefs(run));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
MOZ_ASSERT(run);
|
||||
|
||||
// Dispatch.
|
||||
return NS_DispatchToMainThread(run);
|
||||
}
|
||||
|
||||
/* string canCreateWrapper (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::CanCreateWrapper(const nsIID * iid, char **_retval)
|
||||
|
|
|
@ -652,8 +652,25 @@ SimpleTest.waitForClipboard = function(aExpectedStringOrValidatorFn, aSetupFn,
|
|||
* working (or finish).
|
||||
*/
|
||||
SimpleTest.executeSoon = function(aFunc) {
|
||||
if ("SpecialPowers" in window) {
|
||||
return SpecialPowers.executeSoon(aFunc, window);
|
||||
// Once SpecialPowers is available in chrome mochitests, we can replace the
|
||||
// body of this function with a call to SpecialPowers.executeSoon().
|
||||
if ("Components" in window && "classes" in window.Components) {
|
||||
try {
|
||||
netscape.security.PrivilegeManager
|
||||
.enablePrivilege("UniversalXPConnect");
|
||||
var tm = Components.classes["@mozilla.org/thread-manager;1"]
|
||||
.getService(Components.interfaces.nsIThreadManager);
|
||||
|
||||
tm.mainThread.dispatch({
|
||||
run: function() {
|
||||
aFunc();
|
||||
}
|
||||
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
|
||||
return;
|
||||
} catch (ex) {
|
||||
// If the above fails (most likely because of enablePrivilege
|
||||
// failing), fall through to the setTimeout path.
|
||||
}
|
||||
}
|
||||
setTimeout(aFunc, 0);
|
||||
}
|
||||
|
|
|
@ -882,16 +882,13 @@ SpecialPowersAPI.prototype = {
|
|||
return this._xpcomabi;
|
||||
},
|
||||
|
||||
// The optional aWin parameter allows the caller to specify a given window in
|
||||
// whose scope the runnable should be dispatched. If aFun throws, the
|
||||
// exception will be reported to aWin.
|
||||
executeSoon: function(aFun, aWin) {
|
||||
// Create the runnable in the scope of aWin to avoid running into COWs.
|
||||
var runnable = {};
|
||||
if (aWin)
|
||||
runnable = Cu.createObjectIn(aWin);
|
||||
runnable.run = aFun;
|
||||
Cu.dispatch(runnable, aWin);
|
||||
executeSoon: function(aFunc) {
|
||||
var tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
|
||||
tm.mainThread.dispatch({
|
||||
run: function() {
|
||||
aFunc();
|
||||
}
|
||||
}, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
},
|
||||
|
||||
_os: null,
|
||||
|
|
Загрузка…
Ссылка в новой задаче