nsCOMPtr<nsIJSContextStack> stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1"); NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);  JSContext *cx = nsnull; nsresult rv = NS_OK;  rv = stack->Peek(&cx); NS_ENSURE_SUCCESS(rv, rv); if (!cx) return NS_ERROR_FAILURE;   nsCOMPtr<nsIScriptSecurityManager> secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv);  rv = secMan->CheckSameOrigin(cx, mInner->mURL);  if (NS_FAILED(rv)) { return rv; }
CSSStyleSheetImpl::GetCssRules(nsIDOMCSSRuleList** aCssRules){  if (nsnull == mRuleCollection) {    mRuleCollection = new CSSRuleListImpl(this);    if (nsnull == mRuleCollection) {      return NS_ERROR_OUT_OF_MEMORY;    }    NS_ADDREF(mRuleCollection);  }  *aCssRules = mRuleCollection;  NS_ADDREF(mRuleCollection);  return NS_OK;}