Backed out 5 changesets (bug 905493, bug 920125, bug 919603) for mochitest orange on a CLOSED TREE.

Backed out changeset ccef656b2973 (bug 919603)
Backed out changeset 4b29ce0b2fff (bug 919603)
Backed out changeset b0a051ec55b7 (bug 919603)
Backed out changeset baa9a774aad1 (bug 920125)
Backed out changeset e03276bf4eaa (bug 905493)
This commit is contained in:
Ryan VanderMeulen 2013-09-25 18:22:33 -04:00
parent 0eb7473289
commit b2c316d8b2
10 changed files with 49 additions and 334 deletions

View File

@ -872,22 +872,6 @@ GetNativePropertyHooks(JSContext *cx, JS::Handle<JSObject*> obj,
return ifaceAndProtoJSClass->mNativeHooks;
}
// Try to resolve a property as an unforgeable property from the given
// NativeProperties, if it's there. nativeProperties is allowed to be null (in
// which case we of course won't resolve anything).
static bool
XrayResolveUnforgeableProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
JS::MutableHandle<JSPropertyDescriptor> desc,
const NativeProperties* nativeProperties);
static bool
XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
const NativePropertyHooks* nativePropertyHooks,
DOMObjectType type, JS::Handle<JSObject*> obj,
JS::Handle<jsid> id,
JS::MutableHandle<JSPropertyDescriptor> desc);
bool
XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
@ -897,32 +881,7 @@ XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
const NativePropertyHooks *nativePropertyHooks =
GetNativePropertyHooks(cx, obj, type);
if (type != eInstance) {
// For prototype objects and interface objects, just return their
// normal set of properties.
return XrayResolveNativeProperty(cx, wrapper, nativePropertyHooks, type,
obj, id, desc);
}
// Check for unforgeable properties before doing mResolveOwnProperty weirdness
const NativePropertiesHolder& nativeProperties =
nativePropertyHooks->mNativeProperties;
if (!XrayResolveUnforgeableProperty(cx, wrapper, obj, id, desc,
nativeProperties.regular)) {
return false;
}
if (desc.object()) {
return true;
}
if (!XrayResolveUnforgeableProperty(cx, wrapper, obj, id, desc,
nativeProperties.chromeOnly)) {
return false;
}
if (desc.object()) {
return true;
}
return !nativePropertyHooks->mResolveOwnProperty ||
return type != eInstance || !nativePropertyHooks->mResolveOwnProperty ||
nativePropertyHooks->mResolveOwnProperty(cx, wrapper, obj, id, desc, flags);
}
@ -977,20 +936,6 @@ XrayResolveAttribute(JSContext* cx, JS::Handle<JSObject*> wrapper,
return true;
}
/* static */ bool
XrayResolveUnforgeableProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
JS::MutableHandle<JSPropertyDescriptor> desc,
const NativeProperties* nativeProperties)
{
return !nativeProperties || !nativeProperties->unforgeableAttributes ||
XrayResolveAttribute(cx, wrapper, obj, id,
nativeProperties->unforgeableAttributes,
nativeProperties->unforgeableAttributeIds,
nativeProperties->unforgeableAttributeSpecs,
desc);
}
static bool
XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
@ -1063,6 +1008,18 @@ XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
return true;
}
}
if (nativeProperties->unforgeableAttributes) {
if (!XrayResolveAttribute(cx, wrapper, obj, id,
nativeProperties->unforgeableAttributes,
nativeProperties->unforgeableAttributeIds,
nativeProperties->unforgeableAttributeSpecs,
desc)) {
return false;
}
if (desc.object()) {
return true;
}
}
}
if (nativeProperties->constants) {
@ -1111,7 +1068,7 @@ ResolvePrototypeOrConstructor(JSContext* cx, JS::Handle<JSObject*> wrapper,
return JS_WrapPropertyDescriptor(cx, desc);
}
/* static */ bool
bool
XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
const NativePropertyHooks* nativePropertyHooks,
DOMObjectType type, JS::Handle<JSObject*> obj,
@ -1947,10 +1904,9 @@ InterfaceHasInstance(JSContext* cx, int prototypeID, int depth,
}
bool
ReportLenientThisUnwrappingFailure(JSContext* cx, JSObject* obj)
ReportLenientThisUnwrappingFailure(JSContext* cx, JS::Handle<JSObject*> obj)
{
JS::Rooted<JSObject*> rootedObj(cx, obj);
GlobalObject global(cx, rootedObj);
GlobalObject global(cx, obj);
if (global.Failed()) {
return false;
}

View File

@ -2062,7 +2062,7 @@ InterfaceHasInstance(JSContext* cx, int prototypeID, int depth,
// Helper for lenient getters/setters to report to console. If this
// returns false, we couldn't even get a global.
bool
ReportLenientThisUnwrappingFailure(JSContext* cx, JSObject* obj);
ReportLenientThisUnwrappingFailure(JSContext* cx, JS::Handle<JSObject*> obj);
inline JSObject*
GetUnforgeableHolder(JSObject* aGlobal, prototypes::ID aId)

View File

@ -5321,18 +5321,9 @@ class CGAbstractBindingMethod(CGAbstractStaticMethod):
|this| object. Subclasses are expected to override the generate_code
function to do the rest of the work. This function should return a
CGThing which is already properly indented.
getThisObj should be code for getting a JSObject* for the binding
object. If this is None, we will auto-generate code based on
descriptor to do the right thing. "" can be passed in if the
binding object is already stored in 'obj'.
callArgs should be code for getting a JS::CallArgs into a variable
called 'args'. This can be "" if there is already such a variable
around.
"""
def __init__(self, descriptor, name, args, unwrapFailureCode=None,
getThisObj=None,
getThisObj="args.computeThis(cx).toObjectOrNull()",
callArgs="JS::CallArgs args = JS::CallArgsFromVp(argc, vp);"):
CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args)
@ -5340,26 +5331,7 @@ class CGAbstractBindingMethod(CGAbstractStaticMethod):
self.unwrapFailureCode = 'return ThrowErrorMessage(cx, MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE, "Value", "%s");' % descriptor.interface.identifier.name
else:
self.unwrapFailureCode = unwrapFailureCode
if getThisObj == "":
self.getThisObj = None
else:
if getThisObj is None:
if descriptor.interface.isOnGlobalProtoChain():
ensureCondition = "!args.thisv().isNullOrUndefined() && !args.thisv().isObject()"
getThisObj = "args.thisv().isObject() ? &args.thisv().toObject() : js::GetGlobalForObjectCrossCompartment(&args.callee())"
else:
ensureCondition = "!args.thisv().isObject()"
getThisObj = "&args.thisv().toObject()"
ensureThisObj = CGIfWrapper(CGGeneric(self.unwrapFailureCode),
ensureCondition)
else:
ensureThisObj = None
self.getThisObj = CGList(
[ensureThisObj,
CGGeneric("JS::RootedObject obj(cx, %s);\n" %
getThisObj)],
"\n")
self.getThisObj = getThisObj
self.callArgs = callArgs
def definition_body(self):
@ -5369,7 +5341,10 @@ class CGAbstractBindingMethod(CGAbstractStaticMethod):
# consumption by CastableObjectUnwrapper.
getThis = CGList([
CGGeneric(self.callArgs) if self.callArgs != "" else None,
self.getThisObj,
CGGeneric("JS::RootedObject obj(cx, %s);\n"
"if (!obj) {\n"
" return false;\n"
"}" % self.getThisObj) if self.getThisObj else None,
CGGeneric("%s* self;" % self.descriptor.nativeType)
], "\n")
unwrapThis = CGGeneric(
@ -5610,7 +5585,7 @@ class CGGenericGetter(CGAbstractBindingMethod):
name = "genericLenientGetter"
unwrapFailureCode = (
"MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"
"if (!ReportLenientThisUnwrappingFailure(cx, &args.callee())) {\n"
"if (!ReportLenientThisUnwrappingFailure(cx, obj)) {\n"
" return false;\n"
"}\n"
"args.rval().set(JS::UndefinedValue());\n"
@ -5690,7 +5665,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
name = "genericLenientSetter"
unwrapFailureCode = (
"MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"
"if (!ReportLenientThisUnwrappingFailure(cx, &args.callee())) {\n"
"if (!ReportLenientThisUnwrappingFailure(cx, obj)) {\n"
" return false;\n"
"}\n"
"args.rval().set(JS::UndefinedValue());\n"
@ -7305,6 +7280,22 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
"}\n") % (self.descriptor.nativeType)
if UseHolderForUnforgeable(self.descriptor):
getUnforgeable = """if (!JS_GetPropertyDescriptorById(cx, ${holder}, id, flags, desc)) {
return false;
}
MOZ_ASSERT_IF(desc.object(), desc.object() == ${holder});"""
getUnforgeable = CallOnUnforgeableHolder(self.descriptor,
getUnforgeable, "isXray")
getUnforgeable += """if (desc.object()) {
desc.object().set(proxy);
return !isXray || JS_WrapPropertyDescriptor(cx, desc);
}
"""
else:
getUnforgeable = ""
if indexedSetter or self.descriptor.operations['NamedSetter']:
setOrIndexedGet += "if (flags & JSRESOLVE_ASSIGNING) {\n"
if indexedSetter:
@ -7318,6 +7309,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
setOrIndexedGet += (" FillPropertyDescriptor(desc, proxy, JSVAL_VOID, false);\n" +
" return true;\n" +
" }\n")
setOrIndexedGet += CGIndenter(CGGeneric(getUnforgeable)).define()
if self.descriptor.operations['NamedSetter']:
if not 'NamedCreator' in self.descriptor.operations:
# FIXME need to check that this is a 'supported property name'
@ -7332,7 +7324,11 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
setOrIndexedGet += "}"
if indexedGetter:
setOrIndexedGet += (" else {\n" +
CGIndenter(CGGeneric(get)).define() +
CGIndenter(CGGeneric(get + "\n" + getUnforgeable)).define() +
"}")
else:
setOrIndexedGet += (" else {\n" +
CGIndenter(CGGeneric(getUnforgeable)).define() +
"}")
setOrIndexedGet += "\n\n"
else:
@ -7340,6 +7336,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
setOrIndexedGet += ("if (!(flags & JSRESOLVE_ASSIGNING)) {\n" +
CGIndenter(CGGeneric(get)).define() +
"}\n\n")
setOrIndexedGet += getUnforgeable
if self.descriptor.supportsNamedProperties():
readonly = toStringBool(self.descriptor.operations['NamedSetter'] is None)

View File

@ -523,7 +523,6 @@ class IDLInterface(IDLObjectWithScope):
# have self as a consequential interface
self.interfacesImplementingSelf = set()
self._hasChildInterfaces = False
self._isOnGlobalProtoChain = False
IDLObjectWithScope.__init__(self, location, parentScope, name)
@ -587,15 +586,6 @@ class IDLInterface(IDLObjectWithScope):
self.parent._hasChildInterfaces = True
# Interfaces with [Global] must not have anything inherit from them
if self.parent.getExtendedAttribute("Global"):
# Note: This is not a self.parent.isOnGlobalProtoChain() check
# because ancestors of a [Global] interface can have other
# descendants.
raise WebIDLError("[Global] interface has another interface "
"inheriting from it",
[self.location, self.parent.location])
# Callbacks must not inherit from non-callbacks or inherit from
# anything that has consequential interfaces.
# XXXbz Can non-callbacks inherit from callbacks? Spec issue pending.
@ -751,31 +741,6 @@ class IDLInterface(IDLObjectWithScope):
specialMembersSeen[memberType] = member
if self._isOnGlobalProtoChain:
# Make sure we have no named setters, creators, or deleters
for memberType in ["setter", "creator", "deleter"]:
memberId = "named " + memberType + "s"
if memberId in specialMembersSeen:
raise WebIDLError("Interface with [Global] has a named %s" %
memberType,
[self.location,
specialMembersSeen[memberId].location])
# Make sure we're not [OverrideBuiltins]
if self.getExtendedAttribute("OverrideBuiltins"):
raise WebIDLError("Interface with [Global] also has "
"[OverrideBuiltins]",
[self.location])
# Mark all of our ancestors as being on the global's proto chain too
parent = self.parent
while parent:
# Must not inherit from an interface with [OverrideBuiltins]
if parent.getExtendedAttribute("OverrideBuiltins"):
raise WebIDLError("Interface with [Global] inherits from "
"interface with [OverrideBuiltins]",
[self.location, parent.location])
parent._isOnGlobalProtoChain = True
parent = parent.parent
def validate(self):
for member in self.members:
member.validate()
@ -959,11 +924,6 @@ class IDLInterface(IDLObjectWithScope):
raise WebIDLError("[ArrayClass] must not be specified on "
"an interface with inherited interfaces",
[attr.location, self.location])
elif identifier == "Global":
if not attr.noArguments():
raise WebIDLError("[Global] must take no arguments",
[attr.location])
self._isOnGlobalProtoChain = True
elif (identifier == "PrefControlled" or
identifier == "NeedNewResolve" or
identifier == "OverrideBuiltins" or
@ -1082,9 +1042,6 @@ class IDLInterface(IDLObjectWithScope):
def hasChildInterfaces(self):
return self._hasChildInterfaces
def isOnGlobalProtoChain(self):
return self._isOnGlobalProtoChain
def _getDependentObjects(self):
deps = set(self.members)
deps.union(self.implementedInterfaces)

View File

@ -1,122 +0,0 @@
def WebIDLTest(parser, harness):
parser.parse("""
[Global]
interface Foo : Bar {
getter any(DOMString name);
};
interface Bar {};
""")
results = parser.finish()
harness.ok(results[0].isOnGlobalProtoChain(),
"[Global] interface should be on global's proto chain")
harness.ok(results[1].isOnGlobalProtoChain(),
"[Global] interface should be on global's proto chain")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global]
interface Foo {
getter any(DOMString name);
setter void(DOMString name, any arg);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [Global] used on an interface with a "
"named setter")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global]
interface Foo {
getter any(DOMString name);
creator void(DOMString name, any arg);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [Global] used on an interface with a "
"named creator")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global]
interface Foo {
getter any(DOMString name);
deleter void(DOMString name);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [Global] used on an interface with a "
"named deleter")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global, OverrideBuiltins]
interface Foo {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [Global] used on an interface with a "
"[OverrideBuiltins]")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global]
interface Foo : Bar {
};
[OverrideBuiltins]
interface Bar {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [Global] used on an interface with an "
"[OverrideBuiltins] ancestor")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global]
interface Foo {
};
interface Bar : Foo {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should have thrown for [Global] used on an interface with a "
"descendant")

View File

@ -68,13 +68,11 @@ MOCHITEST_FILES := \
test_exception_messages.html \
test_bug707564.html \
test_defineProperty.html \
file_document_location_set_via_xray.html \
$(NULL)
MOCHITEST_CHROME_FILES = \
test_bug775543.html \
test_bug707564-chrome.html \
test_document_location_set_via_xray.html \
$(NULL)
ifdef GNU_CC

View File

@ -1,5 +0,0 @@
<body>
<script>
document.x = 5;
</script>
</body>

View File

@ -1,49 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=905493
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 905493</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=905493">Mozilla Bug 905493</a>
<p id="display"></p>
<div id="content" style="display: none">
<iframe id="t" src="http://example.org/tests/dom/bindings/test/file_document_location_set_via_xray.html"></iframe>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 905493 **/
function test()
{
var doc = document.getElementById("t").contentWindow.document;
ok(!("x" in doc), "Should have an Xray here");
is(doc.x, undefined, "Really should have an Xray here");
is(doc.wrappedJSObject.x, 5, "And wrapping the right thing");
document.getElementById("t").onload = function() {
ok(true, "Load happened");
SimpleTest.finish();
};
try {
// Test the forwarding location setter
doc.location = "chrome://mochikit/content/tests/SimpleTest/test.css";
} catch (e) {
// Load failed
ok(false, "Load failed");
SimpleTest.finish();
}
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(test);
</script>
</pre>
</body>
</html>

View File

@ -49,14 +49,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
ok(xhr, "'XMLHttpRequest.prototype' in a sandbox should return the XMLHttpRequest interface prototype object");
ok(isXrayWrapper(xhr), "Getting an interface prototype object on an Xray wrapper should return an Xray wrapper");
ok(isXrayWrapper(xhr.constructor), "Getting the constructor property on an Xray wrapper of an interface prototype object should return an Xray wrapper");
isnot(Object.getOwnPropertyDescriptor(xhr, "send"), undefined,
"We should claim to have a send() method");
isnot(Object.keys(xhr).indexOf("responseType"), -1,
"We should claim to have a responseType property");
isnot(Object.getOwnPropertyNames(xhr).indexOf("open"), -1,
"We should claim to have an open() method");
isnot(Object.getOwnPropertyDescriptor(xhr, "constructor"), undefined,
"We should claim to have a 'constructor' property");
} catch (e) {
ok(false, "'XMLHttpRequest.prototype' shouldn't throw in a sandbox");
}
@ -95,14 +87,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
var xhr = Components.utils.evalInSandbox("XMLHttpRequest", sandbox);
is(xhr, "[object XrayWrapper " + XMLHttpRequest + "]", "'XMLHttpRequest' in a sandbox should return the XMLHttpRequest interface object");
ok(isXrayWrapper(xhr.prototype), "Getting the prototype property on an Xray wrapper of an interface object should return an Xray wrapper");
isnot(Object.getOwnPropertyDescriptor(xhr, "UNSENT"), undefined,
"We should claim to have an UNSENT constant");
isnot(Object.keys(xhr).indexOf("OPENED"), -1,
"We should claim to have an OPENED constant");
isnot(Object.getOwnPropertyNames(xhr).indexOf("DONE"), -1,
"We should claim to have a DONE constant");
isnot(Object.getOwnPropertyDescriptor(xhr, "prototype"), undefined,
"We should claim to have 'prototype' property");
} catch (e) {
ok(false, "'XMLHttpRequest' shouldn't throw in a sandbox");
}

View File

@ -7,8 +7,7 @@
// Dummy bindings that we need to force generation of things that
// aren't actually referenced anywhere in IDL yet but are used in C++.
[Global]
interface DummyInterface : EventTarget {
interface DummyInterface {
readonly attribute OnErrorEventHandlerNonNull onErrorEventHandler;
FilePropertyBag fileBag();
InspectorRGBTriple rgbTriple();