Fix for bug 774775 (XRayWrapper does not handle new bindings constants). r=bz.

--HG--
extra : rebase_source : fef985d0417c394ae5997b4450c7076005bdf870
This commit is contained in:
Peter Van der Beken 2012-07-17 22:54:25 +02:00
Родитель 053a7abaca
Коммит a64f14f7ef
2 изменённых файлов: 54 добавлений и 6 удалений

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

@ -769,11 +769,12 @@ class PropertyDefiner:
return "s" + self.name
return "NULL"
def usedForXrays(self, chrome):
# We only need Xrays for methods and attributes. And we only need them
# for the non-chrome ones if we have no chromeonly things. Otherwise
# (we have chromeonly attributes) we need Xrays for the chrome
# methods/attributes. Finally, in workers there are no Xrays.
return ((self.name is "Methods" or self.name is "Attributes") and
# We only need Xrays for methods, attributes and constants. And we only
# need them for the non-chrome ones if we have no chromeonly things.
# Otherwise (we have chromeonly attributes) we need Xrays for the chrome
# methods/attributes/constants. Finally, in workers there are no Xrays.
return ((self.name is "Methods" or self.name is "Attributes" or
self.name is "Constants") and
chrome == self.hasChromeOnly() and
not self.descriptor.workers)
@ -1012,7 +1013,7 @@ class PropertyArrays():
@staticmethod
def xrayRelevantArrayNames():
return [ "methods", "attrs" ]
return [ "methods", "attrs", "consts" ]
def hasChromeOnly(self):
return reduce(lambda b, a: b or getattr(self, a).hasChromeOnly(),
@ -3854,6 +3855,28 @@ class CGResolveProperty(CGAbstractMethod):
}
}
""" % varNames
consts = self.properties.consts
if consts.hasNonChromeOnly() or consts.hasChromeOnly():
str += """ // %(consts)s has an end-of-list marker at the end that we ignore
for (size_t prefIdx = 0; prefIdx < ArrayLength(%(consts)s)-1; ++prefIdx) {
MOZ_ASSERT(%(consts)s[prefIdx].specs);
if (%(consts)s[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = %(consts)s[prefIdx].specs - %(consts)s_specs;;
for ( ; %(consts)s_ids[i] != JSID_VOID; ++i) {
if (id == %(consts)s_ids[i]) {
desc->attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
desc->obj = wrapper;
desc->value = %(consts)s_specs[i].value;
return true;
}
}
}
}
""" % varNames
return str + " return true;"
@ -3906,6 +3929,25 @@ class CGEnumerateProperties(CGAbstractMethod):
}
}
""" % varNames
consts = self.properties.consts
if consts.hasNonChromeOnly() or consts.hasChromeOnly():
str += """ // %(consts)s has an end-of-list marker at the end that we ignore
for (size_t prefIdx = 0; prefIdx < ArrayLength(%(consts)s)-1; ++prefIdx) {
MOZ_ASSERT(%(consts)s[prefIdx].specs);
if (%(consts)s[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = %(consts)s[prefIdx].specs - %(consts)s_specs;;
for ( ; %(consts)s_ids[i] != JSID_VOID; ++i) {
if (!props.append(%(consts)s_ids[i])) {
return false;
}
}
}
}
""" % varNames
return str + " return true;"

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

@ -42,6 +42,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
} catch (e) {
ok(false, "'XMLHttpRequest()' shouldn't throw in a sandbox");
}
try {
var canvas = Components.utils.evalInSandbox("document.createElement('canvas').getContext('2d')", sandbox);
is(canvas.DRAWWINDOW_DRAW_CARET, CanvasRenderingContext2D.DRAWWINDOW_DRAW_CARET, "Constants should be defined on DOM objects in a sandbox");
} catch (e) {
ok(false, "'document.createElement('canvas').getContext('2D')' shouldn't throw in a sandbox");
}
SimpleTest.finish();
}