Back out bug 246699 to fix bug 423375, per shaver
authorgavin@gavinsharp.com
Mon, 17 Mar 2008 07:10:48 -0700
changeset 13172 62f025bcb0cc3a2c9ef81544ffc0feee0e3a2236
parent 13171 662ab32fb982b5602e16679bf9107c705c654746
child 13173 36d4da17de367bc9cfdfe31bc03e95e86716cf4e
push idunknown
push userunknown
push dateunknown
bugs246699, 423375
milestone1.9b5pre
Back out bug 246699 to fix bug 423375, per shaver
caps/src/nsScriptSecurityManager.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -144,23 +144,28 @@ static nsIScriptContext *
 GetScriptContext(JSContext *cx)
 {
     return GetScriptContextFromJSContext(cx);
 }
 
 inline void SetPendingException(JSContext *cx, const char *aMsg)
 {
     JSAutoRequest ar(cx);
-    JS_ReportError(cx, "%s", aMsg);
+    JSString *str = JS_NewStringCopyZ(cx, aMsg);
+    if (str)
+        JS_SetPendingException(cx, STRING_TO_JSVAL(str));
 }
 
 inline void SetPendingException(JSContext *cx, const PRUnichar *aMsg)
 {
     JSAutoRequest ar(cx);
-    JS_ReportError(cx, "%hs", aMsg);
+    JSString *str = JS_NewUCStringCopyZ(cx,
+                        reinterpret_cast<const jschar*>(aMsg));
+    if (str)
+        JS_SetPendingException(cx, STRING_TO_JSVAL(str));
 }
 
 // DomainPolicy members
 #ifdef DEBUG_CAPS_DomainPolicyLifeCycle
 PRUint32 DomainPolicy::sObjects=0;
 void DomainPolicy::_printPopulationInfo()
 {
     printf("CAPS.DomainPolicy: Gen. %d, %d DomainPolicy objects.\n",
@@ -695,32 +700,31 @@ nsScriptSecurityManager::CheckSameOrigin
       sourcePrincipal->GetURI(getter_AddRefs(sourceURI));
       NS_ENSURE_TRUE(sourceURI, NS_ERROR_FAILURE);
     }
 
     // Compare origins
     if (!SecurityCompareURIs(sourceURI, aTargetURI))
     {
          ReportError(cx, NS_LITERAL_STRING("CheckSameOriginError"), sourceURI, aTargetURI);
-         return NS_OK;
+         return NS_ERROR_DOM_BAD_URI;
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::CheckSameOriginURI(nsIURI* aSourceURI,
                                             nsIURI* aTargetURI,
                                             PRBool reportError)
 {
     if (!SecurityCompareURIs(aSourceURI, aTargetURI))
     {
          if (reportError) {
             ReportError(nsnull, NS_LITERAL_STRING("CheckSameOriginError"),
                      aSourceURI, aTargetURI);
-            return NS_OK;
          }
          return NS_ERROR_DOM_BAD_URI;
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::CheckSameOriginPrincipal(nsIPrincipal* aSourcePrincipal,
@@ -1278,17 +1282,17 @@ nsScriptSecurityManager::CheckLoadURIFro
             return NS_OK;
     }
 
     // Report error.
     nsCAutoString spec;
     if (NS_FAILED(aURI->GetAsciiSpec(spec)))
         return NS_ERROR_FAILURE;
     JS_ReportError(cx, "Access to '%s' from script denied", spec.get());
-    return NS_OK;
+    return NS_ERROR_DOM_BAD_URI;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::CheckLoadURI(nsIURI *aSourceURI, nsIURI *aTargetURI,
                                       PRUint32 aFlags)
 {
     // FIXME: bug 327244 -- this function should really die...  Really truly.
     NS_PRECONDITION(aSourceURI, "CheckLoadURI called with null source URI");