Bug 1036185 - Clean up logic in IsPermitted (bonus fix). r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Tue, 15 Jul 2014 09:04:19 -0700
changeset 216095 ce50f24edb55544b4e99f3cacd73d11d1c19fb3f
parent 216094 d3f1b7411f3a1e1c47e54ce16c8aed3383171422
child 216096 d6289d614a705c2f4dfd77806d3b5cd18be790ba
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)
reviewersgabor
bugs1036185
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 1036185 - Clean up logic in IsPermitted (bonus fix). r=gabor
js/xpconnect/wrappers/AccessCheck.cpp
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -86,36 +86,30 @@ AccessCheck::isChrome(JSObject *obj)
 }
 
 nsIPrincipal *
 AccessCheck::getPrincipal(JSCompartment *compartment)
 {
     return GetCompartmentPrincipal(compartment);
 }
 
-// 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.
+// Hardcoded policy for cross origin property access. See the HTML5 Spec.
 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]) {
-        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;
-    }
+    if (name[0] == 'L' && !strcmp(name, "Location"))
+        return dom::LocationBinding::IsPermitted(prop, propChar0, set);
+    if (name[0] == 'W' && !strcmp(name, "Window"))
+        return dom::WindowBinding::IsPermitted(prop, propChar0, set);
+
     return false;
 }
 
 static bool
 IsFrameId(JSContext *cx, JSObject *objArg, jsid idArg)
 {
     RootedObject obj(cx, objArg);
     RootedId id(cx, idArg);