Bug 832014 part 9. Switch AccessCheck to using the generated LocationBinding::IsPermitted method. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 11 Jul 2014 19:34:44 -0400
changeset 215631 7ebd702e6442e43cefec06d319db29fe3cf1a101
parent 215630 fb30689a1d8c665db1df49529b44656351efa7fc
child 215632 9f869623bd08d47db2f246c52ab05964642fadc6
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs832014
milestone33.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 832014 part 9. Switch AccessCheck to using the generated LocationBinding::IsPermitted method. r=bholley
js/xpconnect/wrappers/AccessCheck.cpp
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -9,16 +9,17 @@
 #include "nsJSPrincipals.h"
 #include "nsGlobalWindow.h"
 
 #include "XPCWrapper.h"
 #include "XrayWrapper.h"
 
 #include "jsfriendapi.h"
 #include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/LocationBinding.h"
 #include "mozilla/dom/WindowBinding.h"
 #include "nsIDOMWindowCollection.h"
 #include "nsJSUtils.h"
 
 using namespace mozilla;
 using namespace JS;
 using namespace js;
 
@@ -85,51 +86,39 @@ AccessCheck::isChrome(JSObject *obj)
 }
 
 nsIPrincipal *
 AccessCheck::getPrincipal(JSCompartment *compartment)
 {
     return GetCompartmentPrincipal(compartment);
 }
 
-#define NAME(ch, str, cases)                                                  \
-    case ch: if (!strcmp(name, str)) switch (propChar0) { cases }; break;
-#define PROP(ch, actions) case ch: { actions }; break;
-#define RW(str) if (JS_FlatStringEqualsAscii(prop, str)) return true;
-#define R(str) if (!set && JS_FlatStringEqualsAscii(prop, str)) return true;
-#define W(str) if (set && JS_FlatStringEqualsAscii(prop, str)) return true;
-
 // Hardcoded policy for cross origin property access. This was culled from the
 // preferences file (all.js). We don't want users to overwrite highly sensitive
 // security policies.
 static bool
 IsPermitted(const char *name, JSFlatString *prop, bool set)
 {
     size_t propLength = JS_GetStringLength(JS_FORGET_STRING_FLATNESS(prop));
     if (!propLength)
         return false;
 
     jschar propChar0 = JS_GetFlatStringCharAt(prop, 0);
     switch (name[0]) {
-        NAME('L', "Location",
-             PROP('h', W("href"))
-             PROP('r', R("replace")))
+        case 'L':
+            if (!strcmp(name, "Location"))
+                return dom::LocationBinding::IsPermitted(prop, propChar0, set);
         case 'W':
             if (!strcmp(name, "Window"))
                 return dom::WindowBinding::IsPermitted(prop, propChar0, set);
             break;
     }
     return false;
 }
 
-#undef NAME
-#undef RW
-#undef R
-#undef W
-
 static bool
 IsFrameId(JSContext *cx, JSObject *objArg, jsid idArg)
 {
     RootedObject obj(cx, objArg);
     RootedId id(cx, idArg);
 
     obj = JS_ObjectToInnerObject(cx, obj);
     MOZ_ASSERT(!js::IsWrapper(obj));