mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
Bug 637248, Make Event.isTrusted Unforgeable, r=bz
--HG-- extra : rebase_source : 3edd919c6dac839d6082c1c73de88f9ba2d22146
This commit is contained in:
parent
d3c054db17
commit
3b5f032268
@ -62,6 +62,20 @@ ex = false;
|
||||
e = new Event("hello");
|
||||
ok(e.type, "hello", "Wrong event type!");
|
||||
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||
e.isTrusted = true;
|
||||
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||
|
||||
try {
|
||||
e.__defineGetter__("isTrusted", function() { return true });
|
||||
} catch (exp) {
|
||||
ex = true;
|
||||
}
|
||||
ok(ex, "Shouldn't be able to re-define the getter for isTrusted.");
|
||||
ex = false;
|
||||
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||
|
||||
ok(!("isTrusted" in Object.getPrototypeOf(e)))
|
||||
|
||||
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||
is(e.eventPhase, Event.NONE, "Wrong event phase");
|
||||
@ -175,6 +189,15 @@ ex = false;
|
||||
e = new BlobEvent("hello");
|
||||
ok(e.type, "hello", "Wrong event type!");
|
||||
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||
try {
|
||||
e.__defineGetter__("isTrusted", function() { return true });
|
||||
} catch (exp) {
|
||||
ex = true;
|
||||
}
|
||||
ok(ex, "Shouldn't be able to re-define the getter for isTrusted.");
|
||||
ex = false;
|
||||
ok(!e.isTrusted, "BlobEvent shouldn't be trusted!");
|
||||
|
||||
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||
document.dispatchEvent(e);
|
||||
|
@ -10786,7 +10786,16 @@ class CGEventGetter(CGNativeMember):
|
||||
return ret;
|
||||
raise TypeError("Event code generator does not support this type!")
|
||||
|
||||
def declare(self, cgClass):
|
||||
if getattr(self.member, "originatingInterface",
|
||||
cgClass.descriptor.interface) != cgClass.descriptor.interface:
|
||||
return ""
|
||||
return CGNativeMember.declare(self, cgClass)
|
||||
|
||||
def define(self, cgClass):
|
||||
if getattr(self.member, "originatingInterface",
|
||||
cgClass.descriptor.interface) != cgClass.descriptor.interface:
|
||||
return ""
|
||||
ret = self.retval(self.member.type);
|
||||
methodName = self.descriptorProvider.name + '::' + self.name
|
||||
args = (', '.join([a.declare() for a in self.args]))
|
||||
@ -10845,6 +10854,11 @@ class CGEventMethod(CGNativeMember):
|
||||
while iface.identifier.name != "Event":
|
||||
for m in self.descriptorProvider.getDescriptor(iface.identifier.name).interface.members:
|
||||
if m.isAttr():
|
||||
# We initialize all the other member variables in the
|
||||
# Constructor except those ones coming from the Event.
|
||||
if getattr(m, "originatingInterface",
|
||||
cgClass.descriptor.interface).identifier.name == "Event":
|
||||
continue
|
||||
name = CGDictionary.makeMemberName(m.identifier.name)
|
||||
members += "e->%s = %s.%s;\n" % (name, self.args[1].name, name)
|
||||
if m.type.isAny() or m.type.isObject() or m.type.isSpiderMonkeyInterface():
|
||||
@ -10891,6 +10905,9 @@ class CGEventClass(CGBindingImplClass):
|
||||
members = []
|
||||
for m in descriptor.interface.members:
|
||||
if m.isAttr():
|
||||
if getattr(m, "originatingInterface",
|
||||
descriptor.interface) != descriptor.interface:
|
||||
continue
|
||||
if m.type.isPrimitive() and m.type.tag() in builtinNames:
|
||||
nativeType = CGGeneric(builtinNames[m.type.tag()])
|
||||
if m.type.nullable():
|
||||
|
@ -677,6 +677,11 @@ class IDLInterface(IDLObjectWithScope):
|
||||
for ancestorConsequential in ancestor.getConsequentialInterfaces():
|
||||
ancestorConsequential.interfacesBasedOnSelf.add(self)
|
||||
|
||||
for member in self.members:
|
||||
if (member.isAttr() and member.isUnforgeable() and
|
||||
not hasattr(member, "originatingInterface")):
|
||||
member.originatingInterface = self
|
||||
|
||||
if self.parent:
|
||||
# Make sure we don't shadow any of the [Unforgeable] attributes on
|
||||
# our ancestor interfaces. We don't have to worry about
|
||||
|
@ -1,12 +1,9 @@
|
||||
{
|
||||
"DOMException exception: existence and properties of exception interface prototype object": true,
|
||||
"DOMException exception: existence and properties of exception interface prototype object's \"name\" property": true,
|
||||
"Event interface: document.createEvent(\"Event\") must have own property \"isTrusted\"": true,
|
||||
"Event interface: document.createEvent(\"Event\") must inherit property \"timeStamp\" with the proper type (15)": true,
|
||||
"Event interface: new Event(\"foo\") must have own property \"isTrusted\"": true,
|
||||
"Event interface: new Event(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true,
|
||||
"CustomEvent interface: existence and properties of interface object": true,
|
||||
"Event interface: new CustomEvent(\"foo\") must have own property \"isTrusted\"": true,
|
||||
"Event interface: new CustomEvent(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true,
|
||||
"EventListener interface: existence and properties of interface prototype object": true,
|
||||
"EventListener interface: existence and properties of interface prototype object's \"constructor\" property": true,
|
||||
|
@ -30,6 +30,7 @@ interface Event {
|
||||
void preventDefault();
|
||||
readonly attribute boolean defaultPrevented;
|
||||
|
||||
[Unforgeable]
|
||||
readonly attribute boolean isTrusted;
|
||||
readonly attribute DOMTimeStamp timeStamp;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user