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
Родитель 2fe22ee821
Коммит 2f3202994d
2 изменённых файлов: 25 добавлений и 16 удалений

Просмотреть файл

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

Просмотреть файл

@ -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); 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(); SimpleTest.finish();
} }