Bug 869195. Make QueryInterface be exposed for both chrome and xbl scopes, not just in chrome. r=bholley,peterv

This commit is contained in:
Boris Zbarsky 2013-05-14 14:24:48 -04:00
parent 22ceafa442
commit 3ab853407d
2 changed files with 31 additions and 7 deletions

View File

@ -43,6 +43,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=821850
is(bound.primitiveField, undefined, "Xrays don't show fields"); is(bound.primitiveField, undefined, "Xrays don't show fields");
is(bound.wrappedJSObject.primitiveField, 2, "Waiving Xrays show fields"); is(bound.wrappedJSObject.primitiveField, 2, "Waiving Xrays show fields");
// Check that here document.QueryInterface works
ok("QueryInterface" in document,
"Should have a document.QueryInterface here");
is(document.QueryInterface(Components.interfaces.nsIDOMDocument),
document, "Should be able to QI the document");
// This gets invoked by an event handler. // This gets invoked by an event handler.
window.finish = function() { window.finish = function() {
// Content messed with stuff. Make sure we still see the right thing. // Content messed with stuff. Make sure we still see the right thing.
@ -103,6 +109,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=821850
window.contentVal = { foo: 10, rabbit: { hole: { bar: 100, win: window} } }; window.contentVal = { foo: 10, rabbit: { hole: { bar: 100, win: window} } };
ok(true, "Set contentVal"); ok(true, "Set contentVal");
// Check that we're not exposing QueryInterface to non-XBL code
ok(!("QueryInterface" in document),
"Should not have a document.QueryInterface here");
function go() { function go() {
"use strict"; "use strict";

View File

@ -1460,14 +1460,28 @@ class MethodDefiner(PropertyDefiner):
"flags": "JSPROP_ENUMERATE", "flags": "JSPROP_ENUMERATE",
"condition": MemberCondition(None, None) }) "condition": MemberCondition(None, None) })
if (not descriptor.interface.parent and not static and # Make sure to not stick QueryInterface on abstract interfaces that
# have hasXPConnectImpls (like EventTarget). So only put it on
# interfaces that are concrete and all of whose ancestors are abstract.
def allAncestorsAbstract(iface):
if not iface.parent:
return True
desc = descriptor.getDescriptor(iface.parent.identifier.name)
if desc.concrete:
return False
return allAncestorsAbstract(iface.parent)
if (not static and
descriptor.nativeOwnership == 'nsisupports' and descriptor.nativeOwnership == 'nsisupports' and
descriptor.interface.hasInterfacePrototypeObject()): descriptor.interface.hasInterfacePrototypeObject() and
self.chrome.append({"name": 'QueryInterface', descriptor.concrete and
"methodInfo": False, allAncestorsAbstract(descriptor.interface)):
"length": 1, self.regular.append({"name": 'QueryInterface',
"flags": "0", "methodInfo": False,
"condition": MemberCondition(None, None) }) "length": 1,
"flags": "0",
"condition":
MemberCondition(None,
"nsINode::IsChromeOrXBL") })
if not static: if not static:
stringifier = descriptor.operations['Stringifier'] stringifier = descriptor.operations['Stringifier']