Bug 1161748 - Rehydrate ActivityOptions in a system scope. r=fabrice,gabor

This commit is contained in:
Bobby Holley 2015-05-20 12:18:09 -07:00
parent 53b7e8ff5d
commit 80c484de20

View File

@ -68,10 +68,18 @@ Activity::Initialize(nsPIDOMWindow* aWindow,
mProxy = do_CreateInstance("@mozilla.org/dom/activities/proxy;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
// We're about the pass the dictionary to a JS-implemented component, so
// rehydrate it in a system scode so that security wrappers don't get in the
// way. See bug 1161748 comment 16.
bool ok;
JS::Rooted<JS::Value> optionsValue(aCx);
if (!ToJSValue(aCx, aOptions, &optionsValue)) {
return NS_ERROR_FAILURE;
{
JSAutoCompartment ac(aCx, xpc::PrivilegedJunkScope());
ok = ToJSValue(aCx, aOptions, &optionsValue);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
}
ok = JS_WrapValue(aCx, &optionsValue);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
mProxy->StartActivity(static_cast<nsIDOMDOMRequest*>(this), optionsValue, aWindow);
return NS_OK;