Bug 715417 - Eliminate getPrincipalArray and globalPrivilegesEnabled from JSPrincipals. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 06 Jan 2012 17:29:02 -0800
changeset 85213 a761ff40306bca0dc384838a73531425cf8b3869
parent 85212 b1612e3ba9b98fd87061a84357226ca1b54f973c
child 85214 20e469f2bd881fd33cba8c2e14f9da73878e9b27
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs715417
milestone12.0a1
Bug 715417 - Eliminate getPrincipalArray and globalPrivilegesEnabled from JSPrincipals. r=mrbkap
caps/src/nsJSPrincipals.cpp
dom/workers/Principal.cpp
js/src/jsapi-tests/testChromeBuffer.cpp
js/src/jsapi-tests/testOriginPrincipals.cpp
js/src/jsapi.h
js/src/jsdbgapi.cpp
js/src/jsdbgapi.h
js/src/shell/js.cpp
--- a/caps/src/nsJSPrincipals.cpp
+++ b/caps/src/nsJSPrincipals.cpp
@@ -45,28 +45,16 @@
 #include "nsCOMPtr.h"
 #include "jsapi.h"
 #include "jsxdrapi.h"
 #include "nsIJSRuntimeService.h"
 #include "nsIServiceManager.h"
 #include "nsMemory.h"
 #include "nsStringBuffer.h"
 
-static void *
-nsGetPrincipalArray(JSContext *cx, JSPrincipals *prin)
-{
-    return nsnull;
-}
-
-static JSBool
-nsGlobalPrivilegesEnabled(JSContext *cx, JSPrincipals *jsprin)
-{
-    return JS_TRUE;
-}
-
 static JSBool
 nsJSPrincipalsSubsume(JSPrincipals *jsprin, JSPrincipals *other)
 {
     nsJSPrincipals *nsjsprin = static_cast<nsJSPrincipals *>(jsprin);
     nsJSPrincipals *nsother  = static_cast<nsJSPrincipals *>(other);
 
     bool result;
     nsresult rv = nsjsprin->nsIPrincipalPtr->Subsumes(nsother->nsIPrincipalPtr,
@@ -187,18 +175,16 @@ nsJSPrincipals::Startup()
 
     callbacks->principalsTranscoder = nsTranscodeJSPrincipals;
     return NS_OK;
 }
 
 nsJSPrincipals::nsJSPrincipals()
 {
     codebase = nsnull;
-    getPrincipalArray = nsGetPrincipalArray;
-    globalPrivilegesEnabled = nsGlobalPrivilegesEnabled;
     refcount = 0;
     destroy = nsDestroyJSPrincipals;
     subsume = nsJSPrincipalsSubsume;
     nsIPrincipalPtr = nsnull;
 }
 
 nsresult
 nsJSPrincipals::Init(nsIPrincipal *aPrincipal, const nsCString& aCodebase)
--- a/dom/workers/Principal.cpp
+++ b/dom/workers/Principal.cpp
@@ -53,17 +53,17 @@ PrincipalSubsume(JSPrincipals*, JSPrinci
 {
   return JS_TRUE;
 }
 
 const char gPrincipalCodebase[] = "Web Worker";
 
 JSPrincipals gPrincipal = {
   const_cast<char*>(gPrincipalCodebase),
-  NULL, NULL, 1, PrincipalDestroy, PrincipalSubsume
+  1, PrincipalDestroy, PrincipalSubsume
 };
 
 } // anonymous namespace
 
 BEGIN_WORKERS_NAMESPACE
 
 JSPrincipals*
 GetWorkerPrincipal()
--- a/js/src/jsapi-tests/testChromeBuffer.cpp
+++ b/js/src/jsapi-tests/testChromeBuffer.cpp
@@ -1,15 +1,15 @@
 #include "tests.h"
 
 static void
 Destroy(JSContext *cx, JSPrincipals *prin);
 
 JSPrincipals system_principals = {
-    (char *)"", NULL, NULL, 1, Destroy, NULL
+    (char *)"", 1, Destroy, NULL
 };
 
 static void
 Destroy(JSContext *cx, JSPrincipals *prin)
 {
     JS_ASSERT(prin == &system_principals);
 }
 
--- a/js/src/jsapi-tests/testOriginPrincipals.cpp
+++ b/js/src/jsapi-tests/testOriginPrincipals.cpp
@@ -31,19 +31,19 @@ JSPrincipals *sOriginPrincipalsInErrorRe
 
 static void
 ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
 {
     sOriginPrincipalsInErrorReporter = report->originPrincipals;
 }
 
 char p1str[] = "principal1";
-JSPrincipals prin1 = { p1str, 0, 0, 0, Destroy, Subsume };
+JSPrincipals prin1 = { p1str, 0, Destroy, Subsume };
 char p2str[] = "principal2";
-JSPrincipals prin2 = { p2str, 0, 0, 0, Destroy, Subsume };
+JSPrincipals prin2 = { p2str, 0, Destroy, Subsume };
 
 BEGIN_TEST(testOriginPrincipals)
 {
     JS_SetContextSecurityCallbacks(cx, &seccb);
 
     /*
      * Currently, the only way to set a non-trivial originPrincipal is to use
      * JS_EvaluateUCScriptForPrincipalsVersionOrigin. This does not expose the
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3724,20 +3724,16 @@ JS_SetReservedSlot(JSContext *cx, JSObje
 /************************************************************************/
 
 /*
  * Security protocol.
  */
 struct JSPrincipals {
     char *codebase;
 
-    /* XXX unspecified and unused by Mozilla code -- can we remove these? */
-    void * (* getPrincipalArray)(JSContext *cx, JSPrincipals *);
-    JSBool (* globalPrivilegesEnabled)(JSContext *cx, JSPrincipals *);
-
     /* Don't call "destroy"; use reference counting macros below. */
     jsrefcount refcount;
 
     void   (* destroy)(JSContext *cx, JSPrincipals *);
     JSBool (* subsume)(JSPrincipals *, JSPrincipals *);
 };
 
 #ifdef JS_THREADSAFE
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -527,17 +527,17 @@ JS_GetScriptedCaller(JSContext *cx, JSSt
 
 JS_PUBLIC_API(void *)
 JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fpArg)
 {
     StackFrame *fp = Valueify(fpArg);
     if (fp->annotation() && fp->isScriptFrame()) {
         JSPrincipals *principals = fp->scopeChain().principals(cx);
 
-        if (principals && principals->globalPrivilegesEnabled(cx, principals)) {
+        if (principals) {
             /*
              * Give out an annotation only if privileges have not been revoked
              * or disabled globally.
              */
             return fp->annotation();
         }
     }
 
@@ -545,27 +545,16 @@ JS_GetFrameAnnotation(JSContext *cx, JSS
 }
 
 JS_PUBLIC_API(void)
 JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation)
 {
     Valueify(fp)->setAnnotation(annotation);
 }
 
-JS_PUBLIC_API(void *)
-JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp)
-{
-    JSPrincipals *principals;
-
-    principals = Valueify(fp)->scopeChain().principals(cx);
-    if (!principals)
-        return NULL;
-    return principals->getPrincipalArray(cx, principals);
-}
-
 JS_PUBLIC_API(JSBool)
 JS_IsScriptFrame(JSContext *cx, JSStackFrame *fp)
 {
     return !Valueify(fp)->isDummyFrame();
 }
 
 JS_PUBLIC_API(JSObject *)
 JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fpArg)
--- a/js/src/jsdbgapi.h
+++ b/js/src/jsdbgapi.h
@@ -253,19 +253,16 @@ extern JS_PUBLIC_API(JSStackFrame *)
 JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp);
 
 extern JS_PUBLIC_API(void *)
 JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp);
 
 extern JS_PUBLIC_API(void)
 JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation);
 
-extern JS_PUBLIC_API(void *)
-JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp);
-
 extern JS_PUBLIC_API(JSBool)
 JS_IsScriptFrame(JSContext *cx, JSStackFrame *fp);
 
 extern JS_PUBLIC_API(JSObject *)
 JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp);
 
 extern JS_PUBLIC_API(JSObject *)
 JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -5240,18 +5240,16 @@ MaybeOverrideOutFileFromEnv(const char* 
 JSBool
 ShellPrincipalsSubsume(JSPrincipals *, JSPrincipals *)
 {
     return JS_TRUE;
 }
 
 JSPrincipals shellTrustedPrincipals = {
     (char *)"[shell trusted principals]",
-    NULL,
-    NULL,
     1,
     NULL, /* nobody should be destroying this */
     ShellPrincipalsSubsume
 };
 
 JSBool
 CheckObjectAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
                   jsval *vp)