Bug 1490632 - Always use braces for if/for/while statements in js/ipc. r=evilpie
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 12 Sep 2018 20:04:14 +0000
changeset 436132 3aa7f81bfcb559a6f060283e5884177764129151
parent 436131 70c9cb74c8446bd1ce67040a003a901ffd878fda
child 436133 4d081dbefe2f1ac8ef8ffcb97b85a6dd6f88b588
push id34630
push usernerli@mozilla.com
push dateThu, 13 Sep 2018 21:58:06 +0000
treeherdermozilla-central@71736f1f0f3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1490632
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1490632 - Always use braces for if/for/while statements in js/ipc. r=evilpie Differential Revision: https://phabricator.services.mozilla.com/D5661
js/ipc/CPOWTimer.cpp
js/ipc/JavaScriptLogging.h
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
js/ipc/WrapperAnswer.cpp
js/ipc/WrapperOwner.cpp
--- a/js/ipc/CPOWTimer.cpp
+++ b/js/ipc/CPOWTimer.cpp
@@ -11,18 +11,19 @@
 
 #include "jsapi.h"
 
 CPOWTimer::CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
     : cx_(nullptr)
     , startInterval_(0)
 {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    if (!js::GetStopwatchIsMonitoringCPOW(cx))
+    if (!js::GetStopwatchIsMonitoringCPOW(cx)) {
         return;
+    }
     cx_ = cx;
     startInterval_ = JS_Now();
 }
 CPOWTimer::~CPOWTimer()
 {
     if (!cx_) {
         // Monitoring was off when we started the timer.
         return;
--- a/js/ipc/JavaScriptLogging.h
+++ b/js/ipc/JavaScriptLogging.h
@@ -123,18 +123,19 @@ class Logging
     void format(const ReceiverObj& obj, nsCString& out) {
         formatObject(true, true, obj.id, out);
     }
 
     void format(const nsTArray<JSParam>& values, nsCString& out) {
         nsAutoCString tmp;
         out.Truncate();
         for (size_t i = 0; i < values.Length(); i++) {
-            if (i)
+            if (i) {
                 out.AppendLiteral(", ");
+            }
             if (values[i].type() == JSParam::Tvoid_t) {
                 out.AppendLiteral("<void>");
             } else {
                 format(InVariant(values[i].get_JSVariant()), tmp);
                 out += tmp;
             }
         }
     }
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -70,18 +70,19 @@ JavaScriptParent::allowMessage(JSContext
     if (!xpc::IsInAutomation()) {
         JS_ReportErrorASCII(cx, "CPOW usage forbidden");
         return false;
     }
 
     MessageChannel* channel = GetIPCChannel();
     bool isSafe = channel->IsInTransaction();
 
-    if (isSafe)
+    if (isSafe) {
         return true;
+    }
 
     nsIGlobalObject* global = dom::GetIncumbentGlobal();
     JS::Rooted<JSObject*> jsGlobal(cx, global ? global->GetGlobalJSObject() : nullptr);
     if (jsGlobal) {
         JSAutoRealm ar(cx, jsGlobal);
 
         if (!xpc::CompartmentPrivate::Get(jsGlobal)->allowCPOWs &&
             ForbidUnsafeBrowserCPOWs())
@@ -129,24 +130,26 @@ JavaScriptParent::scopeForTargetObjects(
     // practice, this means that a child process can only (a) hold parent
     // objects alive and (b) invoke them if they are callable.
     return xpc::UnprivilegedJunkScope();
 }
 
 void
 JavaScriptParent::afterProcessTask()
 {
-    if (savedNextCPOWNumber_ == nextCPOWNumber_)
+    if (savedNextCPOWNumber_ == nextCPOWNumber_) {
         return;
+    }
 
     savedNextCPOWNumber_ = nextCPOWNumber_;
 
     MOZ_ASSERT(nextCPOWNumber_ > 0);
-    if (active())
+    if (active()) {
         Unused << SendDropTemporaryStrongReferences(nextCPOWNumber_ - 1);
+    }
 }
 
 PJavaScriptParent*
 mozilla::jsipc::NewJavaScriptParent()
 {
     return new JavaScriptParent();
 }
 
@@ -155,12 +158,13 @@ mozilla::jsipc::ReleaseJavaScriptParent(
 {
     static_cast<JavaScriptParent*>(parent)->decref();
 }
 
 void
 mozilla::jsipc::AfterProcessTask()
 {
     for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
-        if (PJavaScriptParent* p = LoneManagedOrNullAsserts(cp->ManagedPJavaScriptParent()))
+        if (PJavaScriptParent* p = LoneManagedOrNullAsserts(cp->ManagedPJavaScriptParent())) {
             static_cast<JavaScriptParent*>(p)->afterProcessTask();
+        }
     }
 }
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -23,47 +23,51 @@ IdToObjectMap::IdToObjectMap()
   : table_(SystemAllocPolicy(), 32)
 {
 }
 
 void
 IdToObjectMap::trace(JSTracer* trc, uint64_t minimumId)
 {
     for (Table::Range r(table_.all()); !r.empty(); r.popFront()) {
-        if (r.front().key().serialNumber() >= minimumId)
+        if (r.front().key().serialNumber() >= minimumId) {
             JS::TraceEdge(trc, &r.front().value(), "ipc-object");
+        }
     }
 }
 
 void
 IdToObjectMap::sweep()
 {
     for (Table::Enum e(table_); !e.empty(); e.popFront()) {
         JS::Heap<JSObject*>* objp = &e.front().value();
         JS_UpdateWeakPointerAfterGC(objp);
-        if (!*objp)
+        if (!*objp) {
             e.removeFront();
+        }
     }
 }
 
 JSObject*
 IdToObjectMap::find(ObjectId id)
 {
     Table::Ptr p = table_.lookup(id);
-    if (!p)
+    if (!p) {
         return nullptr;
+    }
     return p->value();
 }
 
 JSObject*
 IdToObjectMap::findPreserveColor(ObjectId id)
 {
     Table::Ptr p = table_.lookup(id);
-    if (!p)
+    if (!p) {
         return nullptr;
+    }
     return p->value().unbarrieredGet();
 }
 
 bool
 IdToObjectMap::add(ObjectId id, JSObject* obj)
 {
     return table_.put(id, obj);
 }
@@ -86,18 +90,19 @@ IdToObjectMap::empty() const
     return table_.empty();
 }
 
 #ifdef DEBUG
 bool
 IdToObjectMap::has(const ObjectId& id, const JSObject* obj) const
 {
     auto p = table_.lookup(id);
-    if (!p)
+    if (!p) {
         return false;
+    }
     return p->value() == obj;
 }
 #endif
 
 ObjectToIdMap::ObjectToIdMap()
   : table_(SystemAllocPolicy(), 32)
 {
 }
@@ -113,18 +118,19 @@ ObjectToIdMap::sweep()
 {
     table_.sweep();
 }
 
 ObjectId
 ObjectToIdMap::find(JSObject* obj)
 {
     Table::Ptr p = table_.lookup(obj);
-    if (!p)
+    if (!p) {
         return ObjectId::nullId();
+    }
     return p->value();
 }
 
 bool
 ObjectToIdMap::add(JSContext* cx, JSObject* obj, ObjectId id)
 {
     return table_.put(obj, id);
 }
@@ -169,46 +175,50 @@ JavaScriptShared::~JavaScriptShared()
 {
     MOZ_RELEASE_ASSERT(cpows_.empty());
 }
 
 void
 JavaScriptShared::decref()
 {
     refcount_--;
-    if (!refcount_)
+    if (!refcount_) {
         delete this;
+    }
 }
 
 void
 JavaScriptShared::incref()
 {
     refcount_++;
 }
 
 bool
 JavaScriptShared::convertIdToGeckoString(JSContext* cx, JS::HandleId id, nsString* to)
 {
     RootedValue idval(cx);
-    if (!JS_IdToValue(cx, id, &idval))
+    if (!JS_IdToValue(cx, id, &idval)) {
         return false;
+    }
 
     RootedString str(cx, ToString(cx, idval));
-    if (!str)
+    if (!str) {
         return false;
+    }
 
     return AssignJSString(cx, *to, str);
 }
 
 bool
 JavaScriptShared::convertGeckoStringToId(JSContext* cx, const nsString& from, JS::MutableHandleId to)
 {
     RootedString str(cx, JS_NewUCStringCopyN(cx, from.BeginReading(), from.Length()));
-    if (!str)
+    if (!str) {
         return false;
+    }
 
     return JS_StringToId(cx, str, to);
 }
 
 bool
 JavaScriptShared::toVariant(JSContext* cx, JS::HandleValue from, JSVariant* to)
 {
     switch (JS_TypeOfValue(cx, from)) {
@@ -230,47 +240,51 @@ JavaScriptShared::toVariant(JSContext* c
             JSIID iid;
             const nsID* id = xpc_JSObjectToID(cx, obj);
             ConvertID(*id, &iid);
             *to = iid;
             return true;
         }
 
         ObjectVariant objVar;
-        if (!toObjectVariant(cx, obj, &objVar))
+        if (!toObjectVariant(cx, obj, &objVar)) {
             return false;
+        }
         *to = objVar;
         return true;
       }
 
       case JSTYPE_SYMBOL:
       {
         RootedSymbol sym(cx, from.toSymbol());
 
         SymbolVariant symVar;
-        if (!toSymbolVariant(cx, sym, &symVar))
+        if (!toSymbolVariant(cx, sym, &symVar)) {
             return false;
+        }
         *to = symVar;
         return true;
       }
 
       case JSTYPE_STRING:
       {
         nsAutoJSString autoStr;
-        if (!autoStr.init(cx, from))
+        if (!autoStr.init(cx, from)) {
             return false;
+        }
         *to = autoStr;
         return true;
       }
 
       case JSTYPE_NUMBER:
-        if (from.isInt32())
+        if (from.isInt32()) {
             *to = double(from.toInt32());
-        else
+        } else {
             *to = from.toDouble();
+        }
         return true;
 
       case JSTYPE_BOOLEAN:
         *to = from.toBoolean();
         return true;
 
       default:
         MOZ_ASSERT(false);
@@ -288,102 +302,109 @@ JavaScriptShared::fromVariant(JSContext*
 
         case JSVariant::TNullVariant:
           to.set(NullValue());
           return true;
 
         case JSVariant::TObjectVariant:
         {
           JSObject* obj = fromObjectVariant(cx, from.get_ObjectVariant());
-          if (!obj)
+          if (!obj) {
               return false;
+          }
           to.set(ObjectValue(*obj));
           return true;
         }
 
         case JSVariant::TSymbolVariant:
         {
           Symbol* sym = fromSymbolVariant(cx, from.get_SymbolVariant());
-          if (!sym)
+          if (!sym) {
               return false;
+          }
           to.setSymbol(sym);
           return true;
         }
 
         case JSVariant::Tdouble:
           to.set(JS_NumberValue(from.get_double()));
           return true;
 
         case JSVariant::Tbool:
           to.setBoolean(from.get_bool());
           return true;
 
         case JSVariant::TnsString:
         {
           const nsString& old = from.get_nsString();
           JSString* str = JS_NewUCStringCopyN(cx, old.BeginReading(), old.Length());
-          if (!str)
+          if (!str) {
               return false;
+          }
           to.set(StringValue(str));
           return true;
         }
 
         case JSVariant::TJSIID:
         {
           nsID iid;
           const JSIID& id = from.get_JSIID();
           ConvertID(id, &iid);
 
           RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
           JSObject* obj = xpc_NewIDObject(cx, global, iid);
-          if (!obj)
+          if (!obj) {
               return false;
+          }
           to.set(ObjectValue(*obj));
           return true;
         }
 
         default:
           MOZ_CRASH("NYI");
           return false;
     }
 }
 
 bool
 JavaScriptShared::toJSIDVariant(JSContext* cx, HandleId from, JSIDVariant* to)
 {
     if (JSID_IS_STRING(from)) {
         nsAutoJSString autoStr;
-        if (!autoStr.init(cx, JSID_TO_STRING(from)))
+        if (!autoStr.init(cx, JSID_TO_STRING(from))) {
             return false;
+        }
         *to = autoStr;
         return true;
     }
     if (JSID_IS_INT(from)) {
         *to = JSID_TO_INT(from);
         return true;
     }
     if (JSID_IS_SYMBOL(from)) {
         SymbolVariant symVar;
-        if (!toSymbolVariant(cx, JSID_TO_SYMBOL(from), &symVar))
+        if (!toSymbolVariant(cx, JSID_TO_SYMBOL(from), &symVar)) {
             return false;
+        }
         *to = symVar;
         return true;
     }
     MOZ_ASSERT(false);
     return false;
 }
 
 bool
 JavaScriptShared::fromJSIDVariant(JSContext* cx, const JSIDVariant& from, MutableHandleId to)
 {
     switch (from.type()) {
       case JSIDVariant::TSymbolVariant: {
         Symbol* sym = fromSymbolVariant(cx, from.get_SymbolVariant());
-        if (!sym)
+        if (!sym) {
             return false;
+        }
         to.set(SYMBOL_TO_JSID(sym));
         return true;
       }
 
       case JSIDVariant::TnsString:
         return convertGeckoStringToId(cx, from.get_nsString(), to);
 
       case JSIDVariant::Tint32_t:
@@ -403,43 +424,46 @@ JavaScriptShared::toSymbolVariant(JSCont
 
     SymbolCode code = GetSymbolCode(sym);
     if (static_cast<uint32_t>(code) < WellKnownSymbolLimit) {
         *symVarp = WellKnownSymbol(static_cast<uint32_t>(code));
         return true;
     }
     if (code == SymbolCode::InSymbolRegistry) {
         nsAutoJSString autoStr;
-        if (!autoStr.init(cx, GetSymbolDescription(sym)))
+        if (!autoStr.init(cx, GetSymbolDescription(sym))) {
             return false;
+        }
         *symVarp = RegisteredSymbol(autoStr);
         return true;
     }
 
     JS_ReportErrorASCII(cx, "unique symbol can't be used with CPOW");
     return false;
 }
 
 JS::Symbol*
 JavaScriptShared::fromSymbolVariant(JSContext* cx, const SymbolVariant& symVar)
 {
     switch (symVar.type()) {
       case SymbolVariant::TWellKnownSymbol: {
         uint32_t which = symVar.get_WellKnownSymbol().which();
-        if (which < WellKnownSymbolLimit)
+        if (which < WellKnownSymbolLimit) {
             return GetWellKnownSymbol(cx, static_cast<SymbolCode>(which));
+        }
         MOZ_ASSERT(false, "bad child data");
         return nullptr;
       }
 
       case SymbolVariant::TRegisteredSymbol: {
         nsString key = symVar.get_RegisteredSymbol().key();
         RootedString str(cx, JS_NewUCStringCopyN(cx, key.get(), key.Length()));
-        if (!str)
+        if (!str) {
             return nullptr;
+        }
         return GetSymbolFor(cx, str);
       }
 
       default:
         return nullptr;
     }
 }
 
@@ -474,27 +498,29 @@ JavaScriptShared::ConvertID(const JSIID&
     to->m3[6] = from.m3_6();
     to->m3[7] = from.m3_7();
 }
 
 JSObject*
 JavaScriptShared::findCPOWById(const ObjectId& objId)
 {
     JSObject* obj = findCPOWByIdPreserveColor(objId);
-    if (obj)
+    if (obj) {
         JS::ExposeObjectToActiveJS(obj);
+    }
     return obj;
 }
 
 JSObject*
 JavaScriptShared::findCPOWByIdPreserveColor(const ObjectId& objId)
 {
     JSObject* obj = cpows_.findPreserveColor(objId);
-    if (!obj)
+    if (!obj) {
         return nullptr;
+    }
 
     if (js::gc::EdgeNeedsSweepUnbarriered(&obj)) {
         cpows_.remove(objId);
         return nullptr;
     }
 
     return obj;
 }
@@ -511,57 +537,63 @@ JavaScriptShared::findObjectById(JSConte
     // Each process has a dedicated compartment for CPOW targets. All CPOWs
     // from the other process point to objects in this scope. From there, they
     // can access objects in other compartments using cross-compartment
     // wrappers.
     JSAutoRealm ar(cx, scopeForTargetObjects());
     if (objId.hasXrayWaiver()) {
         obj = js::ToWindowProxyIfWindow(obj);
         MOZ_ASSERT(obj);
-        if (!xpc::WrapperFactory::WaiveXrayAndWrap(cx, &obj))
+        if (!xpc::WrapperFactory::WaiveXrayAndWrap(cx, &obj)) {
             return nullptr;
+        }
     } else {
-        if (!JS_WrapObject(cx, &obj))
+        if (!JS_WrapObject(cx, &obj)) {
             return nullptr;
+        }
     }
     return obj;
 }
 
 static const uint64_t UnknownPropertyOp = 1;
 
 bool
 JavaScriptShared::fromDescriptor(JSContext* cx, Handle<PropertyDescriptor> desc,
                                  PPropertyDescriptor* out)
 {
     out->attrs() = desc.attributes();
-    if (!toVariant(cx, desc.value(), &out->value()))
+    if (!toVariant(cx, desc.value(), &out->value())) {
         return false;
+    }
 
-    if (!toObjectOrNullVariant(cx, desc.object(), &out->obj()))
+    if (!toObjectOrNullVariant(cx, desc.object(), &out->obj())) {
         return false;
+    }
 
     if (!desc.getter()) {
         out->getter() = 0;
     } else if (desc.hasGetterObject()) {
         JSObject* getter = desc.getterObject();
         ObjectVariant objVar;
-        if (!toObjectVariant(cx, getter, &objVar))
+        if (!toObjectVariant(cx, getter, &objVar)) {
             return false;
+        }
         out->getter() = objVar;
     } else {
         out->getter() = UnknownPropertyOp;
     }
 
     if (!desc.setter()) {
         out->setter() = 0;
     } else if (desc.hasSetterObject()) {
         JSObject* setter = desc.setterObject();
         ObjectVariant objVar;
-        if (!toObjectVariant(cx, setter, &objVar))
+        if (!toObjectVariant(cx, setter, &objVar)) {
             return false;
+        }
         out->setter() = objVar;
     } else {
         out->setter() = UnknownPropertyOp;
     }
 
     return true;
 }
 
@@ -580,39 +612,42 @@ UnknownStrictPropertyStub(JSContext* cx,
     return false;
 }
 
 bool
 JavaScriptShared::toDescriptor(JSContext* cx, const PPropertyDescriptor& in,
                                MutableHandle<PropertyDescriptor> out)
 {
     out.setAttributes(in.attrs());
-    if (!fromVariant(cx, in.value(), out.value()))
+    if (!fromVariant(cx, in.value(), out.value())) {
         return false;
+    }
     out.object().set(fromObjectOrNullVariant(cx, in.obj()));
 
     if (in.getter().type() == GetterSetter::Tuint64_t && !in.getter().get_uint64_t()) {
         out.setGetter(nullptr);
     } else if (in.attrs() & JSPROP_GETTER) {
         Rooted<JSObject*> getter(cx);
         getter = fromObjectVariant(cx, in.getter().get_ObjectVariant());
-        if (!getter)
+        if (!getter) {
             return false;
+        }
         out.setGetter(JS_DATA_TO_FUNC_PTR(JSGetterOp, getter.get()));
     } else {
         out.setGetter(UnknownPropertyStub);
     }
 
     if (in.setter().type() == GetterSetter::Tuint64_t && !in.setter().get_uint64_t()) {
         out.setSetter(nullptr);
     } else if (in.attrs() & JSPROP_SETTER) {
         Rooted<JSObject*> setter(cx);
         setter = fromObjectVariant(cx, in.setter().get_ObjectVariant());
-        if (!setter)
+        if (!setter) {
             return false;
+        }
         out.setSetter(JS_DATA_TO_FUNC_PTR(JSSetterOp, setter.get()));
     } else {
         out.setSetter(UnknownStrictPropertyStub);
     }
 
     return true;
 }
 
@@ -620,101 +655,110 @@ bool
 JavaScriptShared::toObjectOrNullVariant(JSContext* cx, JSObject* obj, ObjectOrNullVariant* objVarp)
 {
     if (!obj) {
         *objVarp = NullVariant();
         return true;
     }
 
     ObjectVariant objVar;
-    if (!toObjectVariant(cx, obj, &objVar))
+    if (!toObjectVariant(cx, obj, &objVar)) {
         return false;
+    }
 
     *objVarp = objVar;
     return true;
 }
 
 JSObject*
 JavaScriptShared::fromObjectOrNullVariant(JSContext* cx, const ObjectOrNullVariant& objVar)
 {
-    if (objVar.type() == ObjectOrNullVariant::TNullVariant)
+    if (objVar.type() == ObjectOrNullVariant::TNullVariant) {
         return nullptr;
+    }
 
     return fromObjectVariant(cx, objVar.get_ObjectVariant());
 }
 
 CrossProcessCpowHolder::CrossProcessCpowHolder(dom::CPOWManagerGetter* managerGetter,
                                                const InfallibleTArray<CpowEntry>& cpows)
   : js_(nullptr),
     cpows_(cpows),
     unwrapped_(false)
 {
     // Only instantiate the CPOW manager if we might need it later.
-    if (cpows.Length())
+    if (cpows.Length()) {
         js_ = managerGetter->GetCPOWManager();
+    }
 }
 
 CrossProcessCpowHolder::~CrossProcessCpowHolder()
 {
     if (cpows_.Length() && !unwrapped_) {
         // This should only happen if a message manager message
         // containing CPOWs gets ignored for some reason. We need to
         // unwrap every incoming CPOW in this process to ensure that
         // the corresponding part of the CPOW in the other process
         // will eventually be collected. The scope for this object
         // doesn't really matter, because it immediately becomes
         // garbage. Ignore this for middleman processes used when
         // recording or replaying, as they do not have a CPOW manager
         // and the message will also be received in the recording
         // process.
-        if (recordreplay::IsMiddleman())
+        if (recordreplay::IsMiddleman()) {
             return;
+        }
         AutoJSAPI jsapi;
-        if (!jsapi.Init(xpc::PrivilegedJunkScope()))
+        if (!jsapi.Init(xpc::PrivilegedJunkScope())) {
             return;
+        }
         JSContext* cx = jsapi.cx();
         JS::Rooted<JSObject*> cpows(cx);
         js_->Unwrap(cx, cpows_, &cpows);
     }
 }
 
 bool
 CrossProcessCpowHolder::ToObject(JSContext* cx, JS::MutableHandleObject objp)
 {
     unwrapped_ = true;
 
-    if (!cpows_.Length())
+    if (!cpows_.Length()) {
         return true;
+    }
 
     return js_->Unwrap(cx, cpows_, objp);
 }
 
 bool
 JavaScriptShared::Unwrap(JSContext* cx, const InfallibleTArray<CpowEntry>& aCpows,
                          JS::MutableHandleObject objp)
 {
     // Middleman processes never operate on CPOWs.
     MOZ_ASSERT(!recordreplay::IsMiddleman());
 
     objp.set(nullptr);
 
-    if (!aCpows.Length())
+    if (!aCpows.Length()) {
         return true;
+    }
 
     RootedObject obj(cx, JS_NewPlainObject(cx));
-    if (!obj)
+    if (!obj) {
         return false;
+    }
 
     RootedValue v(cx);
     RootedString str(cx);
     for (size_t i = 0; i < aCpows.Length(); i++) {
         const nsString& name = aCpows[i].name();
 
-        if (!fromVariant(cx, aCpows[i].value(), &v))
+        if (!fromVariant(cx, aCpows[i].value(), &v)) {
             return false;
+        }
 
         if (!JS_DefineUCProperty(cx,
                                  obj,
                                  name.BeginReading(),
                                  name.Length(),
                                  v,
                                  JSPROP_ENUMERATE))
         {
@@ -724,38 +768,43 @@ JavaScriptShared::Unwrap(JSContext* cx, 
 
     objp.set(obj);
     return true;
 }
 
 bool
 JavaScriptShared::Wrap(JSContext* cx, HandleObject aObj, InfallibleTArray<CpowEntry>* outCpows)
 {
-    if (!aObj)
+    if (!aObj) {
         return true;
+    }
 
     Rooted<IdVector> ids(cx, IdVector(cx));
-    if (!JS_Enumerate(cx, aObj, &ids))
+    if (!JS_Enumerate(cx, aObj, &ids)) {
         return false;
+    }
 
     RootedId id(cx);
     RootedValue v(cx);
     for (size_t i = 0; i < ids.length(); i++) {
         id = ids[i];
 
         nsString str;
-        if (!convertIdToGeckoString(cx, id, &str))
+        if (!convertIdToGeckoString(cx, id, &str)) {
             return false;
+        }
 
-        if (!JS_GetPropertyById(cx, aObj, id, &v))
+        if (!JS_GetPropertyById(cx, aObj, id, &v)) {
             return false;
+        }
 
         JSVariant var;
-        if (!toVariant(cx, v, &var))
+        if (!toVariant(cx, v, &var)) {
             return false;
+        }
 
         outCpows->AppendElement(CpowEntry(str, var));
     }
 
     return true;
 }
 
 CPOWManager*
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -24,18 +24,19 @@ class ObjectId {
     // doubles. See bug 1065811 comment 12 for an explanation.
     static const size_t SERIAL_NUMBER_BITS = 47;
     static const size_t FLAG_BITS = 1;
     static const uint64_t SERIAL_NUMBER_MAX = (uint64_t(1) << SERIAL_NUMBER_BITS) - 1;
 
     explicit ObjectId(uint64_t serialNumber, bool hasXrayWaiver)
       : serialNumber_(serialNumber), hasXrayWaiver_(hasXrayWaiver)
     {
-        if (isInvalidSerialNumber(serialNumber))
+        if (isInvalidSerialNumber(serialNumber)) {
             MOZ_CRASH("Bad CPOW Id");
+        }
     }
 
     bool operator==(const ObjectId& other) const {
         bool equal = serialNumber() == other.serialNumber();
         MOZ_ASSERT_IF(equal, hasXrayWaiver() == other.hasXrayWaiver());
         return equal;
     }
 
--- a/js/ipc/WrapperAnswer.cpp
+++ b/js/ipc/WrapperAnswer.cpp
@@ -30,18 +30,19 @@ using mozilla::dom::AutoEntryScript;
 using xpc::IsInAutomation;
 
 static void
 MaybeForceDebugGC()
 {
     static bool sEnvVarInitialized = false;
     static bool sDebugGCs = false;
 
-    if (!sEnvVarInitialized)
+    if (!sEnvVarInitialized) {
         sDebugGCs = !!PR_GetEnv("MOZ_DEBUG_DEAD_CPOWS");
+    }
 
     if (sDebugGCs) {
         JSContext* cx = XPCJSContext::Get()->Context();
         PrepareForFullGC(cx);
         NonIncrementalGC(cx, GC_NORMAL, gcreason::COMPONENT_UTILS);
     }
 }
 
@@ -53,21 +54,23 @@ WrapperAnswer::fail(AutoJSAPI& jsapi, Re
     *rs = ReturnStatus(ReturnException(JSVariant(UndefinedVariant())));
 
     // Note we always return true from this function, since this propagates
     // to the IPC code, and we don't want a JS failure to cause the death
     // of the child process.
 
     JSContext* cx = jsapi.cx();
     RootedValue exn(cx);
-    if (!jsapi.HasException())
+    if (!jsapi.HasException()) {
         return true;
+    }
 
-    if (!jsapi.StealException(&exn))
+    if (!jsapi.StealException(&exn)) {
         return true;
+    }
 
     // If this fails, we still don't want to exit. Just return an invalid
     // exception.
     (void) toVariant(cx, exn, &rs->get_ReturnException().exn());
     return true;
 }
 
 bool
@@ -93,33 +96,37 @@ WrapperAnswer::deadCPOW(AutoJSAPI& jsapi
     JS_ClearPendingException(cx);
     *rs = ReturnStatus(ReturnDeadCPOW());
     return true;
 }
 
 bool
 WrapperAnswer::RecvPreventExtensions(const ObjectId& objId, ReturnStatus* rs)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     ObjectOpResult success;
-    if (!JS_PreventExtensions(cx, obj, success))
+    if (!JS_PreventExtensions(cx, obj, success)) {
         return fail(jsapi, rs);
+    }
 
     LOG("%s.preventExtensions()", ReceiverObj(objId));
     return ok(rs, success);
 }
 
 static void
 EmptyDesc(PPropertyDescriptor* desc)
 {
@@ -129,487 +136,559 @@ EmptyDesc(PPropertyDescriptor* desc)
     desc->getter() = 0;
     desc->setter() = 0;
 }
 
 bool
 WrapperAnswer::RecvGetOwnPropertyDescriptor(const ObjectId& objId, const JSIDVariant& idVar,
                                             ReturnStatus* rs, PPropertyDescriptor* out)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
     EmptyDesc(out);
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.getOwnPropertyDescriptor(%s)", ReceiverObj(objId), Identifier(idVar));
 
     RootedId id(cx);
-    if (!fromJSIDVariant(cx, idVar, &id))
+    if (!fromJSIDVariant(cx, idVar, &id)) {
         return fail(jsapi, rs);
+    }
 
     Rooted<PropertyDescriptor> desc(cx);
-    if (!JS_GetOwnPropertyDescriptorById(cx, obj, id, &desc))
+    if (!JS_GetOwnPropertyDescriptorById(cx, obj, id, &desc)) {
         return fail(jsapi, rs);
+    }
 
-    if (!fromDescriptor(cx, desc, out))
+    if (!fromDescriptor(cx, desc, out)) {
         return fail(jsapi, rs);
+    }
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvDefineProperty(const ObjectId& objId, const JSIDVariant& idVar,
                                   const PPropertyDescriptor& descriptor, ReturnStatus* rs)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("define %s[%s]", ReceiverObj(objId), Identifier(idVar));
 
     RootedId id(cx);
-    if (!fromJSIDVariant(cx, idVar, &id))
+    if (!fromJSIDVariant(cx, idVar, &id)) {
         return fail(jsapi, rs);
+    }
 
     Rooted<PropertyDescriptor> desc(cx);
-    if (!toDescriptor(cx, descriptor, &desc))
+    if (!toDescriptor(cx, descriptor, &desc)) {
         return fail(jsapi, rs);
+    }
 
     ObjectOpResult success;
-    if (!JS_DefinePropertyById(cx, obj, id, desc, success))
+    if (!JS_DefinePropertyById(cx, obj, id, desc, success)) {
         return fail(jsapi, rs);
+    }
     return ok(rs, success);
 }
 
 bool
 WrapperAnswer::RecvDelete(const ObjectId& objId, const JSIDVariant& idVar, ReturnStatus* rs)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("delete %s[%s]", ReceiverObj(objId), Identifier(idVar));
 
     RootedId id(cx);
-    if (!fromJSIDVariant(cx, idVar, &id))
+    if (!fromJSIDVariant(cx, idVar, &id)) {
         return fail(jsapi, rs);
+    }
 
     ObjectOpResult success;
-    if (!JS_DeletePropertyById(cx, obj, id, success))
+    if (!JS_DeletePropertyById(cx, obj, id, success)) {
         return fail(jsapi, rs);
+    }
     return ok(rs, success);
 }
 
 bool
 WrapperAnswer::RecvHas(const ObjectId& objId, const JSIDVariant& idVar, ReturnStatus* rs,
                        bool* foundp)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
     *foundp = false;
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.has(%s)", ReceiverObj(objId), Identifier(idVar));
 
     RootedId id(cx);
-    if (!fromJSIDVariant(cx, idVar, &id))
+    if (!fromJSIDVariant(cx, idVar, &id)) {
         return fail(jsapi, rs);
+    }
 
-    if (!JS_HasPropertyById(cx, obj, id, foundp))
+    if (!JS_HasPropertyById(cx, obj, id, foundp)) {
         return fail(jsapi, rs);
+    }
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvHasOwn(const ObjectId& objId, const JSIDVariant& idVar, ReturnStatus* rs,
                           bool* foundp)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
     *foundp = false;
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.hasOwn(%s)", ReceiverObj(objId), Identifier(idVar));
 
     RootedId id(cx);
-    if (!fromJSIDVariant(cx, idVar, &id))
+    if (!fromJSIDVariant(cx, idVar, &id)) {
         return fail(jsapi, rs);
+    }
 
-    if (!JS_HasOwnPropertyById(cx, obj, id, foundp))
+    if (!JS_HasOwnPropertyById(cx, obj, id, foundp)) {
         return fail(jsapi, rs);
+    }
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvGet(const ObjectId& objId, const JSVariant& receiverVar,
                        const JSIDVariant& idVar, ReturnStatus* rs, JSVariant* result)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     // We may run scripted getters.
     AutoEntryScript aes(scopeForTargetObjects(),
                         "Cross-Process Object Wrapper 'get'");
     JSContext* cx = aes.cx();
 
     // The outparam will be written to the buffer, so it must be set even if
     // the parent won't read it.
     *result = UndefinedVariant();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(aes, rs);
+    }
 
     RootedValue receiver(cx);
-    if (!fromVariant(cx, receiverVar, &receiver))
+    if (!fromVariant(cx, receiverVar, &receiver)) {
         return fail(aes, rs);
+    }
 
     RootedId id(cx);
-    if (!fromJSIDVariant(cx, idVar, &id))
+    if (!fromJSIDVariant(cx, idVar, &id)) {
         return fail(aes, rs);
+    }
 
     JS::RootedValue val(cx);
-    if (!JS_ForwardGetPropertyTo(cx, obj, id, receiver, &val))
+    if (!JS_ForwardGetPropertyTo(cx, obj, id, receiver, &val)) {
         return fail(aes, rs);
+    }
 
-    if (!toVariant(cx, val, result))
+    if (!toVariant(cx, val, result)) {
         return fail(aes, rs);
+    }
 
     LOG("get %s.%s = %s", ReceiverObj(objId), Identifier(idVar), OutVariant(*result));
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvSet(const ObjectId& objId, const JSIDVariant& idVar, const JSVariant& value,
                        const JSVariant& receiverVar, ReturnStatus* rs)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     // We may run scripted setters.
     AutoEntryScript aes(scopeForTargetObjects(),
                         "Cross-Process Object Wrapper 'set'");
     JSContext* cx = aes.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(aes, rs);
+    }
 
     LOG("set %s[%s] = %s", ReceiverObj(objId), Identifier(idVar), InVariant(value));
 
     RootedId id(cx);
-    if (!fromJSIDVariant(cx, idVar, &id))
+    if (!fromJSIDVariant(cx, idVar, &id)) {
         return fail(aes, rs);
+    }
 
     RootedValue val(cx);
-    if (!fromVariant(cx, value, &val))
+    if (!fromVariant(cx, value, &val)) {
         return fail(aes, rs);
+    }
 
     RootedValue receiver(cx);
-    if (!fromVariant(cx, receiverVar, &receiver))
+    if (!fromVariant(cx, receiverVar, &receiver)) {
         return fail(aes, rs);
+    }
 
     ObjectOpResult result;
-    if (!JS_ForwardSetPropertyTo(cx, obj, id, val, receiver, result))
+    if (!JS_ForwardSetPropertyTo(cx, obj, id, val, receiver, result)) {
         return fail(aes, rs);
+    }
 
     return ok(rs, result);
 }
 
 bool
 WrapperAnswer::RecvIsExtensible(const ObjectId& objId, ReturnStatus* rs, bool* result)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
     *result = false;
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.isExtensible()", ReceiverObj(objId));
 
     bool extensible;
-    if (!JS_IsExtensible(cx, obj, &extensible))
+    if (!JS_IsExtensible(cx, obj, &extensible)) {
         return fail(jsapi, rs);
+    }
 
     *result = !!extensible;
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvCallOrConstruct(const ObjectId& objId,
                                    InfallibleTArray<JSParam>&& argv,
                                    const bool& construct,
                                    ReturnStatus* rs,
                                    JSVariant* result,
                                    nsTArray<JSParam>* outparams)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoEntryScript aes(scopeForTargetObjects(),
                         "Cross-Process Object Wrapper call/construct");
     JSContext* cx = aes.cx();
 
     // The outparam will be written to the buffer, so it must be set even if
     // the parent won't read it.
     *result = UndefinedVariant();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(aes, rs);
+    }
 
     MOZ_ASSERT(argv.Length() >= 2);
 
     RootedValue objv(cx);
-    if (!fromVariant(cx, argv[0], &objv))
+    if (!fromVariant(cx, argv[0], &objv)) {
         return fail(aes, rs);
+    }
 
     *result = JSVariant(UndefinedVariant());
 
     AutoValueVector vals(cx);
     AutoValueVector outobjects(cx);
     for (size_t i = 0; i < argv.Length(); i++) {
         if (argv[i].type() == JSParam::Tvoid_t) {
             // This is an outparam.
             RootedObject obj(cx, xpc::NewOutObject(cx));
-            if (!obj)
+            if (!obj) {
+                return fail(aes, rs);
+            }
+            if (!outobjects.append(ObjectValue(*obj))) {
                 return fail(aes, rs);
-            if (!outobjects.append(ObjectValue(*obj)))
+            }
+            if (!vals.append(ObjectValue(*obj))) {
                 return fail(aes, rs);
-            if (!vals.append(ObjectValue(*obj)))
-                return fail(aes, rs);
+            }
         } else {
             RootedValue v(cx);
-            if (!fromVariant(cx, argv[i].get_JSVariant(), &v))
+            if (!fromVariant(cx, argv[i].get_JSVariant(), &v)) {
                 return fail(aes, rs);
-            if (!vals.append(v))
+            }
+            if (!vals.append(v)) {
                 return fail(aes, rs);
+            }
         }
     }
 
     RootedValue rval(cx);
     {
         HandleValueArray args = HandleValueArray::subarray(vals, 2, vals.length() - 2);
         if (construct) {
             RootedObject obj(cx);
-            if (!JS::Construct(cx, vals[0], args, &obj))
+            if (!JS::Construct(cx, vals[0], args, &obj)) {
                 return fail(aes, rs);
+            }
             rval.setObject(*obj);
         } else {
             if(!JS::Call(cx, vals[1], vals[0], args, &rval))
                 return fail(aes, rs);
         }
     }
 
-    if (!toVariant(cx, rval, result))
+    if (!toVariant(cx, rval, result)) {
         return fail(aes, rs);
+    }
 
     // Prefill everything with a dummy jsval.
-    for (size_t i = 0; i < outobjects.length(); i++)
+    for (size_t i = 0; i < outobjects.length(); i++) {
         outparams->AppendElement(JSParam(void_t()));
+    }
 
     // Go through each argument that was an outparam, retrieve the "value"
     // field, and add it to a temporary list. We need to do this separately
     // because the outparams vector is not rooted.
     vals.clear();
     for (size_t i = 0; i < outobjects.length(); i++) {
         RootedObject obj(cx, &outobjects[i].toObject());
 
         RootedValue v(cx);
         bool found;
         if (JS_HasProperty(cx, obj, "value", &found)) {
-            if (!JS_GetProperty(cx, obj, "value", &v))
+            if (!JS_GetProperty(cx, obj, "value", &v)) {
                 return fail(aes, rs);
+            }
         } else {
             v = UndefinedValue();
         }
-        if (!vals.append(v))
+        if (!vals.append(v)) {
             return fail(aes, rs);
+        }
     }
 
     // Copy the outparams. If any outparam is already set to a void_t, we
     // treat this as the outparam never having been set.
     for (size_t i = 0; i < vals.length(); i++) {
         JSVariant variant;
-        if (!toVariant(cx, vals[i], &variant))
+        if (!toVariant(cx, vals[i], &variant)) {
             return fail(aes, rs);
+        }
         outparams->ReplaceElementAt(i, JSParam(variant));
     }
 
     LOG("%s.call(%s) = %s", ReceiverObj(objId), argv, OutVariant(*result));
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvHasInstance(const ObjectId& objId, const JSVariant& vVar, ReturnStatus* rs, bool* bp)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.hasInstance(%s)", ReceiverObj(objId), InVariant(vVar));
 
     RootedValue val(cx);
-    if (!fromVariant(cx, vVar, &val))
+    if (!fromVariant(cx, vVar, &val)) {
         return fail(jsapi, rs);
+    }
 
-    if (!JS_HasInstance(cx, obj, val, bp))
+    if (!JS_HasInstance(cx, obj, val, bp)) {
         return fail(jsapi, rs);
+    }
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvGetBuiltinClass(const ObjectId& objId, ReturnStatus* rs,
                                    uint32_t* classValue)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     *classValue = uint32_t(js::ESClass::Other);
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.getBuiltinClass()", ReceiverObj(objId));
 
     js::ESClass cls;
-    if (!js::GetBuiltinClass(cx, obj, &cls))
+    if (!js::GetBuiltinClass(cx, obj, &cls)) {
         return fail(jsapi, rs);
+    }
 
     *classValue = uint32_t(cls);
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvIsArray(const ObjectId& objId, ReturnStatus* rs,
                            uint32_t* ans)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     *ans = uint32_t(IsArrayAnswer::NotArray);
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.isArray()", ReceiverObj(objId));
 
     IsArrayAnswer answer;
-    if (!JS::IsArray(cx, obj, &answer))
+    if (!JS::IsArray(cx, obj, &answer)) {
         return fail(jsapi, rs);
+    }
 
     *ans = uint32_t(answer);
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvClassName(const ObjectId& objId, nsCString* name)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
     if (!obj) {
         // This is very unfortunate, but we have no choice.
         *name = "<dead CPOW>";
         return true;
     }
@@ -618,199 +697,227 @@ WrapperAnswer::RecvClassName(const Objec
 
     *name = js::ObjectClassName(cx, obj);
     return true;
 }
 
 bool
 WrapperAnswer::RecvGetPrototype(const ObjectId& objId, ReturnStatus* rs, ObjectOrNullVariant* result)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     *result = NullVariant();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     JS::RootedObject proto(cx);
-    if (!JS_GetPrototype(cx, obj, &proto))
+    if (!JS_GetPrototype(cx, obj, &proto)) {
         return fail(jsapi, rs);
+    }
 
-    if (!toObjectOrNullVariant(cx, proto, result))
+    if (!toObjectOrNullVariant(cx, proto, result)) {
         return fail(jsapi, rs);
+    }
 
     LOG("getPrototype(%s)", ReceiverObj(objId));
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvGetPrototypeIfOrdinary(const ObjectId& objId, ReturnStatus* rs, bool* isOrdinary,
                                           ObjectOrNullVariant* result)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     *result = NullVariant();
     *isOrdinary = false;
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     JS::RootedObject proto(cx);
-    if (!JS_GetPrototypeIfOrdinary(cx, obj, isOrdinary, &proto))
+    if (!JS_GetPrototypeIfOrdinary(cx, obj, isOrdinary, &proto)) {
         return fail(jsapi, rs);
+    }
 
-    if (!toObjectOrNullVariant(cx, proto, result))
+    if (!toObjectOrNullVariant(cx, proto, result)) {
         return fail(jsapi, rs);
+    }
 
     LOG("getPrototypeIfOrdinary(%s)", ReceiverObj(objId));
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvRegExpToShared(const ObjectId& objId, ReturnStatus* rs,
                                   nsString* source, uint32_t* flags)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     RootedString sourceJSStr(cx, JS_GetRegExpSource(cx, obj));
-    if (!sourceJSStr)
+    if (!sourceJSStr) {
         return fail(jsapi, rs);
+    }
     nsAutoJSString sourceStr;
-    if (!sourceStr.init(cx, sourceJSStr))
+    if (!sourceStr.init(cx, sourceJSStr)) {
         return fail(jsapi, rs);
+    }
     source->Assign(sourceStr);
 
     *flags = JS_GetRegExpFlags(cx, obj);
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvGetPropertyKeys(const ObjectId& objId, const uint32_t& flags,
                                    ReturnStatus* rs, nsTArray<JSIDVariant>* ids)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.getPropertyKeys()", ReceiverObj(objId));
 
     AutoIdVector props(cx);
-    if (!js::GetPropertyKeys(cx, obj, flags, &props))
+    if (!js::GetPropertyKeys(cx, obj, flags, &props)) {
         return fail(jsapi, rs);
+    }
 
     for (size_t i = 0; i < props.length(); i++) {
         JSIDVariant id;
-        if (!toJSIDVariant(cx, props[i], &id))
+        if (!toJSIDVariant(cx, props[i], &id)) {
             return fail(jsapi, rs);
+        }
 
         ids->AppendElement(id);
     }
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvInstanceOf(const ObjectId& objId, const JSIID& iid, ReturnStatus* rs,
                               bool* instanceof)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
 
     *instanceof = false;
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.instanceOf()", ReceiverObj(objId));
 
     nsID nsiid;
     ConvertID(iid, &nsiid);
 
     nsresult rv = xpc::HasInstance(cx, obj, &nsiid, instanceof);
-    if (rv != NS_OK)
+    if (rv != NS_OK) {
         return fail(jsapi, rs);
+    }
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvDOMInstanceOf(const ObjectId& objId, const int& prototypeID,
                                  const int& depth, ReturnStatus* rs, bool* instanceof)
 {
-    if (!IsInAutomation())
+    if (!IsInAutomation()) {
         return false;
+    }
 
     MaybeForceDebugGC();
 
     AutoJSAPI jsapi;
-    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects())))
+    if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) {
         return false;
+    }
     JSContext* cx = jsapi.cx();
     *instanceof = false;
 
     RootedObject obj(cx, findObjectById(cx, objId));
-    if (!obj)
+    if (!obj) {
         return deadCPOW(jsapi, rs);
+    }
 
     LOG("%s.domInstanceOf()", ReceiverObj(objId));
 
     bool tmp;
-    if (!mozilla::dom::InterfaceHasInstance(cx, prototypeID, depth, obj, &tmp))
+    if (!mozilla::dom::InterfaceHasInstance(cx, prototypeID, depth, obj, &tmp)) {
         return fail(jsapi, rs);
+    }
     *instanceof = tmp;
 
     return ok(rs);
 }
 
 bool
 WrapperAnswer::RecvDropObject(const ObjectId& objId)
 {
--- a/js/ipc/WrapperOwner.cpp
+++ b/js/ipc/WrapperOwner.cpp
@@ -167,28 +167,31 @@ CPOWProxyHandler::getOwnPropertyDescript
 
 bool
 WrapperOwner::getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
                                        MutableHandle<PropertyDescriptor> desc)
 {
     ObjectId objId = idOf(proxy);
 
     JSIDVariant idVar;
-    if (!toJSIDVariant(cx, id, &idVar))
+    if (!toJSIDVariant(cx, id, &idVar)) {
         return false;
+    }
 
     ReturnStatus status;
     PPropertyDescriptor result;
-    if (!SendGetOwnPropertyDescriptor(objId, idVar, &status, &result))
+    if (!SendGetOwnPropertyDescriptor(objId, idVar, &status, &result)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
-    if (!ok(cx, status))
+    if (!ok(cx, status)) {
         return false;
+    }
 
     return toDescriptor(cx, result, desc);
 }
 
 bool
 CPOWProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, HandleId id,
                                  Handle<PropertyDescriptor> desc,
                                  ObjectOpResult& result) const
@@ -199,26 +202,29 @@ CPOWProxyHandler::defineProperty(JSConte
 bool
 WrapperOwner::defineProperty(JSContext* cx, HandleObject proxy, HandleId id,
                              Handle<PropertyDescriptor> desc,
                              ObjectOpResult& result)
 {
     ObjectId objId = idOf(proxy);
 
     JSIDVariant idVar;
-    if (!toJSIDVariant(cx, id, &idVar))
+    if (!toJSIDVariant(cx, id, &idVar)) {
         return false;
+    }
 
     PPropertyDescriptor descriptor;
-    if (!fromDescriptor(cx, desc, &descriptor))
+    if (!fromDescriptor(cx, desc, &descriptor)) {
         return false;
+    }
 
     ReturnStatus status;
-    if (!SendDefineProperty(objId, idVar, descriptor, &status))
+    if (!SendDefineProperty(objId, idVar, descriptor, &status)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status, result);
 }
 
 bool
 CPOWProxyHandler::ownPropertyKeys(JSContext* cx, HandleObject proxy,
@@ -241,22 +247,24 @@ CPOWProxyHandler::delete_(JSContext* cx,
 }
 
 bool
 WrapperOwner::delete_(JSContext* cx, HandleObject proxy, HandleId id, ObjectOpResult& result)
 {
     ObjectId objId = idOf(proxy);
 
     JSIDVariant idVar;
-    if (!toJSIDVariant(cx, id, &idVar))
+    if (!toJSIDVariant(cx, id, &idVar)) {
         return false;
+    }
 
     ReturnStatus status;
-    if (!SendDelete(objId, idVar, &status))
+    if (!SendDelete(objId, idVar, &status)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status, result);
 }
 
 JSObject*
 CPOWProxyHandler::enumerate(JSContext* cx, HandleObject proxy) const
@@ -274,22 +282,24 @@ CPOWProxyHandler::has(JSContext* cx, Han
 }
 
 bool
 WrapperOwner::has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp)
 {
     ObjectId objId = idOf(proxy);
 
     JSIDVariant idVar;
-    if (!toJSIDVariant(cx, id, &idVar))
+    if (!toJSIDVariant(cx, id, &idVar)) {
         return false;
+    }
 
     ReturnStatus status;
-    if (!SendHas(objId, idVar, &status, bp))
+    if (!SendHas(objId, idVar, &status, bp)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status);
 }
 
 bool
 CPOWProxyHandler::hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const
@@ -298,22 +308,24 @@ CPOWProxyHandler::hasOwn(JSContext* cx, 
 }
 
 bool
 WrapperOwner::hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp)
 {
     ObjectId objId = idOf(proxy);
 
     JSIDVariant idVar;
-    if (!toJSIDVariant(cx, id, &idVar))
+    if (!toJSIDVariant(cx, id, &idVar)) {
         return false;
+    }
 
     ReturnStatus status;
-    if (!SendHasOwn(objId, idVar, &status, bp))
+    if (!SendHasOwn(objId, idVar, &status, bp)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return !!ok(cx, status);
 }
 
 bool
 CPOWProxyHandler::get(JSContext* cx, HandleObject proxy, HandleValue receiver,
@@ -336,59 +348,64 @@ CPOWDOMQI(JSContext* cx, unsigned argc, 
 }
 
 static bool
 CPOWToString(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     RootedObject callee(cx, &args.callee());
     RootedValue cpowValue(cx);
-    if (!JS_GetProperty(cx, callee, "__cpow__", &cpowValue))
+    if (!JS_GetProperty(cx, callee, "__cpow__", &cpowValue)) {
         return false;
+    }
 
     if (!cpowValue.isObject() || !IsCPOW(&cpowValue.toObject())) {
         JS_ReportErrorASCII(cx, "CPOWToString called on an incompatible object");
         return false;
     }
 
     RootedObject proxy(cx, &cpowValue.toObject());
     FORWARD(toString, (cx, proxy, args), false);
 }
 
 bool
 WrapperOwner::toString(JSContext* cx, HandleObject cpow, JS::CallArgs& args)
 {
     // Ask the other side to call its toString method. Update the callee so that
     // it points to the CPOW and not to the synthesized CPOWToString function.
     args.setCallee(ObjectValue(*cpow));
-    if (!callOrConstruct(cx, cpow, args, false))
+    if (!callOrConstruct(cx, cpow, args, false)) {
         return false;
+    }
 
-    if (!args.rval().isString())
+    if (!args.rval().isString()) {
         return true;
+    }
 
     RootedString cpowResult(cx, args.rval().toString());
     nsAutoJSString toStringResult;
-    if (!toStringResult.init(cx, cpowResult))
+    if (!toStringResult.init(cx, cpowResult)) {
         return false;
+    }
 
     // We don't want to wrap toString() results for things like the location
     // object, where toString() is supposed to return a URL and nothing else.
     nsAutoString result;
     if (toStringResult[0] == '[') {
         result.AppendLiteral("[object CPOW ");
         result += toStringResult;
         result.AppendLiteral("]");
     } else {
         result += toStringResult;
     }
 
     JSString* str = JS_NewUCStringCopyN(cx, result.get(), result.Length());
-    if (!str)
+    if (!str) {
         return false;
+    }
 
     args.rval().setString(str);
     return true;
 }
 
 bool
 WrapperOwner::DOMQI(JSContext* cx, JS::HandleObject proxy, JS::CallArgs& args)
 {
@@ -404,93 +421,103 @@ WrapperOwner::DOMQI(JSContext* cx, JS::H
             MOZ_ASSERT(jsid, "bad wrapJS");
             const nsID* idptr = jsid->GetID();
             if (idptr->Equals(NS_GET_IID(nsISupports))) {
                 args.rval().set(args.thisv());
                 return true;
             }
 
             // Webidl-implemented DOM objects never have nsIClassInfo.
-            if (idptr->Equals(NS_GET_IID(nsIClassInfo)))
+            if (idptr->Equals(NS_GET_IID(nsIClassInfo))) {
                 return Throw(cx, NS_ERROR_NO_INTERFACE);
+            }
         }
     }
 
     // It wasn't nsISupports, call into the other process to do the QI for us
     // (since we don't know what other interfaces our object supports). Note
     // that we have to use JS_GetPropertyDescriptor here to avoid infinite
     // recursion back into CPOWDOMQI via WrapperOwner::get().
     // We could stash the actual QI function on our own function object to avoid
     // if we're called multiple times, but since we're transient, there's no
     // point right now.
     JS::Rooted<PropertyDescriptor> propDesc(cx);
-    if (!JS_GetPropertyDescriptor(cx, proxy, "QueryInterface", &propDesc))
+    if (!JS_GetPropertyDescriptor(cx, proxy, "QueryInterface", &propDesc)) {
         return false;
+    }
 
     if (!propDesc.value().isObject()) {
         MOZ_ASSERT_UNREACHABLE("We didn't get QueryInterface off a node");
         return Throw(cx, NS_ERROR_UNEXPECTED);
     }
     return JS_CallFunctionValue(cx, proxy, propDesc.value(), args, args.rval());
 }
 
 bool
 WrapperOwner::get(JSContext* cx, HandleObject proxy, HandleValue receiver,
                   HandleId id, MutableHandleValue vp)
 {
     ObjectId objId = idOf(proxy);
 
     JSVariant receiverVar;
-    if (!toVariant(cx, receiver, &receiverVar))
+    if (!toVariant(cx, receiver, &receiverVar)) {
         return false;
+    }
 
     JSIDVariant idVar;
-    if (!toJSIDVariant(cx, id, &idVar))
+    if (!toJSIDVariant(cx, id, &idVar)) {
         return false;
+    }
 
     AuxCPOWData* data = AuxCPOWDataOf(proxy);
     if (data->isDOMObject &&
         idVar.type() == JSIDVariant::TnsString &&
         idVar.get_nsString().EqualsLiteral("QueryInterface"))
     {
         // Handle QueryInterface on DOM Objects specially since we can assume
         // certain things about their implementation.
         RootedFunction qi(cx, JS_NewFunction(cx, CPOWDOMQI, 1, 0,
                                              "QueryInterface"));
-        if (!qi)
+        if (!qi) {
             return false;
+        }
 
         vp.set(ObjectValue(*JS_GetFunctionObject(qi)));
         return true;
     }
 
     JSVariant val;
     ReturnStatus status;
-    if (!SendGet(objId, receiverVar, idVar, &status, &val))
+    if (!SendGet(objId, receiverVar, idVar, &status, &val)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
-    if (!ok(cx, status))
+    if (!ok(cx, status)) {
         return false;
+    }
 
-    if (!fromVariant(cx, val, vp))
+    if (!fromVariant(cx, val, vp)) {
         return false;
+    }
 
     if (idVar.type() == JSIDVariant::TnsString &&
         idVar.get_nsString().EqualsLiteral("toString")) {
         RootedFunction toString(cx, JS_NewFunction(cx, CPOWToString, 0, 0,
                                                    "toString"));
-        if (!toString)
+        if (!toString) {
             return false;
+        }
 
         RootedObject toStringObj(cx, JS_GetFunctionObject(toString));
 
-        if (!JS_DefineProperty(cx, toStringObj, "__cpow__", vp, JSPROP_PERMANENT | JSPROP_READONLY))
+        if (!JS_DefineProperty(cx, toStringObj, "__cpow__", vp, JSPROP_PERMANENT | JSPROP_READONLY)) {
             return false;
+        }
 
         vp.set(ObjectValue(*toStringObj));
     }
 
     return true;
 }
 
 bool
@@ -502,30 +529,34 @@ CPOWProxyHandler::set(JSContext* cx, JS:
 
 bool
 WrapperOwner::set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue v,
                   JS::HandleValue receiver, JS::ObjectOpResult& result)
 {
     ObjectId objId = idOf(proxy);
 
     JSIDVariant idVar;
-    if (!toJSIDVariant(cx, id, &idVar))
+    if (!toJSIDVariant(cx, id, &idVar)) {
         return false;
+    }
 
     JSVariant val;
-    if (!toVariant(cx, v, &val))
+    if (!toVariant(cx, v, &val)) {
         return false;
+    }
 
     JSVariant receiverVar;
-    if (!toVariant(cx, receiver, &receiverVar))
+    if (!toVariant(cx, receiver, &receiverVar)) {
         return false;
+    }
 
     ReturnStatus status;
-    if (!SendSet(objId, idVar, val, receiverVar, &status))
+    if (!SendSet(objId, idVar, val, receiverVar, &status)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status, result);
 }
 
 bool
 CPOWProxyHandler::getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy,
@@ -547,18 +578,19 @@ CPOWProxyHandler::preventExtensions(JSCo
 }
 
 bool
 WrapperOwner::preventExtensions(JSContext* cx, HandleObject proxy, ObjectOpResult& result)
 {
     ObjectId objId = idOf(proxy);
 
     ReturnStatus status;
-    if (!SendPreventExtensions(objId, &status))
+    if (!SendPreventExtensions(objId, &status)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status, result);
 }
 
 bool
 CPOWProxyHandler::isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const
@@ -567,18 +599,19 @@ CPOWProxyHandler::isExtensible(JSContext
 }
 
 bool
 WrapperOwner::isExtensible(JSContext* cx, HandleObject proxy, bool* extensible)
 {
     ObjectId objId = idOf(proxy);
 
     ReturnStatus status;
-    if (!SendIsExtensible(objId, &status, extensible))
+    if (!SendIsExtensible(objId, &status, extensible)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status);
 }
 
 bool
 CPOWProxyHandler::call(JSContext* cx, HandleObject proxy, const CallArgs& args) const
@@ -600,98 +633,111 @@ WrapperOwner::callOrConstruct(JSContext*
 
     InfallibleTArray<JSParam> vals;
     AutoValueVector outobjects(cx);
 
     RootedValue v(cx);
     for (size_t i = 0; i < args.length() + 2; i++) {
         // The |this| value for constructors is a magic value that we won't be
         // able to convert, so skip it.
-        if (i == 1 && construct)
+        if (i == 1 && construct) {
             v = UndefinedValue();
-        else
+        } else {
             v = args.base()[i];
+        }
         if (v.isObject()) {
             RootedObject obj(cx, &v.toObject());
             if (xpc::IsOutObject(cx, obj)) {
                 // Make sure it is not an in-out object.
                 bool found;
-                if (!JS_HasProperty(cx, obj, "value", &found))
+                if (!JS_HasProperty(cx, obj, "value", &found)) {
                     return false;
+                }
                 if (found) {
                     JS_ReportErrorASCII(cx, "in-out objects cannot be sent via CPOWs yet");
                     return false;
                 }
 
                 vals.AppendElement(JSParam(void_t()));
-                if (!outobjects.append(ObjectValue(*obj)))
+                if (!outobjects.append(ObjectValue(*obj))) {
                     return false;
+                }
                 continue;
             }
         }
         JSVariant val;
-        if (!toVariant(cx, v, &val))
+        if (!toVariant(cx, v, &val)) {
             return false;
+        }
         vals.AppendElement(JSParam(val));
     }
 
     JSVariant result;
     ReturnStatus status;
     InfallibleTArray<JSParam> outparams;
-    if (!SendCallOrConstruct(objId, vals, construct, &status, &result, &outparams))
+    if (!SendCallOrConstruct(objId, vals, construct, &status, &result, &outparams)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
-    if (!ok(cx, status))
+    if (!ok(cx, status)) {
         return false;
+    }
 
-    if (outparams.Length() != outobjects.length())
+    if (outparams.Length() != outobjects.length()) {
         return ipcfail(cx);
+    }
 
     RootedObject obj(cx);
     for (size_t i = 0; i < outparams.Length(); i++) {
         // Don't bother doing anything for outparams that weren't set.
-        if (outparams[i].type() == JSParam::Tvoid_t)
+        if (outparams[i].type() == JSParam::Tvoid_t) {
             continue;
+        }
 
         // Take the value the child process returned, and set it on the XPC
         // object.
-        if (!fromVariant(cx, outparams[i], &v))
+        if (!fromVariant(cx, outparams[i], &v)) {
             return false;
+        }
 
         obj = &outobjects[i].toObject();
-        if (!JS_SetProperty(cx, obj, "value", v))
+        if (!JS_SetProperty(cx, obj, "value", v)) {
             return false;
+        }
     }
 
-    if (!fromVariant(cx, result, args.rval()))
+    if (!fromVariant(cx, result, args.rval())) {
         return false;
+    }
 
     return true;
 }
 
 bool
 CPOWProxyHandler::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp) const
 {
     FORWARD(hasInstance, (cx, proxy, v, bp), false);
 }
 
 bool
 WrapperOwner::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp)
 {
     ObjectId objId = idOf(proxy);
 
     JSVariant vVar;
-    if (!toVariant(cx, v, &vVar))
+    if (!toVariant(cx, v, &vVar)) {
         return false;
+    }
 
     ReturnStatus status;
-    if (!SendHasInstance(objId, vVar, &status, bp))
+    if (!SendHasInstance(objId, vVar, &status, bp)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status);
 }
 
 bool
 CPOWProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const
@@ -701,18 +747,19 @@ CPOWProxyHandler::getBuiltinClass(JSCont
 
 bool
 WrapperOwner::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls)
 {
     ObjectId objId = idOf(proxy);
 
     uint32_t classValue = uint32_t(ESClass::Other);
     ReturnStatus status;
-    if (!SendGetBuiltinClass(objId, &status, &classValue))
+    if (!SendGetBuiltinClass(objId, &status, &classValue)) {
         return ipcfail(cx);
+    }
     *cls = ESClass(classValue);
 
     LOG_STACK();
 
     return ok(cx, status);
 }
 
 bool
@@ -724,47 +771,50 @@ CPOWProxyHandler::isArray(JSContext* cx,
 
 bool
 WrapperOwner::isArray(JSContext* cx, HandleObject proxy, IsArrayAnswer* answer)
 {
     ObjectId objId = idOf(proxy);
 
     uint32_t ans;
     ReturnStatus status;
-    if (!SendIsArray(objId, &status, &ans))
+    if (!SendIsArray(objId, &status, &ans)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     *answer = IsArrayAnswer(ans);
     MOZ_ASSERT(*answer == IsArrayAnswer::Array ||
                *answer == IsArrayAnswer::NotArray ||
                *answer == IsArrayAnswer::RevokedProxy);
 
     return ok(cx, status);
 }
 
 const char*
 CPOWProxyHandler::className(JSContext* cx, HandleObject proxy) const
 {
     WrapperOwner* parent = OwnerOf(proxy);
-    if (!parent->active())
+    if (!parent->active()) {
         return "<dead CPOW>";
+    }
     return parent->className(cx, proxy);
 }
 
 const char*
 WrapperOwner::className(JSContext* cx, HandleObject proxy)
 {
     AuxCPOWData* data = AuxCPOWDataOf(proxy);
     if (data->className.IsEmpty()) {
         ObjectId objId = idOf(proxy);
 
-        if (!SendClassName(objId, &data->className))
+        if (!SendClassName(objId, &data->className)) {
             return "<error>";
+        }
 
         LOG_STACK();
     }
 
     return data->className.get();
 }
 
 bool
@@ -775,23 +825,25 @@ CPOWProxyHandler::getPrototype(JSContext
 
 bool
 WrapperOwner::getPrototype(JSContext* cx, HandleObject proxy, MutableHandleObject objp)
 {
     ObjectId objId = idOf(proxy);
 
     ObjectOrNullVariant val;
     ReturnStatus status;
-    if (!SendGetPrototype(objId, &status, &val))
+    if (!SendGetPrototype(objId, &status, &val)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
-    if (!ok(cx, status))
+    if (!ok(cx, status)) {
         return false;
+    }
 
     objp.set(fromObjectOrNullVariant(cx, val));
 
     return true;
 }
 
 bool
 CPOWProxyHandler::getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary,
@@ -803,23 +855,25 @@ CPOWProxyHandler::getPrototypeIfOrdinary
 bool
 WrapperOwner::getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary,
                                      MutableHandleObject objp)
 {
     ObjectId objId = idOf(proxy);
 
     ObjectOrNullVariant val;
     ReturnStatus status;
-    if (!SendGetPrototypeIfOrdinary(objId, &status, isOrdinary, &val))
+    if (!SendGetPrototypeIfOrdinary(objId, &status, isOrdinary, &val)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
-    if (!ok(cx, status))
+    if (!ok(cx, status)) {
         return false;
+    }
 
     objp.set(fromObjectOrNullVariant(cx, val));
 
     return true;
 }
 
 RegExpShared*
 CPOWProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy) const
@@ -836,36 +890,39 @@ WrapperOwner::regexp_toShared(JSContext*
     nsString source;
     unsigned flags = 0;
     if (!SendRegExpToShared(objId, &status, &source, &flags)) {
         MOZ_ALWAYS_FALSE(ipcfail(cx));
         return nullptr;
     }
     LOG_STACK();
 
-    if (!ok(cx, status))
+    if (!ok(cx, status)) {
         return nullptr;
+    }
 
     RootedObject regexp(cx);
     regexp = JS_NewUCRegExpObject(cx, source.get(), source.Length(), flags);
-    if (!regexp)
+    if (!regexp) {
         return nullptr;
+    }
 
     return js::RegExpToSharedNonInline(cx, regexp);
 }
 
 void
 CPOWProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
 {
     AuxCPOWData* aux = AuxCPOWDataOf(proxy);
 
     OwnerOf(proxy)->drop(proxy);
 
-    if (aux)
+    if (aux) {
         delete aux;
+    }
 }
 
 size_t
 CPOWProxyHandler::objectMoved(JSObject* proxy, JSObject* old) const
 {
     OwnerOf(proxy)->updatePointer(proxy, old);
     return 0;
 }
@@ -885,21 +942,23 @@ CPOWProxyHandler::isConstructor(JSObject
 }
 
 void
 WrapperOwner::drop(JSObject* obj)
 {
     // The association may have already been swept from the table but if it's
     // there then remove it.
     ObjectId objId = idOfUnchecked(obj);
-    if (cpows_.findPreserveColor(objId) == obj)
+    if (cpows_.findPreserveColor(objId) == obj) {
         cpows_.remove(objId);
+    }
 
-    if (active())
+    if (active()) {
         Unused << SendDropObject(objId);
+    }
     decref();
 }
 
 void
 WrapperOwner::updatePointer(JSObject* obj, const JSObject* old)
 {
     ObjectId objId = idOfUnchecked(obj);
     MOZ_ASSERT(hasCPOW(objId, old));
@@ -908,30 +967,34 @@ WrapperOwner::updatePointer(JSObject* ob
 
 bool
 WrapperOwner::getPropertyKeys(JSContext* cx, HandleObject proxy, uint32_t flags, AutoIdVector& props)
 {
     ObjectId objId = idOf(proxy);
 
     ReturnStatus status;
     InfallibleTArray<JSIDVariant> ids;
-    if (!SendGetPropertyKeys(objId, flags, &status, &ids))
+    if (!SendGetPropertyKeys(objId, flags, &status, &ids)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
-    if (!ok(cx, status))
+    if (!ok(cx, status)) {
         return false;
+    }
 
     for (size_t i = 0; i < ids.Length(); i++) {
         RootedId id(cx);
-        if (!fromJSIDVariant(cx, ids[i], &id))
+        if (!fromJSIDVariant(cx, ids[i], &id)) {
             return false;
-        if (!props.append(id))
+        }
+        if (!props.append(id)) {
             return false;
+        }
     }
 
     return true;
 }
 
 namespace mozilla {
 namespace jsipc {
 
@@ -940,38 +1003,41 @@ IsCPOW(JSObject* obj)
 {
     return IsProxy(obj) && GetProxyHandler(obj) == &CPOWProxyHandler::singleton;
 }
 
 bool
 IsWrappedCPOW(JSObject* obj)
 {
     JSObject* unwrapped = js::UncheckedUnwrap(obj, true);
-    if (!unwrapped)
+    if (!unwrapped) {
         return false;
+    }
     return IsCPOW(unwrapped);
 }
 
 void
 GetWrappedCPOWTag(JSObject* obj, nsACString& out)
 {
     JSObject* unwrapped = js::UncheckedUnwrap(obj, true);
     MOZ_ASSERT(IsCPOW(unwrapped));
 
     AuxCPOWData* aux = AuxCPOWDataOf(unwrapped);
-    if (aux)
+    if (aux) {
         out = aux->objectTag;
+    }
 }
 
 nsresult
 InstanceOf(JSObject* proxy, const nsID* id, bool* bp)
 {
     WrapperOwner* parent = OwnerOf(proxy);
-    if (!parent->active())
+    if (!parent->active()) {
         return NS_ERROR_UNEXPECTED;
+    }
     return parent->instanceOf(proxy, id, bp);
 }
 
 bool
 DOMInstanceOf(JSContext* cx, JSObject* proxyArg, int prototypeID, int depth, bool* bp)
 {
     RootedObject proxy(cx, proxyArg);
     FORWARD(domInstanceOf, (cx, proxy, prototypeID, depth, bp), false);
@@ -984,33 +1050,36 @@ nsresult
 WrapperOwner::instanceOf(JSObject* obj, const nsID* id, bool* bp)
 {
     ObjectId objId = idOf(obj);
 
     JSIID iid;
     ConvertID(*id, &iid);
 
     ReturnStatus status;
-    if (!SendInstanceOf(objId, iid, &status, bp))
+    if (!SendInstanceOf(objId, iid, &status, bp)) {
         return NS_ERROR_UNEXPECTED;
+    }
 
-    if (status.type() != ReturnStatus::TReturnSuccess)
+    if (status.type() != ReturnStatus::TReturnSuccess) {
         return NS_ERROR_UNEXPECTED;
+    }
 
     return NS_OK;
 }
 
 bool
 WrapperOwner::domInstanceOf(JSContext* cx, JSObject* obj, int prototypeID, int depth, bool* bp)
 {
     ObjectId objId = idOf(obj);
 
     ReturnStatus status;
-    if (!SendDOMInstanceOf(objId, prototypeID, depth, &status, bp))
+    if (!SendDOMInstanceOf(objId, prototypeID, depth, &status, bp)) {
         return ipcfail(cx);
+    }
 
     LOG_STACK();
 
     return ok(cx, status);
 }
 
 void
 WrapperOwner::ActorDestroy(ActorDestroyReason why)
@@ -1027,56 +1096,62 @@ WrapperOwner::ipcfail(JSContext* cx)
 {
     JS_ReportErrorASCII(cx, "cross-process JS call failed");
     return false;
 }
 
 bool
 WrapperOwner::ok(JSContext* cx, const ReturnStatus& status)
 {
-    if (status.type() == ReturnStatus::TReturnSuccess)
+    if (status.type() == ReturnStatus::TReturnSuccess) {
         return true;
+    }
 
     if (status.type() == ReturnStatus::TReturnDeadCPOW) {
         JS_ReportErrorASCII(cx, "operation not possible on dead CPOW");
         return false;
     }
 
     RootedValue exn(cx);
-    if (!fromVariant(cx, status.get_ReturnException().exn(), &exn))
+    if (!fromVariant(cx, status.get_ReturnException().exn(), &exn)) {
         return false;
+    }
 
     JS_SetPendingException(cx, exn);
     return false;
 }
 
 bool
 WrapperOwner::ok(JSContext* cx, const ReturnStatus& status, ObjectOpResult& result)
 {
-    if (status.type() == ReturnStatus::TReturnObjectOpResult)
+    if (status.type() == ReturnStatus::TReturnObjectOpResult) {
         return result.fail(status.get_ReturnObjectOpResult().code());
-    if (!ok(cx, status))
+    }
+    if (!ok(cx, status)) {
         return false;
+    }
     return result.succeed();
 }
 
 // CPOWs can have a tag string attached to them, originating in the local
 // process from this function.  It's sent with the CPOW to the remote process,
 // where it can be fetched with Components.utils.getCrossProcessWrapperTag.
 static nsCString
 GetRemoteObjectTag(JS::Handle<JSObject*> obj)
 {
     if (nsCOMPtr<nsISupports> supports = xpc::UnwrapReflectorToISupports(obj)) {
         nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(supports));
-        if (treeItem)
+        if (treeItem) {
             return NS_LITERAL_CSTRING("ContentDocShellTreeItem");
+        }
 
         nsCOMPtr<nsIDocument> doc(do_QueryInterface(supports));
-        if (doc)
+        if (doc) {
             return NS_LITERAL_CSTRING("ContentDocument");
+        }
     }
 
     return NS_LITERAL_CSTRING("generic");
 }
 
 static RemoteObject
 MakeRemoteObject(JSContext* cx, ObjectId id, HandleObject obj)
 {
@@ -1109,24 +1184,27 @@ WrapperOwner::toObjectVariant(JSContext*
     if (!id.isNull()) {
         MOZ_ASSERT(id.hasXrayWaiver() == waiveXray);
         *objVarp = MakeRemoteObject(cx, id, obj);
         return true;
     }
 
     // Need to call PreserveWrapper on |obj| in case it's a reflector.
     // FIXME: What if it's an XPCWrappedNative?
-    if (mozilla::dom::IsDOMObject(obj))
+    if (mozilla::dom::IsDOMObject(obj)) {
         mozilla::dom::TryPreserveWrapper(obj);
+    }
 
     id = ObjectId(nextSerialNumber_++, waiveXray);
-    if (!objects_.add(id, obj))
+    if (!objects_.add(id, obj)) {
         return false;
-    if (!objectIdMap(waiveXray).add(cx, obj, id))
+    }
+    if (!objectIdMap(waiveXray).add(cx, obj, id)) {
         return false;
+    }
 
     *objVarp = MakeRemoteObject(cx, id, obj);
     return true;
 }
 
 JSObject*
 WrapperOwner::fromObjectVariant(JSContext* cx, const ObjectVariant& objVar)
 {
@@ -1157,48 +1235,53 @@ WrapperOwner::fromRemoteObjectVariant(JS
         // hooks.
         ProxyOptions options;
         options.setLazyProto(true);
         obj = NewProxyObject(cx,
                              &CPOWProxyHandler::singleton,
                              v,
                              nullptr,
                              options);
-        if (!obj)
+        if (!obj) {
             return nullptr;
+        }
 
-        if (!cpows_.add(objId, obj))
+        if (!cpows_.add(objId, obj)) {
             return nullptr;
+        }
 
         nextCPOWNumber_ = objId.serialNumber() + 1;
 
         // Incref once we know the decref will be called.
         incref();
 
         AuxCPOWData* aux = new AuxCPOWData(objId,
                                            objVar.isCallable(),
                                            objVar.isConstructor(),
                                            objVar.isDOMObject(),
                                            objVar.objectTag());
 
         SetProxyReservedSlot(obj, 0, PrivateValue(this));
         SetProxyReservedSlot(obj, 1, PrivateValue(aux));
     }
 
-    if (!JS_WrapObject(cx, &obj))
+    if (!JS_WrapObject(cx, &obj)) {
         return nullptr;
+    }
     return obj;
 }
 
 JSObject*
 WrapperOwner::fromLocalObjectVariant(JSContext* cx, const LocalObject& objVar)
 {
     Maybe<ObjectId> id(ObjectId::deserialize(objVar.serializedId()));
     if (id.isNothing()) {
         return nullptr;
     }
     Rooted<JSObject*> obj(cx, findObjectById(cx, id.value()));
-    if (!obj)
+    if (!obj) {
         return nullptr;
-    if (!JS_WrapObject(cx, &obj))
+    }
+    if (!JS_WrapObject(cx, &obj)) {
         return nullptr;
+    }
     return obj;
 }