if (objPrin && NS_SUCCEEDED(objPrin->GetPrincipal(result))) return NS_OK; } parent = JS_GetParent(aCx, parent); } while (parent);
if (objPrin && ((*result = objPrin->GetPrincipal()))) { NS_ADDREF(*result); return NS_OK; } } parent = JS_GetParent(aCx, parent); } while (parent);
cryptojs_GetObjectPrincipal(JSContext *aCx, JSObject *aObj,                            nsIPrincipal **result){  JSObject *parent = aObj;  do  {    JSClass *jsClass = JS_GetClass(aCx, parent);    const uint32 privateNsISupports = JSCLASS_HAS_PRIVATE |                                       JSCLASS_PRIVATE_IS_NSISUPPORTS;    if (jsClass && (jsClass->flags & (privateNsISupports)) ==                     privateNsISupports)    {      nsCOMPtr<nsISupports> supports = (nsISupports *) JS_GetPrivate(aCx, parent);      nsCOMPtr<nsIScriptObjectPrincipal> objPrin = do_QueryInterface(supports);                    if (!objPrin)      {        /*         * If it's a wrapped native, check the underlying native         * instead.         */        nsCOMPtr<nsIXPConnectWrappedNative> xpcNative =                                             do_QueryInterface(supports);        if (xpcNative)          xpcNative->GetNative(getter_AddRefs(supports));          objPrin = do_QueryInterface(supports);        }        if (objPrin && NS_SUCCEEDED(objPrin->GetPrincipal(result)))          return NS_OK;        }        parent = JS_GetParent(aCx, parent);    } while (parent);    // Couldn't find a principal for this object.    return NS_ERROR_FAILURE;}