From 7bf5a529d9d56ec74224ce1fe5932892468e7163 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 11 Jul 2014 19:34:44 -0400 Subject: [PATCH] Bug 832014 part 9. Switch AccessCheck to using the generated LocationBinding::IsPermitted method. r=bholley --- js/xpconnect/wrappers/AccessCheck.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/js/xpconnect/wrappers/AccessCheck.cpp b/js/xpconnect/wrappers/AccessCheck.cpp index e9b7811cb04..75ab3935665 100644 --- a/js/xpconnect/wrappers/AccessCheck.cpp +++ b/js/xpconnect/wrappers/AccessCheck.cpp @@ -14,6 +14,7 @@ #include "jsfriendapi.h" #include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/LocationBinding.h" #include "mozilla/dom/WindowBinding.h" #include "nsIDOMWindowCollection.h" #include "nsJSUtils.h" @@ -90,13 +91,6 @@ 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. @@ -109,9 +103,9 @@ IsPermitted(const char *name, JSFlatString *prop, bool set) 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); @@ -120,11 +114,6 @@ IsPermitted(const char *name, JSFlatString *prop, bool set) return false; } -#undef NAME -#undef RW -#undef R -#undef W - static bool IsFrameId(JSContext *cx, JSObject *objArg, jsid idArg) {