Bug 810520. Correctly handle static methods and attributes in the NativeProperties structs that Xrays use. r=peterv

Note that at this point we actaully do Xrays for all of our various
property types, except in worker code.  The real substantive change
here is the change to what usedForXrays returns.  The rest is minor
cleanup.
This commit is contained in:
Boris Zbarsky 2012-11-13 00:26:55 -08:00
parent 06079492cb
commit 93edcc7097
2 changed files with 25 additions and 16 deletions

View File

@ -1027,11 +1027,8 @@ class PropertyDefiner:
return "s" + self.name
return "nullptr"
def usedForXrays(self):
# We only need Xrays for methods, attributes and constants, but in
# workers there are no Xrays.
return (self.name is "Methods" or self.name is "Attributes" or
self.name is "UnforgeableAttributes" or
self.name is "Constants") and not self.descriptor.workers
# No Xrays in workers.
return not self.descriptor.workers
def __str__(self):
# We only need to generate id arrays for things that will end
@ -1364,14 +1361,11 @@ class CGNativeProperties(CGList):
for array in properties.arrayNames():
propertyArray = getattr(properties, array)
if check(propertyArray):
if descriptor.workers:
props = "%(name)s, nullptr, %(name)s_specs"
if propertyArray.usedForXrays():
ids = "%(name)s_ids"
else:
if propertyArray.usedForXrays():
ids = "%(name)s_ids"
else:
ids = "nullptr"
props = "%(name)s, " + ids + ", %(name)s_specs"
ids = "nullptr"
props = "%(name)s, " + ids + ", %(name)s_specs"
props = (props %
{ 'name': propertyArray.variableName(chrome) })
else:
@ -1380,10 +1374,15 @@ class CGNativeProperties(CGList):
return CGWrapper(CGIndenter(CGList(nativeProps, ",\n")),
pre="static const NativeProperties %s = {\n" % name,
post="\n};")
regular = generateNativeProperties("sNativeProperties", False)
chrome = generateNativeProperties("sChromeOnlyNativeProperties", True)
CGList.__init__(self, [regular, chrome], "\n\n")
nativeProperties = []
if properties.hasNonChromeOnly():
nativeProperties.append(
generateNativeProperties("sNativeProperties", False))
if properties.hasChromeOnly():
nativeProperties.append(
generateNativeProperties("sChromeOnlyNativeProperties", True))
CGList.__init__(self, nativeProperties, "\n\n")
def declare(self):
return ""

View File

@ -181,6 +181,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
ok(false, "NodeList.prototype manipulation via an Xray shouldn't throw" + e);
}
try {
var url = Components.utils.evalInSandbox("URL", sandbox);
for (var i in url) {
url[i];
}
ok(true, "We didn't crash!");
} catch (e) {
ok(false, "URL interface object manipulation via an Xray shouldn't throw" + e);
}
SimpleTest.finish();
}